For ivreghdfe, I could find summary stats of the regressor by running something like this
What can I do to obtain summary stats of X for the observations that were used in the regression that used ivreg2hdfe?
Random data to run this can be created by running the following.
ivreghdfe Y (X=Z) C, absorb(FE1 FE2) cluster(Cluster)But for ivreg2hdfe, it seems it doesn't work.
summarize X if e(sample), detail
ivreg2hdfe, depvar(Y) en(X) ex(C) iv(Z) id1(FE1) id2(FE2) cluster(Cluster)It seems e(sample) simply didn't work for ivreg2hdfe.
summarize X if e(sample), detail
What can I do to obtain summary stats of X for the observations that were used in the regression that used ivreg2hdfe?
Random data to run this can be created by running the following.
clear
* Set a random seed for reproducibility
set seed 12345
* Generate random variables
set obs 100 // Number of observations
generate Y = rnormal(0,1)
generate X = rnormal(0,1) // Independent variable
generate Z = rnormal(0,1) // Instrumental variable
generate C = rnormal(0,1) // Control variable
* Create categorical fixed effects variables
gen FE1 = floor((uniform() * 5) + 1) // Categorical fixed effect with 5 categories
gen FE2 = floor((uniform() * 3) + 1) // Categorical fixed effect with 3 categories
* Create a cluster variable
gen Cluster = floor((uniform() * 5) + 1)
* Regression
ivreghdfe Y (X=Z) C, absorb(FE1 FE2) cluster(Cluster)
summarize X if e(sample), detail
ivreg2hdfe, depvar(Y) en(X) ex(C) iv(Z) id1(FE1) id2(FE2) cluster(Cluster)
summarize X if e(sample), detail
Comment