Hi,
I am new on R and I have been trying to simply correct for heteroskedasticity. I use the following function
cse=function(reg) {
rob=sqrt(diag(vcovHC(reg, type="HC1")))
return(rob)
}
and then regress two models with and without correction :
library(wooldridge)
data(wage1)
head(wage1)
ols1<-lm(wage~educ, wage1)
ols2<-lm(wage~educ, wage1)
and display them using stargazer
library(wooldridge)
data(wage1)
head(wage1)
ols1<-lm(wage~educ, wage1)
ols2<-lm(wage~educ, wage1)
stargazer( ols1, ols2, type="text", se=list( cse(ols2)), column.labels=c("non-robust", "Robust"))
Yet, stargazer does not correct the second model (ols2) but the first one. How come? I did specify that the cse function ought to be apply to the ols2 object. I don't get why it is correcting only the SE for the first object (ols1) and not the second.
Thanks for your help