linearmodels.panel.covariance.ClusteredCovariance

class ClusteredCovariance(y, x, params, entity_ids, time_ids, *, debiased=False, extra_df=0, clusters=None, group_debias=False)[source]

One-way (Rogers) or two-way clustered covariance estimation

Parameters
yndarray

nobs by 1 stacked array of dependent

xndarray

nobs by variables stacked array of exogenous

paramsndarray

variables by 1 array of estimated model parameters

entity_idsndarray

(entity x time) by 1 stacked array of entity ids

time_idsndarray

(entity x time) by 1 stacked array of time ids

debiasedbool

Flag indicating whether to debias the estimator

extra_dfint

Additional degrees of freedom consumed by models beyond the number of columns in x, e.g., fixed effects. Covariance estimators are always adjusted for extra_df irrespective of the setting of debiased

clustersndarray

nobs by 1 or nobs by 2 array of cluster group ids

group_debiasbool

Flag indicating whether to apply small-number of groups adjustment.

Notes

The estimator of the covariance is

\[\hat{\Sigma}_{xx}^{-1}\hat{S}_{\mathcal{G}}\hat{\Sigma}_{xx}^{-1}\]

where

\[\hat{\Sigma}_{xx} = X'X\]

and \(\hat{S}_{\mathcal{G}}\) is a one- or two-way cluster covariance of the scores. Two-way clustering is implemented by summing up the two one-way cluster covariances and then subtracting the one-way clustering covariance computed using the group formed from the intersection of the two groups.

Two small sample adjustment are available. debias=True will account for regressors in the main model. group_debias=True will provide a small sample adjustment for the number of clusters of the form

\[(g / (g- 1)) ((n - 1) / n)\]

where g is the number of distinct groups and n is the number of observations.

Attributes
cov

Estimated covariance

eps

Model residuals

name

Covariance estimator name

s2

Error variance

Methods

deferred_cov()

Covariance calculation deferred until executed

Properties

ALLOWED_KWARGS

DEFAULT_KERNEL

cov

Estimated covariance

eps

Model residuals

name

Covariance estimator name

s2

Error variance