--------------------------------------------------------------------------------------------------- log: C:\mydocs\MPH\Text\SecondEdition\WebDoFiles\2.12.Poison.log log type: text opened on: 26 Dec 2007, 20:26:51 . * 2.12.Poison.log . * . * Calculate the mean plasma glycolate and arterial pH levels for . * the ethylene glycol poisoning data of Brent et al. (1999). . * Regress glycolate levels against pH. Draw a scatter plot of . * glycolate against pH. Plot the linear regression line on this . * scatter plot together with the 95% confidence limits for this . * line and the 95% prediction intervals for new patients. . * . use C:\WDDtext\2.12.Poison.dta, clear . summarize ph glyco Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- ph | 18 7.210556 .1730512 6.88 7.47 glyco | 18 90.44 80.58488 0 265.24 . scatter glyco ph, xlabel(6.8(.1)7.5) ylabel(0(50)300, angle(0)) /// > symbol(Oh) yline(90.4) xline(7.21) . more . regress glyco ph Source | SS df MS Number of obs = 18 -------------+------------------------------ F( 1, 16) = 61.70 Model | 87664.6947 1 87664.6947 Prob > F = 0.0000 Residual | 22731.9877 16 1420.74923 R-squared = 0.7941 -------------+------------------------------ Adj R-squared = 0.7812 Total | 110396.682 17 6493.9225 Root MSE = 37.693 ------------------------------------------------------------------------------ glyco | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- ph | -414.9666 52.82744 -7.86 0.000 -526.9558 -302.9775 _cons | 3082.58 381.0188 8.09 0.000 2274.856 3890.304 ------------------------------------------------------------------------------ . predict yhat, xb . scatter glyco ph || line yhat ph /// > , ylabel(0(50)250) xlabel(6.9(.1)7.5) /// > ytitle(Plasma Glycolate (mg/dl)) legend(off) . . more . * . * The preceding graph could also have been generated without . * explicitly calculating yhat as follows. . * . scatter glyco ph || lfit glyco ph /// > , xlabel(6.9(.1)7.5) ytitle(Plasma Glycolate (mg/dl)) . more . * . * Add 95% confidence interval bands to the preceding graph. . * . twoway lfitci glyco ph || scatter glyco ph, symbol(Oh) /// > , ylabel(0(50)300) xlabel(6.9 (.1) 7.5) /// > ytitle(Plasma Glycolate (mg/dl)) legend(off) . more . * . * Add 95% prediction interval bands to the preceding graph. . * . twoway lfitci glyco ph, stdf ciplot(rline) color(gray) /// > || lfitci glyco ph, lpattern(solid) /// > || scatter glyco ph /// > , ylabel(0(50)300) xlabel(6.9 (.1) 7.5) /// > ytitle(Plasma Glycolate (mg/dl)) legend(off) . more . * . * Derive a lowess regression curve for the ethylene glycol . * poisoning data using a bandwidth of 0.99. Plot this curve . * together with the linear regression line and a scatterplot of . * plasma glycolate by arterial pH levels. . * . twoway lfit glyco ph, color(gray) /// > || scatter glyco ph /// > || lowess glyco ph, bwidth(.99) lpattern(solid) /// > , xlabel(6.9 (.1) 7.5) ylabel(0(50)250) /// > ytitle(Plasma Glycolate (mg/dl)) legend(off) > . . log close log: C:\mydocs\MPH\Text\SecondEdition\WebDoFiles\2.12.Poison.log log type: text closed on: 26 Dec 2007, 20:27:30 -------------------------------------------------------------------------------------------------