version 8.0 set more on log using 3.11.1.Framingham.log, replace * 3.11.1.Framingham.log * * Plot a scatterplot matrix of log(sbp), log(bmi), age and log(scl) for * women from the Framingham Heart Study who were recruited in January. * use 2.20.Framingham.dta generate logsbp = log(sbp) label variable logsbp "Log Systolic Blood Pressure" generate logbmi = log(bmi) label variable logbmi "Log Body Mass Index" generate logscl = log(scl) label variable logscl "Log Serum Cholesterol" set textsize 120 graph matrix logsbp logbmi age logscl if month==1 & sex==2, msymbol(Oh) /// mcolor(gs10) more * * Use multiple regression models to analyze the effects of log(sbp), * log(bmi), age and log(scl) on log(sbp) * generate woman = sex - 1 generate wo_lbmi = woman * logbmi generate wo_age = woman * age generate wo_lscl = woman * logscl regress logsbp logbmi age logscl woman wo_lbmi wo_age wo_lscl regress logsbp logbmi age logscl woman wo_lbmi wo_age regress logsbp logbmi age logscl woman wo_age * * Calculate 95% confidence and prediction intervals for a 60 year-old * woman with a SCL of 400 and a BMI of 40. * edit set obs 4700 replace scl = 400 in 4700 replace age = 60 in 4700 replace bmi = 40 in 4700 replace woman = 1 in 4700 replace id = 9999 in 4700 replace logbmi = log(bmi) if id == 9999 replace logscl = log(scl) if id == 9999 replace wo_age = woman*age if id == 9999 predict yhat,xb predict h, leverage predict std_yhat, stdp predict std_f, stdf generate cil_yhat = yhat - invttail(4658-5-1,.025)*std_yhat generate ciu_yhat = yhat + invttail(4658-5-1,.025)*std_yhat generate cil_f = yhat - invttail(4658-5-1,.025)*std_f generate ciu_f = yhat + invttail(4658-5-1,.025)*std_f generate cil_sbpf = exp(cil_f) generate ciu_sbpf = exp(ciu_f) list bmi age scl woman logbmi logscl yhat h std_yhat std_f cil_yhat /// ciu_yhat cil_f ciu_f cil_sbpf ciu_sbpf if id==9999 display invttail(4652,.025) * * Repeat the preceding analysis using an automatic forward * selection algorithm * drop if id == 9999 sw regress logsbp logbmi age logscl woman wo_lbmi wo_age wo_lscl, forward pe(.1) * * Draw a scatterplot of studentized residuals against the estimated expected * value of logsbp together with the corresponding lowess regression curve. * predict t, rstudent lowess t yhat, bwidth(0.2) msymbol(Oh) mcolor(gs10) clwidth(thick) /// ylabel(-3(1)5) yline(-1.96 0 1.96) xlabel(4.7(.1)5.1) more generate out = t > 1.96 | t < -1.96 tabulate out * * Perform an influence analysis on patients 2000 through 2050 * keep if id >= 2000 & id <= 2050 regress logsbp logbmi age logscl woman wo_age drop t h predict h, leverage predict z, rstandard predict t, rstudent predict deltab1, dfbeta(logbmi) predict cook, cooksd display invttail(43,.025) label variable deltab1 "Delta Beta for log[BMI]" scatter deltab1 t, msymbol(Oh) ylabel(-1.5(.5)0, angle(0)) yline(0) /// xlabel(-2(1)4) xtick(-2.5(.5)4.5) xline(-2 2) sort t list id h z t deltab1 cook in -3/-1 regress logsbp logbmi age logscl woman wo_age if id ~=2049 display ( .1659182 - .3675337 )/.1489199 log close