0
votes

How do I name a model after correcting for heteroskedasticity in R? Basically, how do I save a model so that it includes the robust standard errors? I am using the plm package if that makes a difference.

So let's say I have these two models below:

model1<-plm(x~y+z,data=dataset,model="within")
model2<-plm(x~y,data=dataset,model="within")

But then I correct for heteroskedasticity:

coeftest(model1,vcovHC)
coeftest(model2,vcovHC)

How do I save the model so I can do a Wald test to compare the two? I tried doing the following below but it doesn't seem to be correct:

model1B<-coeftest(model1,vcovHC)
model2B<-coeftest(model2,vcovHC)

Basically I am trying to be able to do the following but with robust standard errors:

waldtest(model1,model2)
1

1 Answers

0
votes

Using the first example in ?plm::vcovHC and loading a few more packages including lmtest where I eventually found waldtest, I proceed further in this manner:

zz2 <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) ,
      data = Produc, model = "random")

And then compare using vcovHC as an argument to the vcov parameter in waldtest:

 waldtest(zz, zz2, vcov=vcovHC)
Wald test

Model 1: log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
Model 2: log(gsp) ~ log(pcap) + log(pc) + log(emp)
  Res.Df Df  Chisq Pr(>Chisq)   
1    811                        
2    812 -1 7.0021   0.008141 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

With default vcov:

> waldtest(zz, zz2)
Wald test

Model 1: log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
Model 2: log(gsp) ~ log(pcap) + log(pc) + log(emp)
  Res.Df Df  Chisq Pr(>Chisq)    
1    811                         
2    812 -1 46.284  1.023e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1