R Stepwise alternative for automatic model selection for panel regression models (plm)
Asked Answered
H

1

6

Im running a panel regression (randon effects) and i have several regressor candidates.

 X.panel3.form = as.formula(c("value ~ ",paste(X.panel3.cols,collapse="+")))

> X.panel3.form
value ~ SMB + HML + MOM + IBX + EQWO + TERMBZ + BZCDS5Y + COEN + 
    COMP + COMI + COAG + DOL + VIX + SPX + TERMUS

Then I run a simple panel regression model

fit.plm = plm(X.panel3.form,data=panel,index = c("variable","Date"),  model="random")

This would be the full model, but i would like to automatically select models with fewer regressors. similar to a Stepwise procedure.

in facts stepwise with and optimization by AIC would be the best reference in mind, something simple to keep only the more relevant regressors.

the point is that Step() function does not work for panel data in R (I believe its because theres no maximum likelyhood estimation for panel models)

so when running the Step(), StepAIC()(from Mass package)

i got the error:

Error in UseMethod("extractAIC") : 
  no applicable method for 'extractAIC' applied to an object of class "c('plm', 'panelmodel')"

so my question is: What would be an anternative for automatic model selection in R and a possible simple implementation for panel datasets when using the plm package?

Horton answered 29/7, 2016 at 12:34 Comment(4)
You have read this?Porpoise
Roland, tks for the link. I'm aware of the possible problems with automatic model selection approach. But for this preliminary study (and this comes from a boss) I need to limit regressors from a candidate list.Horton
Still with no luck getting an information criteria to run a automatic model selection... now im tring to adapt a rlme/lme4 mixed model to accomplish the same thing...Horton
Hi Alexander, were you able to find answer to your question? I am on the same problem as yoursSavoy
E
0

You can try the solution I found at this other question (full credit to the original solver):

    logLik.plm <- function(object){
  out <- -plm::nobs(object) * log(2 * var(object$residuals) * pi)/2 - deviance(object)/(2 * var(object$residuals))
  
  attr(out,"df") <- nobs(object) - object$df.residual
  attr(out,"nobs") <- plm::nobs(summary(object))
  return(out)
}

He created a gist here

Adding this function adds the possibility to calculate AIC and BIC for plm objects

Ebneter answered 11/12, 2023 at 20:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.