statsmodels.stats.sandwich_covariance.cov_cluster_2groups#
- statsmodels.stats.sandwich_covariance.cov_cluster_2groups(results, group, group2=None, use_correction=True, crv_type='cluster')[source]#
Cluster robust covariance matrix for two groups/clusters
- Parameters:
- results
resultinstance result of a regression, uses results.model.exog and results.resid TODO: this should use wexog instead
- group
ndarray Group/cluster indicator for the first cluster dimension. If group2 is not given, group must be a 2-D array with two columns, one for each cluster dimension.
- group2
ndarray,optional Group/cluster indicator for the second cluster dimension.
- use_correctionbool,
optional If true (default), then the small sample correction factor is used.
- crv_type{“cluster”},
optional Only ‘cluster’ (default), computing the additive two-way CRV1 combination
cov0 + cov1 - cov01, is supported here. Passing ‘cluster-crv3’ or ‘cluster-jk’ raisesValueError; usecov_clusterdirectly with one-way clustering for those options.
- results
- Returns:
- cov_both
ndarray, (k_vars,k_vars) cluster robust covariance matrix for parameter estimates, for both clusters
- cov_0
ndarray, (k_vars,k_vars) cluster robust covariance matrix for parameter estimates for first cluster
- cov_1
ndarray, (k_vars,k_vars) cluster robust covariance matrix for parameter estimates for second cluster
- cov_both
Notes
verified against Peterson’s table, (4 decimal print precision)