Skip to content

IV models with a single regressor don't work with fancy covariance matrices #4

@tcovert

Description

@tcovert

Consider a (modified) example from the help:

zz <- plm(log(gsp) ~ log(pcap) | log(pc) + log(emp),
	     data = Produc, index = c("state","year"),
	     model = "within")

When you type summary(zz) you get:

> summary(zz)
Oneway (individual) effect Within Model
Instrumental variable estimation

Call:
plm(formula = log(gsp) ~ log(pcap) | log(pc) + log(emp), data = Produc, 
    model = "within", index = c("state", "year"))

Balanced Panel: n = 48, T = 17, N = 816

Residuals:
      Min.    1st Qu.     Median    3rd Qu.       Max. 
-0.3779409 -0.0561652 -0.0055046  0.0440775  0.4590412 

Coefficients:
          Estimate Std. Error z-value  Pr(>|z|)    
log(pcap) 1.528846   0.035191  43.444 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:    18.941
Residual Sum of Squares: 7.0211
R-Squared:      0.69103
Adj. R-Squared: 0.67169
Chisq: 1887.37 on 1 DF, p-value: < 2.22e-16

Now, what about Driscoll-Kraay standard errors?

> summary(zz, vcov = vcovSCC)
Error in demX[tind[[i]], , drop = FALSE] : incorrect number of dimensions

I believe the problem is in the definition of vcovG, where the variable demX is defined for models with instrumental variables. If the model matrix has just one column (as in the above example), demX is a column vector, not a matrix. I've found that if you wrap that line in an as.matrix everything else works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmultiple topicsissue is about multiple topics in one GitHub issue

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions