ccv(treatment, cluster=None, seed=None, n_splits=8, pk=1, qk=1)
Compute the Causal Cluster Variance following Abadie et al (QJE 2023).
Parameters
| treatment |
|
The name of the treatment variable. |
required |
| cluster |
str |
The name of the cluster variable. None by default. If None, uses the cluster variable from the model fit. |
None |
| seed |
int |
An integer to set the random seed. Defaults to None. |
None |
| n_splits |
int |
The number of splits to use in the cross-fitting procedure. Defaults to 8. |
8 |
| pk |
float |
The proportion of sampled clusters. Defaults to 1, which corresponds to all clusters of the population being sampled. |
1 |
| qk |
float |
The proportion of sampled observations within each cluster. Defaults to 1, which corresponds to all observations within each cluster being sampled. |
1 |
Returns
|
pd.DataFrame |
A DataFrame with inference based on the “Causal Cluster Variance” and “regular” CRV1 inference. |
Examples
import pyfixest as pf
import numpy as np
data = pf.get_data()
data["D"] = np.random.choice([0, 1], size=data.shape[0])
fit = pf.feols("Y ~ D", data=data, vcov={"CRV1": "group_id"})
fit.ccv(treatment="D", pk=0.05, qk=0.5, n_splits=8, seed=123).head()
| CCV |
-0.09017884663368153 |
0.206357 |
-0.437003 |
0.667307 |
-0.52372 |
0.343362 |
| CRV1 |
-0.090179 |
0.108273 |
-0.832882 |
0.415826 |
-0.317652 |
0.137295 |