{smcl} {com}{sf}{ul off}{txt}{.-} name: {res} {txt}log: {res}/Users/steve/Dropbox/work/teaching/biostat208/labs/lab4/lab4.smcl {txt}log type: {res}smcl {txt}opened on: {res}25 Jan 2021, 08:31:03 {txt} {com}. . . use lab4, clear {txt} {com}. . label list {txt}noyes: {res} 0 no 1 yes {txt}ht: {res} 0 placebo 1 hormone therapy {txt}raceth: {res} 1 white 2 African American 3 Latina, Asian, other {txt}physact: {res} 1 much less active 2 somewhat less active 3 about as active 4 somewhat more active 5 much more active {txt} {com}. . * indicator for being relatively inactive . recode physact 2=1 3/5=0, gen(lessactive) {txt}(2566 differences between physact and lessactive) {com}. label variable lessactive "less active than peers" {txt} {com}. label values lessactive noyes {txt} {com}. tab physact lessactive {txt}{c |} less active than comparative physical {c |} peers activity {c |} no yes {c |} Total {hline 21}{c +}{hline 22}{c +}{hline 10} much less active {c |}{res} 0 197 {txt}{c |}{res} 197 {txt}somewhat less active {c |}{res} 0 503 {txt}{c |}{res} 503 {txt} about as active {c |}{res} 919 0 {txt}{c |}{res} 919 {txt}somewhat more active {c |}{res} 838 0 {txt}{c |}{res} 838 {txt} much more active {c |}{res} 306 0 {txt}{c |}{res} 306 {txt}{hline 21}{c +}{hline 22}{c +}{hline 10} Total {c |}{res} 2,063 700 {txt}{c |}{res} 2,763 {txt} {com}. . * three-level alcohol use variable . recode drnkspwk 0.2/4.9999 = 1 5/max = 2, gen(drinkamt) {txt}(1081 differences between drnkspwk and drinkamt) {com}. label variable drinkamt "alcohol consumption" {txt} {com}. label define drinkamt 0 "none" 1 "<5 drinks/week" 2 ">= 5 drinks/week" {txt} {com}. label values drinkamt drinkamt {txt} {com}. tab drnkspwk drinkamt {txt}average {c |} drinks per {c |} alcohol consumption week {c |} none <5 drinks >= 5 drin {c |} Total {hline 11}{c +}{hline 33}{c +}{hline 10} 0 {c |}{res} 1,682 0 0 {txt}{c |}{res} 1,682 {txt} .2333333 {c |}{res} 0 228 0 {txt}{c |}{res} 228 {txt} .4666667 {c |}{res} 0 54 0 {txt}{c |}{res} 54 {txt} .5833333 {c |}{res} 0 203 0 {txt}{c |}{res} 203 {txt} .7 {c |}{res} 0 7 0 {txt}{c |}{res} 7 {txt} .9333333 {c |}{res} 0 3 0 {txt}{c |}{res} 3 {txt} 1.166667 {c |}{res} 0 83 0 {txt}{c |}{res} 83 {txt} 1.4 {c |}{res} 0 1 0 {txt}{c |}{res} 1 {txt} 1.5 {c |}{res} 0 89 0 {txt}{c |}{res} 89 {txt} 1.75 {c |}{res} 0 14 0 {txt}{c |}{res} 14 {txt} 2.333333 {c |}{res} 0 5 0 {txt}{c |}{res} 5 {txt} 2.916667 {c |}{res} 0 1 0 {txt}{c |}{res} 1 {txt} 3 {c |}{res} 0 55 0 {txt}{c |}{res} 55 {txt} 3.5 {c |}{res} 0 47 0 {txt}{c |}{res} 47 {txt} 4.5 {c |}{res} 0 17 0 {txt}{c |}{res} 17 {txt} 5.5 {c |}{res} 0 0 44 {txt}{c |}{res} 44 {txt} 6 {c |}{res} 0 0 4 {txt}{c |}{res} 4 {txt} 7 {c |}{res} 0 0 99 {txt}{c |}{res} 99 {txt} 10.5 {c |}{res} 0 0 12 {txt}{c |}{res} 12 {txt} 11 {c |}{res} 0 0 36 {txt}{c |}{res} 36 {txt} 14 {c |}{res} 0 0 54 {txt}{c |}{res} 54 {txt} 16.5 {c |}{res} 0 0 3 {txt}{c |}{res} 3 {txt} 21 {c |}{res} 0 0 12 {txt}{c |}{res} 12 {txt} 22 {c |}{res} 0 0 2 {txt}{c |}{res} 2 {txt} 28 {c |}{res} 0 0 4 {txt}{c |}{res} 4 {txt} 35 {c |}{res} 0 0 1 {txt}{c |}{res} 1 {txt} 42 {c |}{res} 0 0 2 {txt}{c |}{res} 2 {txt} 49.5 {c |}{res} 0 0 1 {txt}{c |}{res} 1 {txt}{hline 11}{c +}{hline 33}{c +}{hline 10} Total {c |}{res} 1,682 807 274 {txt}{c |}{res} 2,763 {txt} {com}. . * natural log of triglyceride level . gen lntg = log(tgl) {txt}(4 missing values generated) {com}. . * select for complete data so nested models run on same sample . foreach x in lncr bmi bmi age raceth educ drinkamt lessactive lntg {c -(} {txt} 2{com}. drop if missing(`x') {txt} 3{com}. {c )-} {txt}(2 observations deleted) (5 observations deleted) (0 observations deleted) (0 observations deleted) (0 observations deleted) (2 observations deleted) (0 observations deleted) (0 observations deleted) (4 observations deleted) {com}. . * unadjusted model for crude association of BMI with log-creatinine levels . reg lncreat bmi, eform("exp(beta)") {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(1, 2748) = {res} 8.41 {txt} Model {c |} {res} .378193297 1 .378193297 {txt}Prob > F ={res} 0.0038 {txt} Residual {c |} {res} 123.586736 2,748 .044973339 {txt}R-squared ={res} 0.0031 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0027 {txt} Total {c |} {res} 123.964929 2,749 .045094554 {txt}Root MSE = {res} .21207 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} exp(beta){col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}bmi {c |}{col 14}{res}{space 2} 1.002129{col 26}{space 2} .000735{col 37}{space 1} 2.90{col 46}{space 3}0.004{col 54}{space 4} 1.000689{col 67}{space 3} 1.003571 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} .9930229{col 26}{space 2} .0211934{col 37}{space 1} -0.33{col 46}{space 3}0.743{col 54}{space 4} .9523239{col 67}{space 3} 1.035461 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * Relative increment in creatinine associated with 5-kg/m^2 increment in BMI . lincom bmi*5, eform {p 0 7}{space 1}{text:( 1)}{space 1} {res}5{res}*{res}bmi = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} exp(b){col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 1.010691{col 26}{space 2} .0037062{col 37}{space 1} 2.90{col 46}{space 3}0.004{col 54}{space 4} 1.003449{col 67}{space 3} 1.017984 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. * Percent increment in creatinine associated with 5-kg/m^2 increment in BMI . nlcom 100*(exp(_b[bmi]*5)-1) {txt}_nl_1: {res}100*(exp(_b[bmi]*5)-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} 1.069061{col 26}{space 2} .3706213{col 37}{space 1} 2.88{col 46}{space 3}0.004{col 54}{space 4} .342657{col 67}{space 3} 1.795466 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * model adjusting for confounders . regress lncreat bmi age i.raceth educyrs i.drinkamt lessactive, eform("exp(beta)") {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(8, 2741) = {res} 29.27 {txt} Model {c |} {res} 9.75651277 8 1.2195641 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 114.208416 2,741 .041666697 {txt}R-squared ={res} 0.0787 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0760 {txt} Total {c |} {res} 123.964929 2,749 .045094554 {txt}Root MSE = {res} .20412 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 23}{c |} exp(beta){col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 18}bmi {c |}{col 23}{res}{space 2} 1.001536{col 35}{space 2} .0007371{col 46}{space 1} 2.09{col 55}{space 3}0.037{col 63}{space 4} 1.000092{col 76}{space 3} 1.002982 {txt}{space 18}age {c |}{col 23}{res}{space 2} 1.006676{col 35}{space 2} .0006056{col 46}{space 1} 11.06{col 55}{space 3}0.000{col 63}{space 4} 1.005489{col 76}{space 3} 1.007864 {txt}{space 21} {c |} {space 15}raceth {c |} {space 4}African American {c |}{col 23}{res}{space 2} 1.108189{col 35}{space 2} .0164042{col 46}{space 1} 6.94{col 55}{space 3}0.000{col 63}{space 4} 1.076485{col 76}{space 3} 1.140826 {txt}Latina, Asian, other {c |}{col 23}{res}{space 2} .9669554{col 35}{space 2} .0211308{col 46}{space 1} -1.54{col 55}{space 3}0.124{col 63}{space 4} .9263967{col 76}{space 3} 1.00929 {txt}{space 21} {c |} {space 14}educyrs {c |}{col 23}{res}{space 2} .9978021{col 35}{space 2} .0015297{col 46}{space 1} -1.44{col 55}{space 3}0.151{col 63}{space 4} .9948072{col 76}{space 3} 1.000806 {txt}{space 21} {c |} {space 13}drinkamt {c |} {space 6}<5 drinks/week {c |}{col 23}{res}{space 2} .9923387{col 35}{space 2} .0089205{col 46}{space 1} -0.86{col 55}{space 3}0.392{col 63}{space 4} .9750004{col 76}{space 3} 1.009985 {txt}{space 4}>= 5 drinks/week {c |}{col 23}{res}{space 2} .9629118{col 35}{space 2} .0132512{col 46}{space 1} -2.75{col 55}{space 3}0.006{col 63}{space 4} .9372759{col 76}{space 3} .989249 {txt}{space 21} {c |} {space 11}lessactive {c |}{col 23}{res}{space 2} 1.061564{col 35}{space 2} .009842{col 46}{space 1} 6.44{col 55}{space 3}0.000{col 63}{space 4} 1.04244{col 76}{space 3} 1.081039 {txt}{space 16}_cons {c |}{col 23}{res}{space 2} .6558158{col 35}{space 2} .0341953{col 46}{space 1} -8.09{col 55}{space 3}0.000{col 63}{space 4} .5920786{col 76}{space 3} .7264145 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * Relative increment in creatinine associated with 5-kg/m^2 increment in BMI . lincom bmi*5, eform {p 0 7}{space 1}{text:( 1)}{space 1} {res}5{res}*{res}bmi = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} exp(b){col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 1.007704{col 26}{space 2} .003708{col 37}{space 1} 2.09{col 46}{space 3}0.037{col 54}{space 4} 1.00046{col 67}{space 3} 1.015001 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. * Percent increment in creatinine associated with 5-kg/m^2 increment in BMI . nlcom 100*(exp(_b[bmi]*5)-1) {txt}_nl_1: {res}100*(exp(_b[bmi]*5)-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} .7704428{col 26}{space 2} .3707982{col 37}{space 1} 2.08{col 46}{space 3}0.038{col 54}{space 4} .0436917{col 67}{space 3} 1.497194 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * Mediation . * Model 1: . reg lntg bmi age i.raceth educ i.drinkamt lessact {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(8, 2741) = {res} 28.21 {txt} Model {c |} {res} 33.6979045 8 4.21223807 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 409.325519 2,741 .149334374 {txt}R-squared ={res} 0.0761 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0734 {txt} Total {c |} {res} 443.023423 2,749 .161158029 {txt}Root MSE = {res} .38644 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lntg{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 18}bmi {c |}{col 23}{res}{space 2} .0134878{col 35}{space 2} .0013932{col 46}{space 1} 9.68{col 55}{space 3}0.000{col 63}{space 4} .0107559{col 76}{space 3} .0162196 {txt}{space 18}age {c |}{col 23}{res}{space 2} .0008696{col 35}{space 2} .0011388{col 46}{space 1} 0.76{col 55}{space 3}0.445{col 63}{space 4}-.0013635{col 76}{space 3} .0031026 {txt}{space 21} {c |} {space 15}raceth {c |} {space 4}African American {c |}{col 23}{res}{space 2}-.2579085{col 35}{space 2} .0280238{col 46}{space 1} -9.20{col 55}{space 3}0.000{col 63}{space 4}-.3128584{col 76}{space 3}-.2029586 {txt}Latina, Asian, other {c |}{col 23}{res}{space 2} .1219685{col 35}{space 2} .0413709{col 46}{space 1} 2.95{col 55}{space 3}0.003{col 63}{space 4} .0408471{col 76}{space 3} .2030899 {txt}{space 21} {c |} {space 14}educyrs {c |}{col 23}{res}{space 2}-.0059608{col 35}{space 2} .0029023{col 46}{space 1} -2.05{col 55}{space 3}0.040{col 63}{space 4}-.0116517{col 76}{space 3}-.0002699 {txt}{space 21} {c |} {space 13}drinkamt {c |} {space 6}<5 drinks/week {c |}{col 23}{res}{space 2}-.0516891{col 35}{space 2} .0170183{col 46}{space 1} -3.04{col 55}{space 3}0.002{col 63}{space 4}-.0850591{col 76}{space 3}-.0183192 {txt}{space 4}>= 5 drinks/week {c |}{col 23}{res}{space 2}-.1061394{col 35}{space 2} .0260528{col 46}{space 1} -4.07{col 55}{space 3}0.000{col 63}{space 4}-.1572245{col 76}{space 3}-.0550542 {txt}{space 21} {c |} {space 11}lessactive {c |}{col 23}{res}{space 2} .0322336{col 35}{space 2} .0175519{col 46}{space 1} 1.84{col 55}{space 3}0.066{col 63}{space 4}-.0021827{col 76}{space 3} .06665 {txt}{space 16}_cons {c |}{col 23}{res}{space 2} 4.702106{col 35}{space 2} .0987119{col 46}{space 1} 47.63{col 55}{space 3}0.000{col 63}{space 4} 4.508549{col 76}{space 3} 4.895663 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. scalar link1 = _b[bmi] {txt} {com}. * Percent increase in TG for a 5-kg/m^2 increase in BMI . nlcom 100*(exp(_b[bmi]*5)-1) {txt}_nl_1: {res}100*(exp(_b[bmi]*5)-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lntg{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} 6.976474{col 26}{space 2} .745209{col 37}{space 1} 9.36{col 46}{space 3}0.000{col 54}{space 4} 5.515892{col 67}{space 3} 8.437057 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * Model 2: . reg lncr bmi age i.raceth educ i.drinkamt lessactive {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(8, 2741) = {res} 29.27 {txt} Model {c |} {res} 9.75651277 8 1.2195641 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 114.208416 2,741 .041666697 {txt}R-squared ={res} 0.0787 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0760 {txt} Total {c |} {res} 123.964929 2,749 .045094554 {txt}Root MSE = {res} .20412 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 18}bmi {c |}{col 23}{res}{space 2} .001535{col 35}{space 2} .0007359{col 46}{space 1} 2.09{col 55}{space 3}0.037{col 63}{space 4} .000092{col 76}{space 3} .002978 {txt}{space 18}age {c |}{col 23}{res}{space 2} .0066537{col 35}{space 2} .0006015{col 46}{space 1} 11.06{col 55}{space 3}0.000{col 63}{space 4} .0054741{col 76}{space 3} .0078332 {txt}{space 21} {c |} {space 15}raceth {c |} {space 4}African American {c |}{col 23}{res}{space 2} .1027268{col 35}{space 2} .0148027{col 46}{space 1} 6.94{col 55}{space 3}0.000{col 63}{space 4} .0737011{col 76}{space 3} .1317524 {txt}Latina, Asian, other {c |}{col 23}{res}{space 2}-.0336029{col 35}{space 2} .021853{col 46}{space 1} -1.54{col 55}{space 3}0.124{col 63}{space 4}-.0764528{col 76}{space 3} .0092471 {txt}{space 21} {c |} {space 14}educyrs {c |}{col 23}{res}{space 2}-.0022003{col 35}{space 2} .001533{col 46}{space 1} -1.44{col 55}{space 3}0.151{col 63}{space 4}-.0052063{col 76}{space 3} .0008057 {txt}{space 21} {c |} {space 13}drinkamt {c |} {space 6}<5 drinks/week {c |}{col 23}{res}{space 2}-.0076908{col 35}{space 2} .0089894{col 46}{space 1} -0.86{col 55}{space 3}0.392{col 63}{space 4}-.0253174{col 76}{space 3} .0099359 {txt}{space 4}>= 5 drinks/week {c |}{col 23}{res}{space 2}-.0377934{col 35}{space 2} .0137616{col 46}{space 1} -2.75{col 55}{space 3}0.006{col 63}{space 4}-.0647776{col 76}{space 3}-.0108093 {txt}{space 21} {c |} {space 11}lessactive {c |}{col 23}{res}{space 2} .0597432{col 35}{space 2} .0092713{col 46}{space 1} 6.44{col 55}{space 3}0.000{col 63}{space 4} .0415638{col 76}{space 3} .0779225 {txt}{space 16}_cons {c |}{col 23}{res}{space 2}-.4218752{col 35}{space 2} .0521416{col 46}{space 1} -8.09{col 55}{space 3}0.000{col 63}{space 4} -.524116{col 76}{space 3}-.3196345 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. * overall effect of BMI on creatinine levels . * needed for evaluating mediation . scalar b_overall = _b[bmi] {txt} {com}. * Overall BMI effect: percent increase in creatinine for a 5-kg/m^2 increase in BMI . nlcom 100*(exp(_b[bmi]*5)-1) {txt}_nl_1: {res}100*(exp(_b[bmi]*5)-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} .7704428{col 26}{space 2} .3707982{col 37}{space 1} 2.08{col 46}{space 3}0.038{col 54}{space 4} .0436917{col 67}{space 3} 1.497194 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * Model 3: . reg lncr bmi age i.raceth educ i.drinkamt lessact lntg {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(9, 2740) = {res} 29.05 {txt} Model {c |} {res} 10.7976826 9 1.19974251 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 113.167246 2,740 .041301915 {txt}R-squared ={res} 0.0871 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0841 {txt} Total {c |} {res} 123.964929 2,749 .045094554 {txt}Root MSE = {res} .20323 {txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 23}{c |} Coef.{col 35} Std. Err.{col 47} t{col 55} P>|t|{col 63} [95% Con{col 76}f. Interval] {hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 18}bmi {c |}{col 23}{res}{space 2} .0008547{col 35}{space 2} .0007451{col 46}{space 1} 1.15{col 55}{space 3}0.251{col 63}{space 4}-.0006063{col 76}{space 3} .0023158 {txt}{space 18}age {c |}{col 23}{res}{space 2} .0066098{col 35}{space 2} .000599{col 46}{space 1} 11.04{col 55}{space 3}0.000{col 63}{space 4} .0054353{col 76}{space 3} .0077843 {txt}{space 21} {c |} {space 15}raceth {c |} {space 4}African American {c |}{col 23}{res}{space 2} .1157342{col 35}{space 2} .0149638{col 46}{space 1} 7.73{col 55}{space 3}0.000{col 63}{space 4} .0863928{col 76}{space 3} .1450756 {txt}Latina, Asian, other {c |}{col 23}{res}{space 2}-.0397543{col 35}{space 2} .0217916{col 46}{space 1} -1.82{col 55}{space 3}0.068{col 63}{space 4}-.0824838{col 76}{space 3} .0029753 {txt}{space 21} {c |} {space 14}educyrs {c |}{col 23}{res}{space 2}-.0018997{col 35}{space 2} .0015275{col 46}{space 1} -1.24{col 55}{space 3}0.214{col 63}{space 4}-.0048948{col 76}{space 3} .0010955 {txt}{space 21} {c |} {space 13}drinkamt {c |} {space 6}<5 drinks/week {c |}{col 23}{res}{space 2}-.0050839{col 35}{space 2} .008965{col 46}{space 1} -0.57{col 55}{space 3}0.571{col 63}{space 4}-.0226627{col 76}{space 3} .012495 {txt}{space 4}>= 5 drinks/week {c |}{col 23}{res}{space 2}-.0324404{col 35}{space 2} .0137427{col 46}{space 1} -2.36{col 55}{space 3}0.018{col 63}{space 4}-.0593874{col 76}{space 3}-.0054933 {txt}{space 21} {c |} {space 11}lessactive {c |}{col 23}{res}{space 2} .0581175{col 35}{space 2} .0092363{col 46}{space 1} 6.29{col 55}{space 3}0.000{col 63}{space 4} .0400067{col 76}{space 3} .0762282 {txt}{space 17}lntg {c |}{col 23}{res}{space 2} .0504343{col 35}{space 2} .010045{col 46}{space 1} 5.02{col 55}{space 3}0.000{col 63}{space 4} .0307378{col 76}{space 3} .0701309 {txt}{space 16}_cons {c |}{col 23}{res}{space 2}-.6590229{col 35}{space 2} .0701846{col 46}{space 1} -9.39{col 55}{space 3}0.000{col 63}{space 4}-.7966429{col 76}{space 3}-.5214029 {txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt} {com}. scalar link2 = _b[lntg] {txt} {com}. scalar b_direct = _b[bmi] {txt} {com}. * Direct BMI effect: percent increase in creatinine for a 5-kg/m^2 increase in BMI . nlcom 100*(exp(_b[bmi]*5)-1) {txt}_nl_1: {res}100*(exp(_b[bmi]*5)-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} .4282816{col 26}{space 2} .3741551{col 37}{space 1} 1.14{col 46}{space 3}0.252{col 54}{space 4} -.305049{col 67}{space 3} 1.161612 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * Relative increase in creatinine for a 25% increast in TG . local l125 = log(1.25) {txt} {com}. lincom lntg*`l125', eform {p 0 7}{space 1}{text:( 1)}{space 1} {res}.2231436{res}*{res}lntg = 0{p_end} {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} exp(b){col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}(1) {c |}{col 14}{res}{space 2} 1.011318{col 26}{space 2} .0022668{col 37}{space 1} 5.02{col 46}{space 3}0.000{col 54}{space 4} 1.006883{col 67}{space 3} 1.015772 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. * Percent increase in creatinine for a 25% increase in TG . nlcom 100*(exp(_b[lntg]*log(1.25))-1) {txt}_nl_1: {res}100*(exp(_b[lntg]*log(1.25))-1) {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} z{col 46} P>|z|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 7}_nl_1 {c |}{col 14}{res}{space 2} 1.131766{col 26}{space 2} .2266849{col 37}{space 1} 4.99{col 46}{space 3}0.000{col 54}{space 4} .6874721{col 67}{space 3} 1.576061 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {com}. . * indirect effect of BMI on creatinine via TG . * on log-creatinine scale, for comparison with medeff results below . display link1*link2 {res}.00068025 {txt} {com}. * percent increase in creatinine for a 5 kg/m^2 increase in BMI . display 100*(exp(5*link1*link2)-1) {res}.34070202 {txt} {com}. . * indirect effect via subtraction . display b_overall-b_direct {res}.00068025 {txt} {com}. * percent increase in creatinine for a 5-kg/m^2 increase in BMI . display 100*(exp(5*(b_overall-b_direct))-1) {res}.34070202 {txt} {com}. . . * Percentage of adjusted BMI effect on log-creatinine explained by TG . scalar pe = (b_overall - b_direct)/b_overall*100 {txt} {com}. display round(pe, .1) {res}44.3 {txt} {com}. . capture program drop mediate {txt} {com}. program define mediate, rclass {txt} 1{com}. syntax varlist, outcome(varlist) mediator(varlist fv) covars(varlist fv) {txt} 2{com}. reg `outcome' `varlist' `covars' {txt} 3{com}. scalar b_overall = _b[`varlist'] {txt} 4{com}. reg `outcome' `varlist' `covars' `mediator' {txt} 5{com}. scalar b_direct = _b[`varlist'] {txt} 6{com}. return scalar pe = (b_overall - b_direct) / b_overall * 100 {txt} 7{com}. end {txt} {com}. * set seed for random number generator to make bootstrap results replicable . set seed 208 {txt} {com}. bootstrap pe=r(pe), reps(1000) notable nodots: mediate bmi, /// > outcome(lncr) mediator(lntg) covars(age i.raceth educ i.drinkamt lessactive) {res} {txt}Bootstrap results{col 49}Number of obs{col 67}= {res} 2,750 {txt}{col 49}Replications{col 67}= {res} 1,000 {p2colset 7 17 21 2}{...} {txt}{p2col :command:}mediate bmi, outcome(lncr) mediator(lntg) covars(age i.raceth educ i.drinkamt lessactive) {p_end} {p2colset 12 17 21 2}{...} {p2col :pe:}{res:r(pe)}{p_end} {com}. estat bootstrap, all {txt}Bootstrap results{col 49}Number of obs{col 67}= {res} 2,750 {txt}{col 49}Replications{col 67}= {res} 1000 {p2colset 7 17 21 2}{...} {txt}{p2col :command:}mediate bmi, outcome(lncr) mediator(lntg) covars(age i.raceth educ i.drinkamt lessactive) {p_end} {p2colset 12 17 21 2}{...} {p2col :pe:}{res:r(pe)}{p_end} {res}{col 1}{text}{hline 13}{c TT}{hline 12}{hline 11}{hline 13}{hline 12}{hline 10}{hline 6} {col 14}{text}{c |} Observed{col 38} Bootstrap {res}{col 14}{text}{c |} Coef.{col 27} Bias{col 38} Std. Err.{col 51} [95% Conf. Interval] {res}{col 1}{text}{hline 13}{c +}{hline 12}{hline 11}{hline 13}{hline 12}{hline 10}{hline 6} {col 1}{text} pe{col 14}{c |}{result}{space 2} 44.316268{col 27}{space 2} 241.4377{col 38}{space 2} 6504.7125{col 51}{space 2}-12704.69{col 63}{space 1} 12793.32{col 73}{text} (N) {res}{col 14}{text}{c |}{col 51}{result}{space 2} 15.61846{col 63}{space 1} 264.6381{col 73}{text} (P) {res}{col 14}{text}{c |}{col 51}{result}{space 2} 17.08607{col 63}{space 1} 466.0168{col 73}{text} (BC) {res}{col 1}{text}{hline 13}{c BT}{hline 12}{hline 11}{hline 13}{hline 12}{hline 10}{hline 6} {col 0}(N){col 8}normal confidence interval {col 0}(P){col 8}percentile confidence interval {col 0}(BC){col 8}bias-corrected confidence interval {res}{txt} {com}. . * Optional: estimates using medeff package . foreach x in raceth drinkamt {c -(} {txt} 2{com}. qui tab `x', gen(`x'_) {txt} 3{com}. drop `x'_1 {txt} 4{com}. {c )-} {txt} {com}. medeff (regress lntg bmi age raceth_* educ drinkamt_* lessact) /// // model 1 > (regress lncr bmi age raceth_* educ drinkamt_* lessact lntg), /// // model 3 > mediate(lntg) treat(bmi) sims(2000) Using 0 and 1 as treatment values {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(8, 2741) = {res} 28.21 {txt} Model {c |} {res} 33.6979045 8 4.21223807 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 409.325519 2,741 .149334374 {txt}R-squared ={res} 0.0761 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0734 {txt} Total {c |} {res} 443.023423 2,749 .161158029 {txt}Root MSE = {res} .38644 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lntg{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}bmi {c |}{col 14}{res}{space 2} .0134878{col 26}{space 2} .0013932{col 37}{space 1} 9.68{col 46}{space 3}0.000{col 54}{space 4} .0107559{col 67}{space 3} .0162196 {txt}{space 9}age {c |}{col 14}{res}{space 2} .0008696{col 26}{space 2} .0011388{col 37}{space 1} 0.76{col 46}{space 3}0.445{col 54}{space 4}-.0013635{col 67}{space 3} .0031026 {txt}{space 4}raceth_2 {c |}{col 14}{res}{space 2}-.2579085{col 26}{space 2} .0280238{col 37}{space 1} -9.20{col 46}{space 3}0.000{col 54}{space 4}-.3128584{col 67}{space 3}-.2029586 {txt}{space 4}raceth_3 {c |}{col 14}{res}{space 2} .1219685{col 26}{space 2} .0413709{col 37}{space 1} 2.95{col 46}{space 3}0.003{col 54}{space 4} .0408471{col 67}{space 3} .2030899 {txt}{space 5}educyrs {c |}{col 14}{res}{space 2}-.0059608{col 26}{space 2} .0029023{col 37}{space 1} -2.05{col 46}{space 3}0.040{col 54}{space 4}-.0116517{col 67}{space 3}-.0002699 {txt}{space 2}drinkamt_2 {c |}{col 14}{res}{space 2}-.0516891{col 26}{space 2} .0170183{col 37}{space 1} -3.04{col 46}{space 3}0.002{col 54}{space 4}-.0850591{col 67}{space 3}-.0183192 {txt}{space 2}drinkamt_3 {c |}{col 14}{res}{space 2}-.1061394{col 26}{space 2} .0260528{col 37}{space 1} -4.07{col 46}{space 3}0.000{col 54}{space 4}-.1572245{col 67}{space 3}-.0550542 {txt}{space 2}lessactive {c |}{col 14}{res}{space 2} .0322336{col 26}{space 2} .0175519{col 37}{space 1} 1.84{col 46}{space 3}0.066{col 54}{space 4}-.0021827{col 67}{space 3} .06665 {txt}{space 7}_cons {c |}{col 14}{res}{space 2} 4.702106{col 26}{space 2} .0987119{col 37}{space 1} 47.63{col 46}{space 3}0.000{col 54}{space 4} 4.508549{col 67}{space 3} 4.895663 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res} {txt} Source {c |} SS df MS Number of obs ={res} 2,750 {txt}{hline 13}{c +}{hline 34} F(9, 2740) = {res} 29.05 {txt} Model {c |} {res} 10.7976826 9 1.19974251 {txt}Prob > F ={res} 0.0000 {txt} Residual {c |} {res} 113.167246 2,740 .041301915 {txt}R-squared ={res} 0.0871 {txt}{hline 13}{c +}{hline 34} Adj R-squared ={res} 0.0841 {txt} Total {c |} {res} 123.964929 2,749 .045094554 {txt}Root MSE = {res} .20323 {txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {col 1} lncreat{col 14}{c |} Coef.{col 26} Std. Err.{col 38} t{col 46} P>|t|{col 54} [95% Con{col 67}f. Interval] {hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {space 9}bmi {c |}{col 14}{res}{space 2} .0008547{col 26}{space 2} .0007451{col 37}{space 1} 1.15{col 46}{space 3}0.251{col 54}{space 4}-.0006063{col 67}{space 3} .0023158 {txt}{space 8}lntg {c |}{col 14}{res}{space 2} .0504343{col 26}{space 2} .010045{col 37}{space 1} 5.02{col 46}{space 3}0.000{col 54}{space 4} .0307378{col 67}{space 3} .0701309 {txt}{space 9}age {c |}{col 14}{res}{space 2} .0066098{col 26}{space 2} .000599{col 37}{space 1} 11.04{col 46}{space 3}0.000{col 54}{space 4} .0054353{col 67}{space 3} .0077843 {txt}{space 4}raceth_2 {c |}{col 14}{res}{space 2} .1157342{col 26}{space 2} .0149638{col 37}{space 1} 7.73{col 46}{space 3}0.000{col 54}{space 4} .0863928{col 67}{space 3} .1450756 {txt}{space 4}raceth_3 {c |}{col 14}{res}{space 2}-.0397543{col 26}{space 2} .0217916{col 37}{space 1} -1.82{col 46}{space 3}0.068{col 54}{space 4}-.0824838{col 67}{space 3} .0029753 {txt}{space 5}educyrs {c |}{col 14}{res}{space 2}-.0018997{col 26}{space 2} .0015275{col 37}{space 1} -1.24{col 46}{space 3}0.214{col 54}{space 4}-.0048948{col 67}{space 3} .0010955 {txt}{space 2}drinkamt_2 {c |}{col 14}{res}{space 2}-.0050839{col 26}{space 2} .008965{col 37}{space 1} -0.57{col 46}{space 3}0.571{col 54}{space 4}-.0226627{col 67}{space 3} .012495 {txt}{space 2}drinkamt_3 {c |}{col 14}{res}{space 2}-.0324404{col 26}{space 2} .0137427{col 37}{space 1} -2.36{col 46}{space 3}0.018{col 54}{space 4}-.0593874{col 67}{space 3}-.0054933 {txt}{space 2}lessactive {c |}{col 14}{res}{space 2} .0581175{col 26}{space 2} .0092363{col 37}{space 1} 6.29{col 46}{space 3}0.000{col 54}{space 4} .0400067{col 67}{space 3} .0762282 {txt}{space 7}_cons {c |}{col 14}{res}{space 2}-.6590229{col 26}{space 2} .0701846{col 37}{space 1} -9.39{col 46}{space 3}0.000{col 54}{space 4}-.7966429{col 67}{space 3}-.5214029 {txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12} {res}{txt}(750 missing values generated) (750 missing values generated) (750 missing values generated) {hline 31}{c TT}{hline 52} Effect {c |} Mean [95% Conf. Interval] {hline 31}{c +}{hline 52} {res} ACME {c |} .0006761 .0003914 .0009831 Direct Effect {c |} .000854 -.0005953 .0023025 Total Effect {c |} .0015302 .0001306 .0029774 % of Tot Eff mediated {c |} .4302801 .2122807 2.334602 {txt}{hline 31}{c BT}{hline 52} {com}. . log close {txt}name: {res} {txt}log: {res}/Users/steve/Dropbox/work/teaching/biostat208/labs/lab4/lab4.smcl {txt}log type: {res}smcl {txt}closed on: {res}25 Jan 2021, 08:31:33 {txt}{.-} {smcl} {txt}{sf}{ul off}