1

I have used multiple imputation as provided by the mice package on my panel data (5 variables on annual basis, covering 3 years, 456 observations). Afterwards I estimated a fixed effects and a random effects model (thanks to this answer: Is it possible to use lqmm with a mira object?):

library(plm)
library(mice)
imp_data <- mice(data_panel, 
               predictorMatrix = predictormatrix_data,
               m=5,
               maxit=100,
               meth='cart')

mod.1 <- with(imp_data,
                     plm(y~ x1 + x2 + x3 + x4,
                         data = data.frame(mget(ls())),
                         index = c("Name", "Year"),
                         effect = "individual", model = "within"))
summary(pool(mod.1))

mod.2 <- with(imp_data,
                     plm(y~ x1 + x2 + x3 + x4,
                         data = data.frame(mget(ls())),
                         index = c("Name", "Year"),
                         model = "random"))
summary(pool(mod.2))

I have also estimated cluster robust standard errors for the fixed effects model:

datlist <- miceadds::mids2datlist(imp_data)
# linear regression with cluster robust standard errors
mod <- lapply(datlist, FUN = function(data){miceadds::lm.cluster(data=data ,         
                                                                 formula=y~ x1 + x2 + x3 + x4
                                                                   + factor(id), 
                                                                 cluster = data_panel$id)}  )

# extract parameters and covariance matrix
betas <- lapply( mod , FUN = function(rr){ coef(rr) } )
vars <- lapply( mod , FUN = function(rr){ vcov(rr) } )
# conduct statistical inference
mod.coef <- summary(pool_mi( qhat = betas, u = vars ))

Now I would like to compare the fixed effects and the random effects models by applying a Hausman test, as suggested by my thesis supervisor. Unfortunately, I cannot figure out how to do it. The phtest function in the plm package does not work for mira objects. I would appreciate any help or hint.

0 Answers0