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:
- y
ndarray
nobs by 1 stacked array of dependent
- x
ndarray
nobs by variables stacked array of exogenous
- params
ndarray
variables by 1 array of estimated model parameters
- entity_ids
ndarray
(entity x time) by 1 stacked array of entity ids
- time_ids
ndarray
(entity x time) by 1 stacked array of time ids
- debiasedbool
Flag indicating whether to debias the estimator
- extra_df
int
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
- clusters
ndarray
nobs by 1 or nobs by 2 array of cluster group ids
- group_debiasbool
Flag indicating whether to apply small-number of groups adjustment.
- y
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:
Methods
Covariance calculation deferred until executed
Properties
Estimated covariance
Model residuals
Covariance estimator name
Error variance