Closed tcovert closed 3 years ago
Thank you for reporting with a reproducible example and the analysis! I will commit a fix to our development repository later this day.
This is fixed in revision #1125 in our development repository (currently building): https://r-forge.r-project.org/R/?group_id=406
It affected all vcovXX
functions making use of vcovG
(vcovHC
, vcovNW
, vcovDC
, vcovSCC
) as well as the vcovBK
which does not make use of vcovG
.
I found a similar issue in within_intercept, which also seems to not support models with one covariate.
Here is a reproducible example:
data("Produc", package = "plm")
zz <- plm(log(gsp) ~ log(pcap), data = Produc, index = c("state","year"), model = "within")
inter <- within_intercept(zz)
The error message is
Error in colMeans(M) : 'x' must be an array of at least two dimensions
.
Again, wrapping M with as.matrix
seems to fix the issue.
Thank you for reporting! This is similar but code-wise independent.
Fixed by adding one of the famous drop = FALSE
addition to matrix subsetting in within_intercept
in rev. 1143 on R-Forge.
plm version 2.4-2 now on CRAN (2021-09-21) containing these fixes
Consider a (modified) example from the help:
When you type
summary(zz)
you get:Now, what about Driscoll-Kraay standard errors?
I believe the problem is in the definition of
vcovG
, where the variabledemX
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 anas.matrix
everything else works.