use https://stats.idre.ucla.edu/stat/stata/examples/methods_matter/chapter4/nyvoucher, clear
Descriptive statistics for the variables voucher, pre_ach, and post_ach. Note: this output does not appear in the text.
sum voucher pre_ach post_ach Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- voucher | 521 .5585413 .4970383 0 1 pre_ach | 521 20.16411 18.25523 0 92 post_ach | 521 23.8666 19.2089 0 89
Strategy #1 from Table 4.1 on page 49.
ttest post_ach, by(voucher) Two-sample t test with equal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] ---------+-------------------------------------------------------------------- 0 | 230 21.13043 1.198249 18.17234 18.76943 23.49144 1 | 291 26.02921 1.158 19.754 23.75006 28.30836 ---------+-------------------------------------------------------------------- combined | 521 23.8666 .841557 19.2089 22.21333 25.51987 ---------+-------------------------------------------------------------------- diff | -4.898775 1.682719 -8.204552 -1.592998 ------------------------------------------------------------------------------ diff = mean(0) - mean(1) t = -2.9112 Ho: diff = 0 degrees of freedom = 519 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.0019 Pr(|T| > |t|) = 0.0038 Pr(T > t) = 0.9981
Strategy #2 from Table 4.1 on page 49.
reg post_ach voucher Source | SS df MS Number of obs = 521 -------------+------------------------------ F( 1, 519) = 8.48 Model | 3082.89021 1 3082.89021 Prob > F = 0.0038 Residual | 188787.589 519 363.752579 R-squared = 0.0161 -------------+------------------------------ Adj R-squared = 0.0142 Total | 191870.479 520 368.98169 Root MSE = 19.072 ------------------------------------------------------------------------------ post_ach | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- voucher | 4.898775 1.682719 2.91 0.004 1.592998 8.204552 _cons | 21.13043 1.25759 16.80 0.000 18.65984 23.60103 ------------------------------------------------------------------------------
Strategy #3 from Table 4.1 on page 49.
reg post_ach voucher pre_ach Source | SS df MS Number of obs = 521 -------------+------------------------------ F( 2, 518) = 205.40 Model | 84863.1705 2 42431.5852 Prob > F = 0.0000 Residual | 107007.308 518 206.577815 R-squared = 0.4423 -------------+------------------------------ Adj R-squared = 0.4401 Total | 191870.479 520 368.98169 Root MSE = 14.373 ------------------------------------------------------------------------------ post_ach | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- voucher | 4.097609 1.26873 3.23 0.001 1.60512 6.590097 pre_ach | .6873125 .0345439 19.90 0.000 .619449 .7551759 _cons | 7.718877 1.162978 6.64 0.000 5.434143 10.00361 ------------------------------------------------------------------------------