I have the following data
I would like to estimate the following model
It is a DiD analysis in a panel setting with time and individual fixed effects.
However, when I run the code from above I get the following error message: "depvars may not be interactions"
I also tried to do the estimation by hand:
Here the interaction (the variable of interest) gets omitted. This is strange because when I try this with ivreghdfe, I do get an estimate. Here, however, with a warning that the standard errors might be flawed.
Is it generally possible to estimate my model in this context (without any warnings or caveats in terms of my standard errors)? Which commands shall I use?
I'd appreciate any help.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id byte(wave pre_post) float anyMMactivity_consistent byte(treatment_2 control_2) float(target close_rule) str24 b_tc_name 1 1 0 1 1 0 1 0 "Kibiito B" 1 2 1 1 1 0 0 0 "Kibiito B" 2 1 0 0 1 0 1 0 "Kibiito B" 2 2 1 1 1 0 0 0 "Kibiito B" 3 1 0 1 1 0 1 16 "Kibiito B" 3 2 1 1 1 0 0 16 "Kibiito B" 4 1 0 1 1 0 1 0 "Kibiito B" 4 2 1 1 1 0 0 0 "Kibiito B" 5 1 0 0 1 0 1 16 "Kibiito" 5 2 1 1 1 0 0 16 "Kibiito" 6 1 0 1 0 1 1 0 "Kibiito B" 6 2 1 1 0 1 0 0 "Kibiito B" 7 1 0 1 1 0 1 16 "Kibiito" 7 2 1 1 1 0 0 16 "Kibiito" 8 1 0 1 1 0 1 16 "Kibiito B" 8 2 1 1 1 0 0 16 "Kibiito B" 9 1 0 0 0 0 0 0 "Mujunju 2" 9 2 1 . 0 0 0 0 "Mujunju 2" 10 1 0 0 1 0 0 5 "Kibiito" 10 2 1 1 1 0 0 5 "Kibiito" end
Code:
xtivreg anyMMactivity_consistent i.pre_post##i.treatment_2 i.wave (pre_post#treatment_2 = close_rule) if treatment_2 == 1 | control_2 == 1, fe vce(cluster b_tc_name)
However, when I run the code from above I get the following error message: "depvars may not be interactions"
I also tried to do the estimation by hand:
Code:
gen interaction = pre_post*treatment_2
xtivreg anyMMactivity_consistent i.wave (interaction = close_rule) if treatment_2 == 1 | control_2 == 1, fe vce(cluster b_tc_name)
Fixed-effects (within) IV regression Number of obs = 3,950
Group variable: id Number of groups = 1,975
R-sq: Obs per group:
within = 0.3528 min = 2
between = . avg = 2.0
overall = 0.1952 max = 2
Wald chi2(1) = 915.11
corr(u_i, Xb) = 0.0000 Prob > chi2 = 0.0000
(Std. Err. adjusted for 108 clusters in b_tc_name)
------------------------------------------------------------------------------
| Robust
anyMMactiv~t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
interaction | 0 (omitted)
2.wave | .4040506 .0133567 30.25 0.000 .3778719 .4302293
_cons | .5002532 .0066784 74.91 0.000 .4871638 .5133425
-------------+----------------------------------------------------------------
sigma_u | .30567061
sigma_e | .38718957
rho | .38395074 (fraction of variance due to u_i)
------------------------------------------------------------------------------
Instrumented: interaction
Instruments: 2.wave close_rule
------------------------------------------------------------------------------
Code:
. ivreghdfe anyMMactivity_consistent i.pre_post##i.treatment_2 target (pre_post#treatment_2 = close_rule) if treatment_2 == 1 | control_2 == 1, absorb(i.id i.wave) cluster(b_tc_name)
Warning - duplicate variables detected
Duplicates: 1.pre_post#1.treatment_2
note: variable #2 is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
note: variable #3 is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
note: variable #6 is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
(MWFE estimator converged in 2 iterations)
OLS estimation
--------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on b_tc_name
Number of clusters (b_tc_name) = 108 Number of obs = 3950
F( 2, 107) = 2.87
Prob > F = 0.0611
Total (centered) SS = 295.7837975 Centered R2 = 0.0037
Total (uncentered) SS = 295.7837975 Uncentered R2 = 0.0037
Residual SS = 294.7025325 Root MSE = .2733
--------------------------------------------------------------------------------------
| Robust
anyMMactivity_cons~t | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---------------------+----------------------------------------------------------------
pre_post |
0 | 0 (empty)
1 | 0 (omitted)
|
treatment_2 |
0 | 0 (empty)
1 | 0 (omitted)
|
pre_post#treatment_2 |
0 0 | 0 (empty)
0 1 | 0 (empty)
1 0 | 0 (empty)
1 1 | .0709197 .030044 2.36 0.020 .0113611 .1304784
|
target | .0171343 .025644 0.67 0.505 -.0337019 .0679705
--------------------------------------------------------------------------------------
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
------------------------------------------------------------------------------
Collinearities detected among instruments: 3 instrument(s) dropped
Included instruments: 1.pre_post 1.treatment_2 1.pre_post#1.treatment_2 target
Excluded instruments: close_rule
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
Duplicates: 1.pre_post#1.treatment_2
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
id | 1975 1975 0 *|
wave | 2 0 2 |
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
I'd appreciate any help.
