I have performed multiple Pooled regressions with a loop function and stored the regression output in a list (myregression). What I would like to do now is to efficiently perform the coeftest function in the lmtest package over all my regressions (i.e., myregression list) to adjust standard errors and t-statistics. Finally I would like to obtain the mean of the coefficients, standard errors and t-values.
Here is what I came up so far:
library(plm)
data("Grunfeld", package="plm")
# Store each subset regression in myregression
myregression <- list()
count <- 1
# Regression on six-year subsets of Grunfeld
for(t in 1940:1950){
myregression[[count]] <- plm(inv ~ value + capital,
subset(Grunfeld, year<=t & year>=t-5),
index=c("firm","year"))
# Name each regression based on the year range included in the data subset
names(myregression)[[count]] = paste0("Year_",t)
count <- count+1
}
Here is where my problems kick in: Although i'm able to perform the coeftest function to invidiual components of the list, I'm unable to code the lapply function accordingly.
## Apply coeftest function to all plm-objects
library(lmtest)
coeftest(myregression$Year_1940, vcov=function(x) vcovSCC(x, type="HC3", maxlag=4))
coeftest(myregression$Year_1941, vcov=function(x) vcovSCC(x, type="HC3", maxlag=4))
COEFTEST<-lapply(myregression, coeftest(x, vcov=function(x) vcovSCC(x, type="HC3", maxlag=4)))
## obtaining average coefficients, se's,and t values over all regressions
lapply(COEFTEST, mean)
I hope there is only a minor mistake that I'm unable to see. I further noticed that the plm regression output is smaller than regular lm output is there another way to obtain mean adj. R^2?