I believe I have found a way of having three variables (ID, Time and type) as fixed effect using the plm function (where I have previously indexed the ("ID","Time") in pdata.frame):
FixedEffects <- plm(Y ~ x1 + X2 + factor(type),
data = GeneralPanel,
model = "within",
effect = "twoways")
I a looking for a way to now do something similar but where ID is random effect and the other two are fixed. Does this work?
RandomEffects <- plm(Y ~ x1 + X2 + factor(type),
data = GeneralPanel,
model = "random",
effect = "individual")
I tried this next piece of code and it did not work:
RandomEffects <- plm(Y ~ x1 + X2 + factor(type) + factor(Time),
data = GeneralPanel,
model = "random",
effect = "individual")
It seems to make sense but it gave me this error:
Error in solve.default(crossprod(ZBeta)) :
Lapack routine dgesv: system is exactly singular: U[28,28] = 0
If I take out the factor(Time) it doesn't give an error, but I'm not sure it is giving me the answer I want. If I take out the factor(type) (which is not what I want anyways) it also gives me an error:
Error in solve.default(crossprod(ZBeta)) :
Lapack routine dgesv: system is exactly singular: U[6,6] = 0
How can I do two fixed effects variables (Year and type) and one random effects (ID) with plm in R?