
Last chance! 50% off unlimited learning
Sale ends in
Estimation of sandwich covariances a la Newey-West (1987) and Driscoll and Kraay (1998) for panel data.
vcovPL(x, cluster = NULL, order.by = NULL,
kernel = "Bartlett", sandwich = TRUE, fix = FALSE, …)meatPL(x, cluster = NULL, order.by = NULL,
kernel = "Bartlett", lag = "NW1987", bw = NULL,
adjust = TRUE, …)
a fitted model object.
a variable indicating the clustering of observations
or a list
(or data.frame
) thereof. By default,
either attr(x, "cluster")
is used. If that is also NULL
each observation is its own cluster.
a variable indicating the aggregation within time periods.
a character specifying the kernel used. All kernels
described in Andrews (1991) are supported, see kweights
.
character or numeric, indicating the lag length used.
Three rules of thumb ("max"
or equivalently "P2009"
,
"NW1987"
, or "NW1994"
) can be specified, or a numeric
number of lags can be specified directly. By default, "NW1987"
is used.
numeric. The bandwidth of the kernel which by default corresponds
to lag + 1
. Only one of lag
and bw
should be
used.
logical. Should the sandwich estimator be computed?
If set to FALSE
only the meat matrix is returned.
logical. Should the covariance matrix be fixed to be positive semi-definite in case it is not?
logical. Should a finite sample adjustment be made? This
amounts to multiplication with
arguments passed to the metaPL
or estfun
function,
respectively.
A matrix containing the covariance matrix estimate.
vcovPL
is a function for estimating the Newey-West (1987) and
Driscoll and Kraay (1998) covariance matrix.
Driscoll and Kraay (1998) apply a Newey-West type correction to the
sequence of cross-sectional averages of the moment conditions (see
Hoechle (2007)). For large
The function meatPL
is the work horse for estimating
the meat of Newey-West (1978) and Driscoll and Kraay (1998)
covariance matrix estimators. vcovPL
is a wrapper calling
sandwich
and bread
(Zeileis 2006).
Default lag length is the "NW1987"
.
For lag = "NW1987"
, the lag length is chosen from the heuristic
lag = "NW1994"
,
the lag length is taken from the first step of Newey and West's
(1994) plug-in procedure.
Andrews DWK (1991). “Heteroscedasticity and Autocorrelation Consistent Covariance Matrix Estimation”, Econometrica, 817--858.
Driscoll JC & Kraay AC (1998). “Consistent Covariance Matrix Estimation with Spatially Dependent Panel Data”, The Review of Economics and Statistics, 80(4), 549--560.
Hoechle D (2007). “Robust Standard Errors for Panel Regressions with Cross-Sectional Dependence”, Stata Journal, 7(3), 281--312.
Newey WK & West KD (1987). “Hypothesis Testing with Efficient Method of Moments Estimation”, International Economic Review, 777-787.
Newey WK & West KD (1994). “Automatic Lag Selection in Covariance Matrix Estimation”, The Review of Economic Studies, 61(4), 631--653.
White H (1980). “A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity”, Econometrica, 817--838. 10.2307/1912934
Zeileis A (2004). “Econometric Computing with HC and HAC Covariance Matrix Estimator”, Journal of Statistical Software, 11(10), 1--17. 10.18637/jss.v011.i10
Zeileis A (2006). “Object-Oriented Computation of Sandwich Estimators”, Journal of Statistical Software, 16(9), 1--16. 10.18637/jss.v016.i09
# NOT RUN {
## Petersen's data
data("PetersenCL", package = "sandwich")
m <- lm(y ~ x, data = PetersenCL)
## Driscoll and Kraay standard errors
## lag length set to: T - 1 (maximum lag length)
## as proposed by Petersen (2009)
sqrt(diag(vcovPL(m, cluster = PetersenCL$firm, lag = "max", adjust = FALSE)))
## lag length set to: floor(4 * (T / 100)^(2/9))
## rule of thumb proposed by Hoechle (2007) based on Newey & West (1994)
sqrt(diag(vcovPL(m, cluster = PetersenCL$firm, lag = "NW1994")))
## lag length set to: floor(T^(1/4))
## rule of thumb based on Newey & West (1987)
sqrt(diag(vcovPL(m, cluster = PetersenCL$firm, lag = "NW1987")))
# }
Run the code above in your browser using DataLab