# vcovPC

##### Panel-Corrected Covariance Matrix Estimation

Estimation of sandwich covariances a la Beck and Katz (1995) for panel data.

- Keywords
- regression

##### Usage

```
vcovPC(x, cluster = NULL, order.by = NULL,
pairwise = FALSE, sandwich = TRUE, fix = FALSE, …)
```meatPC(x, cluster = NULL, order.by = NULL,
pairwise = FALSE, kronecker = TRUE, …)

##### Arguments

- x
a fitted model object.

- cluster
a variable indicating the clustering of observations or a

`list`

(or`data.frame`

) thereof. By default, either`attr(x, "cluster")`

is used.- order.by
a variable indicating the aggregation within time periods.

- pairwise
logical. For unbalanced panels. Indicating whether the meat should be estimated pair- or casewise.

- sandwich
logical. Should the sandwich estimator be computed? If set to

`FALSE`

only the meat matrix is returned.- fix
logical. Should the covariance matrix be fixed to be positive semi-definite in case it is not?

- kronecker
logical. Calculate the meat via the Kronecker-product, shortening the computation time for small matrices. For large matrices, set

`kronecker = FALSE`

.- …
arguments passed to the

`meatPC`

or`estfun`

function, respectively.

##### Details

`vcovPC`

is a function for estimating Beck and Katz (1995)
panel-corrected covariance matrix.

The function `meatPC`

is the work horse for estimating
the meat of Beck and Katz (1995) covariance matrix estimators.
`vcovPC`

is a wrapper calling
`sandwich`

and `bread`

(Zeileis 2006).

Following Bailey and Katz (2011), there are two alternatives to
estimate the meat for unbalanced panels.
For `pairwise = FALSE`

, a balanced subset of the panel is used,
whereas for `pairwise = TRUE`

, a pairwise balanced sample is
employed.

##### Value

A matrix containing the covariance matrix estimate.

##### References

Bailey D & Katz JN (2011).
“Implementing Panel-Corrected Standard Errors in R: The pcse Package”,
*Journal of Statistical Software, Code Snippets*, **42**(1), 1--11.
URL http://www.jstatsoft.org/v42/c01/

Beck N & Katz JN (1995).
“What To Do (and Not To Do) with Time-Series-Cross-Section Data
in Comparative Politics”,
*American Political Science Review*, **89**(3), 634--647.
URL http://www.jstor.org/stable/2082979

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

##### Examples

`library(sandwich)`

```
# NOT RUN {
## Petersen's data
data("PetersenCL", package = "sandwich")
m <- lm(y ~ x, data = PetersenCL)
## Beck and Katz (1995) standard errors
## balanced panel
sqrt(diag(vcovPC(m, cluster = PetersenCL$firm, order.by = PetersenCL$year)))
## unbalanced panel
PU <- subset(PetersenCL, !(firm == 1 & year == 10))
pu_lm <- lm(y ~ x, data = PU)
sqrt(diag(vcovPC(pu_lm, cluster = PU$firm, order.by = PU$year, pairwise = TRUE)))
sqrt(diag(vcovPC(pu_lm, cluster = PU$firm, order.by = PU$year, pairwise = FALSE)))
# }
```

*Documentation reproduced from package sandwich, version 2.4-0, License: GPL-2 | GPL-3*