* Chapter 7 Comparison of two means: confidence intervals, hypothesis tests and p-values * modified on Jan. 13, 2007 by Leena Choi * Section 7.3 Example 7.1 input group n x_mean sd 1 36 4.7 0.6 0 64 5.0 0.6 end gen z = invnormal(.975) gen diff = x_mean[1] - x_mean[2] gen se = sqrt(sd[1]^2/n[1] + sd[2]^2/n[2]) gen l_ci = diff - z*se gen u_ci = diff + z*se list l_ci u_ci in 1 *find 10%, 1% percent point gen z_score = diff/se * one-sided p-value di normal(z_score) * two-sided p-values di 2*normal(z_score) * Section 7.4 Table 7.2 * Example 7.2 use "C:\Teaching\IGP\data\birthweight.dta", clear label data "Comparison of birth weights (kg) of children born to 14 heavy smokers with those of children born to 15 non-smokers." notes: "Data from EMS Table. 7.2" notes: "Created on Jan. 14, 2007" *label define smokelab 1 "Smokers" 0 "Non-smokers" label values smoke smokelab ttest weight, by(smoke) sdtest weight, by(smoke) di invttail(14+15-2, .025) ttest weight, by(smoke) unequal * Section 7.6 Table 7.3 label data "A placebo-controlled clinical trial to test the effectiveness of a sleeping drug" notes: "Data from EMS Table. 7.3" notes: "Created on Jan. 14, 2007" di invttail(9, .025) use "C:\Teaching\IGP\data\sleepingdrug.dta", clear ttest drug=placebo