I'm currently working on a project for which I need to differ my main explanatory variable. I'm building an individual fixed effects model with plm and need to "cut in half" a variable. Unfortunately I can't provide a repex but a part of the code.
low_troop <- plm(POLSTAB ~ US + RDURAB + DEMOC + POP, data = US, index = c('COUNTRY'), model = 'within', effect = "individual")
high_troop <- plm(POLSTAB ~ US+ RDURAB + DEMOC + POP, data = US, index = c('COUNTRY'), model = 'within', effect = "individual"
In my panel data, US is the number of US Soldiers abroad. I'd love to have one plm for all data where the value for US is >100 and one for US value <100. Is this possible without creating a new dataset?
Thank you all so much for your help.
Regards,
Lawrence
Just subset data in the data=
argument; example:
library(plm)
data(Grunfeld)
wi.lo <- plm(inv ~ value + capital, data=Grunfeld[Grunfeld$value >= 1000,],
index="firm", model="within", effect="individual")
wi.hi <- plm(inv ~ value + capital, data=Grunfeld[Grunfeld$value < 1000,],
index="firm", model="within", effect="individual")
summary(wi.lo)$coef
# Estimate Std. Error t-value Pr(>|t|)
# value 0.1132322 0.02024847 5.592138 6.934243e-07
# capital 0.3455339 0.03022447 11.432257 2.868412e-16
summary(wi.hi)$coef
# Estimate Std. Error t-value Pr(>|t|)
# value 0.09465974 0.01115671 8.484558 4.579648e-14
# capital 0.09808216 0.01249071 7.852408 1.431317e-12