Generic Lego building block for robust covariance matrix estimators of the vcovXX kind for panel models.
vcovG(x, ...)
# S3 method for class 'plm'
vcovG(
x,
type = c("HC0", "sss", "HC1", "HC2", "HC3", "HC4"),
cluster = c("group", "time"),
l = 0,
inner = c("cluster", "white", "diagavg"),
...
)
# S3 method for class 'pcce'
vcovG(
x,
type = c("HC0", "sss", "HC1", "HC2", "HC3", "HC4"),
cluster = c("group", "time"),
l = 0,
inner = c("cluster", "white", "diagavg"),
...
)an object of class "plm" or "pcce"
further arguments
the weighting scheme used, one of "HC0",
"sss", "HC1", "HC2", "HC3", "HC4",
one of "group", "time",
lagging order, defaulting to zero
the function to be applied to the residuals inside the
sandwich: one of "cluster" or "white" or
"diagavg", or a user specified R function,
An object of class "matrix" containing the estimate
of the covariance matrix of coefficients.
vcovG is the generic building block for use by higher–level
wrappers vcovHC(), vcovSCC(), vcovDC(), and vcovNW(). The
main use of vcovG is to be used internally by the former, but it
is made available in the user space for use in non–standard
combinations. For more documentation, see see wrapper functions
mentioned.
Millo G (2017). “Robust standard error estimators for panel models: A unifying approach.” Journal of Statistical Software, 82(3), 1–27.
data("Produc", package="plm")
zz <- plm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc,
model="pooling")
## reproduce Arellano's covariance matrix
vcovG(zz, cluster="group", inner="cluster", l=0)
#> (Intercept) log(pcap) log(pc) log(emp)
#> (Intercept) 0.0596248904 -9.637916e-03 -0.0068911857 0.0148866870
#> log(pcap) -0.0096379163 3.614354e-03 -0.0002956929 -0.0031157168
#> log(pc) -0.0068911857 -2.956929e-04 0.0021371841 -0.0017597732
#> log(emp) 0.0148866870 -3.115717e-03 -0.0017597732 0.0047067982
#> unemp 0.0003700792 -8.058266e-05 -0.0000586966 0.0001366349
#> unemp
#> (Intercept) 3.700792e-04
#> log(pcap) -8.058266e-05
#> log(pc) -5.869660e-05
#> log(emp) 1.366349e-04
#> unemp 9.550671e-06
#> attr(,"cluster")
#> [1] "group"
## define custom covariance function
## (in this example, same as vcovHC)
myvcov <- function(x) vcovG(x, cluster="group", inner="cluster", l=0)
summary(zz, vcov = myvcov)
#> Pooling Model
#>
#> Note: Coefficient variance-covariance matrix supplied: myvcov
#>
#> Call:
#> plm(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
#> data = Produc, model = "pooling")
#>
#> Balanced Panel: n = 48, T = 17, N = 816
#>
#> Residuals:
#> Min. 1st Qu. Median 3rd Qu. Max.
#> -0.23176215 -0.06103699 -0.00010248 0.05085197 0.35111348
#>
#> Coefficients:
#> Estimate Std. Error t-value Pr(>|t|)
#> (Intercept) 1.6433023 0.2441821 6.7298 3.211e-11 ***
#> log(pcap) 0.1550070 0.0601195 2.5783 0.01010 *
#> log(pc) 0.3091902 0.0462297 6.6881 4.209e-11 ***
#> log(emp) 0.5939349 0.0686061 8.6572 < 2.2e-16 ***
#> unemp -0.0067330 0.0030904 -2.1787 0.02964 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Total Sum of Squares: 849.81
#> Residual Sum of Squares: 6.2942
#> R-Squared: 0.99259
#> Adj. R-Squared: 0.99256
#> F-statistic: 2778.06 on 4 and 47 DF, p-value: < 2.22e-16
## use in coefficient significance test
library(lmtest)
## robust significance test
coeftest(zz, vcov. = myvcov)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.6433023 0.2441821 6.7298 3.211e-11 ***
#> log(pcap) 0.1550070 0.0601195 2.5783 0.01010 *
#> log(pc) 0.3091902 0.0462297 6.6881 4.209e-11 ***
#> log(emp) 0.5939349 0.0686061 8.6572 < 2.2e-16 ***
#> unemp -0.0067330 0.0030904 -2.1787 0.02964 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>