linearmodels.iv.covariance.ClusteredCovariance¶
-
class linearmodels.iv.covariance.ClusteredCovariance(x: ndarray[Any, dtype[float64]], y: ndarray[Any, dtype[float64]], z: ndarray[Any, dtype[float64]], params: ndarray[Any, dtype[float64]], clusters: ndarray[Any, Any] | None =
None
, debiased: bool =False
, kappa: int | float =1
)[source]¶ Covariance estimation for clustered data
- Parameters:¶
- x: ndarray[Any, dtype[float64]]¶
Model regressors (nobs by nvar)
- y: ndarray[Any, dtype[float64]]¶
Series ,modeled (nobs by 1)
- z: ndarray[Any, dtype[float64]]¶
Instruments used for endogenous regressors (nobs by ninstr)
- params: ndarray[Any, dtype[float64]]¶
Estimated model parameters (nvar by 1)
- debiased: bool =
False
¶ Flag indicating whether to use a small-sample adjustment
- clusters: ndarray[Any, Any] | None =
None
¶ Cluster group assignment. If not provided, uses clusters of 1. Either nobs by ncluster where ncluster is 1 or 2.
- kappa: int | float =
1
¶ Value of kappa in k-class estimator
Notes
Covariance is estimated using
\[n^{-1} V^{-1} \hat{S} V^{-1}\]where
\[\begin{split}\hat{S} & = n^{-1} (G/(G-1)) \sum_{g=1}^G \xi_{g}^\prime \xi_{g} \\ \xi_{g} & = \sum_{i\in\mathcal{G}_g} \hat{\epsilon}_i \hat{x}_i \\\end{split}\]where \(\hat{\gamma}=(Z'Z)^{-1}(Z'X)\) and \(\hat{x}_i = z_i\hat{\gamma}\). \(\mathcal{G}_g\) contains the indices of elements in cluster g. If
debiased
is true, then \(S\) is scaled by g(n - 1) / ((g-1)(n-k)) where g is the number of groups..\[V = n^{-1} X'Z(Z'Z)^{-1}Z'X\]where \(X\) is the matrix of variables included in the model and \(Z\) is the matrix of instruments, including exogenous regressors.
Methods
Properties
Covariance of estimated parameters
Flag indicating if covariance is debiased
Clustered estimator of score covariance
Estimated variance of residuals.