Reputation: 139
I am running a individual-level fixed effect ols using the plm function. In the relevant model I regress an independent variable with 2 levels that varies between-subjects (between-subject treatment) and another independent variable with 2 levels that varies within-subjects (within subject treatment).
The summary of plm does not display the coefficient for the independent variable that varies within-subject. Inspecting model.matrix I noticed that the column of interest consists of all zeros.
Is there any way to solve the problem? Maybe resorting to a different type of contrast? Or by design is impossible to estimate the effect of a within-subject variable in fixed effect model like this?
Any help would be much appreciated.
#Reproducible example (unrelated with my actual dataset)
structure(list(DOILN = c(4.3207, 4.1675, 4.0718, 3.8239, 3.6247,
2.044, 1.3759, 1.4596, 1.486, 4.3136), ROSLN = c(-2.0178, -2.2647,
-4.0632, -3.9933, -3.441, -3.6077, -2.8291, -2.6271, -2.4051,
-1.7239), IRATE = c(-0.0295, -0.1228, 0.00288, 0.03388, -0.0295,
0.00288, 0.03849, 0.03388, 0.07165, 0.04809), GDPGROW = c(0.11731,
0.07891, 0.05072, 0.05745, 0.11731, 0.05072, 0.02142, 0.05745,
0.06645, -0.01765), ISOCode = structure(c(4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 3L), .Label = c("BRA", "CHN", "IND", "RUS"), class = "factor"),
ISOCodeBRA = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ISOCodeRUS = c(1,
1, 1, 1, 1, 1, 1, 1, 1, 0), ISOCodeIND = c(0, 0, 0, 0, 0,
0, 0, 0, 0, 1), ISOCodeCHN = c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0)), .Names = c("DOILN", "ROSLN", "IRATE", "GDPGROW", "ISOCode",
"ISOCodeBRA", "ISOCodeRUS", "ISOCodeIND", "ISOCodeCHN"), row.names = c("120453-2010",
"120453-2011", "120453-2012", "120453-2014", "133431-2010", "133431-2012",
"133431-2013", "133431-2014", "133431-2015", "200448-2009"), class = c("pdata.frame",
"data.frame"), index = structure(list(GCKey = structure(c(1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L), .Label = c("120453", "133431",
"200448"), class = "factor"), FiscalY = structure(c(2L, 3L, 4L,
6L, 2L, 4L, 5L, 6L, 7L, 1L), .Label = c("2009", "2010", "2011",
"2012", "2013", "2014", "2015"), class = "factor")), .Names = c("GCKey",
"FiscalY"), row.names = c(915L, 647L, 35L, 41L, 83L, 68L, 220L,
330L, 497L, 1219L), class = c("pindex", "data.frame")))
mod <-plm(ROSLN ~ DOILN + GDPGROW + IRATE + factor(ISOCode),
data = dat, model = "within")
model.matrix(mod)
summary(mod)
Upvotes: 0
Views: 117
Reputation: 21937
I think the problem is that you're using a within model and there is no variation on ISOCode
within GCKey
- which is the index.
> table(index(dat)$GCKey, dat$ISOCode)
BRA CHN IND RUS
120453 0 0 0 4
133431 0 0 0 5
200448 0 0 1 0
So, applying the within transformation to the ISOCode
dummy regressors produces a vector of all zeros. For example, if you used model='pooling'
, you would see a model matrix that was more like you expected.
Upvotes: 1