Error computing Robust Standard errors in Panel regression model (plm,R) -
i using plm library run fixed effect regressions , sandwich,lmtest libraries compute robust standard errors. have no problem running regressions, in instances when go compute standard errors following error:
library(plm) library(sandwich) library(lmtest) fe_reg <- plm(y ~ x + i(x^2)+factor(date), data=reg_data, index=c("id","date"), model="within") coeftest(fe_reg, vcov.=vcovhc(fe_reg, type="hc1")) rruntimeerror: error in solve.default(crossprod(demx)) system computationally singular: reciprocal condition number = 1.84726e-25
i not have problems computing coefficients or "normal" standard errors (ie homoscedastic). also, have no problem computing robust standard errors when omit quadratic term:
fe_reg <- plm(y ~ x +factor(date), data=reg_data, index=c("id","date"), model="within")
anyone have idea going on? if design matrix singular coefficients should not have been computed, don't understand issue coming when computing standard errors.
thanks!
if remember correctly, plm
not verbose. think possible have singular matrix plm not complain. lm
more verbose. try
lm_mod1 <- lm(y ~ x + i(x^2)+factor(date), data=reg_data) summary(lm_mod1)
lm
will tell in it's summary output if there problem calculating 1 coefficient (coefficient na
in table , there should note @ top of output well). edit: note @ top of lm's summary output should "coefficients: (1 not defined because of singularities)" in case.
edit there possibility why coeftest not working: if model.matrix
contrains large values small values, solve
might not able solve system of linear equations computation in vcovhc
function. thus, have @ model.matrix(y ~ x + i(x^2)+factor(date), data=reg_data)
if case. if so, try rescaling variables (e.g. multiply oder divide 100 oder 1000 [also log()
makes sense sometimes). take care, interpretation of coefficients changes due change of scales!
Comments
Post a Comment