High-level convenience wrapper for double-clustering robust covariance matrix estimators a la Thompson (2011) and Cameron et al. (2011) for panel models.
vcovDC(x, ...)
# S3 method for class 'plm'
vcovDC(x, type = c("HC0", "sss", "HC1", "HC2", "HC3", "HC4"), ...)An object of class "matrix" containing the estimate of
the covariance matrix of coefficients.
vcovDC is a function for estimating a robust covariance matrix of
parameters for a panel model with errors clustering along both dimensions.
The function is a convenience wrapper simply summing a group- and a
time-clustered covariance matrix and subtracting a diagonal one a la
White.
Weighting schemes specified by type are analogous to those in
sandwich::vcovHC() in package sandwich and are
justified theoretically (although in the context of the standard
linear model) by MacKinnon and White (1985)
and
Cribari–Neto (2004)
(see Zeileis 2004)
.
The main use of vcovDC (and the other variance-covariance estimators
provided in the package vcovHC, vcovBK, vcovNW, vcovSCC) is to pass
it to plm's own functions like summary, pwaldtest, and phtest or
together with testing functions from the lmtest and car packages. All of
these typically allow passing the vcov or vcov. parameter either as a
matrix or as a function, e.g., for Wald–type testing: argument vcov. to
coeftest(), argument vcov to waldtest() and other methods in the
lmtest package; and argument vcov. to
linearHypothesis() in the car package (see the
examples), see (see also Zeileis 2004)
, 4.1-2, and examples below.
Cameron AC, Gelbach JB, Miller DL (2011). “Robust inference with multiway clustering.” Journal of Business & Economic Statistics, 29(2).
Cribari–Neto F (2004). “Asymptotic Inference Under Heteroskedasticity of Unknown Form.” Computational Statistics & Data Analysis, 45, 215–233.
MacKinnon JG, White H (1985). “Some Heteroskedasticity–Consistent Covariance Matrix Estimators With Improved Finite Sample Properties.” Journal of Econometrics, 29, 305–325.
Thompson SB (2011). “Simple formulas for standard errors that cluster by both firm and time.” Journal of Financial Economics, 99(1), 1–10.
Zeileis A (2004). “Econometric Computing With HC and HAC Covariance Matrix Estimators.” Journal of Statistical Software, 11(10), 1–17. https://www.jstatsoft.org/article/view/v011i10.
sandwich::vcovHC() from the sandwich
package for weighting schemes (type argument).
data("Produc", package="plm")
zz <- plm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, model="pooling")
## as function input to plm's summary method (with and without additional arguments):
summary(zz, vcov = vcovDC)
#> Pooling Model
#>
#> Note: Coefficient variance-covariance matrix supplied: vcovDC
#>
#> 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.643302 0.252047 6.5198 1.237e-10 ***
#> log(pcap) 0.155007 0.061718 2.5115 0.01221 *
#> log(pc) 0.309190 0.044957 6.8774 1.217e-11 ***
#> log(emp) 0.593935 0.070203 8.4603 < 2.2e-16 ***
#> unemp -0.006733 0.003330 -2.0219 0.04351 *
#> ---
#> 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: 2975.74 on 4 and 811 DF, p-value: < 2.22e-16
summary(zz, vcov = function(x) vcovDC(x, type="HC1", maxlag=4))
#> Pooling Model
#>
#> Note: Coefficient variance-covariance matrix supplied: function(x) vcovDC(x, type = "HC1", maxlag = 4)
#>
#> 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.2528223 6.4998 1.403e-10 ***
#> log(pcap) 0.1550070 0.0619079 2.5038 0.01248 *
#> log(pc) 0.3091902 0.0450955 6.8563 1.400e-11 ***
#> log(emp) 0.5939349 0.0704186 8.4343 < 2.2e-16 ***
#> unemp -0.0067330 0.0033403 -2.0157 0.04416 *
#> ---
#> 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: 2957.51 on 4 and 811 DF, p-value: < 2.22e-16
## standard coefficient significance test
library(lmtest)
coeftest(zz)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.6433023 0.0575873 28.5359 < 2.2e-16 ***
#> log(pcap) 0.1550070 0.0171538 9.0363 < 2.2e-16 ***
#> log(pc) 0.3091902 0.0102720 30.1003 < 2.2e-16 ***
#> log(emp) 0.5939349 0.0137475 43.2032 < 2.2e-16 ***
#> unemp -0.0067330 0.0014164 -4.7537 2.363e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## DC robust significance test, default
coeftest(zz, vcov.=vcovDC)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.643302 0.252047 6.5198 1.237e-10 ***
#> log(pcap) 0.155007 0.061718 2.5115 0.01221 *
#> log(pc) 0.309190 0.044957 6.8774 1.217e-11 ***
#> log(emp) 0.593935 0.070203 8.4603 < 2.2e-16 ***
#> unemp -0.006733 0.003330 -2.0219 0.04351 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## idem with parameters, pass vcov as a function argument
coeftest(zz, vcov.=function(x) vcovDC(x, type="HC1", maxlag=4))
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.6433023 0.2528223 6.4998 1.403e-10 ***
#> log(pcap) 0.1550070 0.0619079 2.5038 0.01248 *
#> log(pc) 0.3091902 0.0450955 6.8563 1.400e-11 ***
#> log(emp) 0.5939349 0.0704186 8.4343 < 2.2e-16 ***
#> unemp -0.0067330 0.0033403 -2.0157 0.04416 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## joint restriction test
waldtest(zz, update(zz, .~.-log(emp)-unemp), vcov=vcovDC)
#> Wald test
#>
#> Model 1: log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
#> Model 2: log(gsp) ~ log(pcap) + log(pc)
#> Res.Df Df Chisq Pr(>Chisq)
#> 1 811
#> 2 813 -2 109.61 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
if (FALSE) { # \dontrun{
## test of hyp.: 2*log(pc)=log(emp)
library(car)
linearHypothesis(zz, "2*log(pc)=log(emp)", vcov.=vcovDC)
} # }