Hello guys,
for my thesis, i am using a combination of matching and DiD.
As i want to show the matching quality after my matching step, i want to run "ttest" to see if the difference in the covariates are significant between the treatment and the control group.
Depending on what covariate i am adding to the analysis, the sample size is decreasing (as not every variable is observable for every year i have in my data).
My question is. How do i run a ttest for the "reduced" sample size?
To make my point clear, i will try to show you the problem.
I am running this code to get my estimates...
which gives me the following output
457 men in treated group and 538 women in the treated group when including all covariates in the analysis.
Now when i run the ttest with the following code (example for men i.e. female==0)
i will only post the output for the age variable ( i only used those 6 variables as a test that i get the code right, the final code for the ttest will include all covariates)
which is correct, as 784 represents the number of the controlgroup BEFORE applying the matching step with all covariates and 64046 is the sample size of the control group, also before applying the matching step.
But how do i run ttest for the reduced sample size after matching? ( In this case 457 men as shown above )
Thanks in advance
for my thesis, i am using a combination of matching and DiD.
As i want to show the matching quality after my matching step, i want to run "ttest" to see if the difference in the covariates are significant between the treatment and the control group.
Depending on what covariate i am adding to the analysis, the sample size is decreasing (as not every variable is observable for every year i have in my data).
My question is. How do i run a ttest for the "reduced" sample size?
To make my point clear, i will try to show you the problem.
I am running this code to get my estimates...
Code:
set more off global exact welle_* global xvars age age2 mig foreign lifesat lifesat2 uni voctrain labinc labinc2 pgerwzeit pgerwzeit2 nounemp pgexpft pgexpft2 /// kids_* badhlth medhlth goodhlth pgpsbil2_1 pgpsbil2_2 pgpsbil2_3 pgpsbil2_5 d11106 own rel3 mardur yearmar_2 yearmar_3 foreach x in 0 1 { preserve keep if female==`x' foreach y in lifesat { qui reg d1`y' treat $xvars $exact [weight=w_treat] est store m`x'_1 qui count if treat==1 & e(sample) estadd scalar obs =r(N) } restore }
Code:
. foreach x in 0 1 { 2. preserve 3. keep if female==`x' 4. foreach y in lifesat { 5. qui reg d1`y' treat $xvars $exact [weight=w_treat] 6. est store m`x'_1 7. qui count if treat==1 & e(sample) 8. estadd scalar obs =r(N) 9. } 10. restore 11. } (70,644 observations deleted) added scalar: e(obs) = 457 (62,173 observations deleted) added scalar: e(obs) = 538
Now when i run the ttest with the following code (example for men i.e. female==0)
Code:
global xvars_wobula1 age lifesat mig foreign labinc uni foreach x in 0 { preserve keep if female==`x' foreach var of varlist $xvars_wobula1 { estpost ttest `var', by (treat) } restore }
Code:
| e(b) e(count) e(se) e(t) e(df_t) e(p_l) e(p) e(p_u) -------------+---------------------------------------------------------------------------------------- age | 5.766025 64830 .3456512 16.68163 64828 1 2.41e-62 1.20e-62 | e(N_1) e(mu_1) e(N_2) e(mu_2) -------------+-------------------------------------------- age | 64046 43.77368 784 38.00765
But how do i run ttest for the reduced sample size after matching? ( In this case 457 men as shown above )
Thanks in advance
Comment