* Adjusted predictions & Marginal effects for multiple outcome variables * Requires Stata 14+ and Spost13 suite of commands webuse nhanes2f, clear keep if !missing(diabetes, black, female, age) // Note: In later versions of Stata, some of these labels // are already defined. When that is so, the capture // prefix keeps the program from aborting with an error capture label define black 0 "nonBlack" 1 "black" capture label define female 0 "male" 1 "female" capture label values black black capture label values female female fre health ologit health i.female i.black c.age, nolog * AAPs using margins margins black *spost13 mtable, at(black = (0 1)) * AMEs using margins margins, dydx(black) mtable, dydx(black) * mtable mtable, at (black = (0 1) age = 20 ) at (black = (0 1) age = 47 ) at (black = (0 1) age = 74 ) dec(4) quietly mtable, at (black = 0 age = 20 ) rown(20 year old white) dec(4) quietly mtable, at (black = 1 age = 20 ) rown(20 year old black) dec(4) below quietly mtable, at (black = 0 age = 47 ) rown(47 year old white) dec(4) below quietly mtable, at (black = 1 age = 47 ) rown(47 year old black) dec(4) below quietly mtable, at (black = 0 age = 74 ) rown(74 year old white) dec(4) below mtable, at (black = 1 age = 74 ) rown(74 year old black) dec(4) below * Graphics using mgen * mgen for all all groups pooled together mgen, at(age = (20(5)75)) stub(all) list allpr1 allpr2 allpr3 allpr4 allpr5 allage in 1/15 sum allpr1 allpr2 allpr3 allpr4 allpr5 allage line allpr1 allpr2 allpr3 allpr4 allpr5 allage, scheme(sj) name(pooled) * mgen for groups drop allpr1 - allCpr5 mgen, at(age = (20(5)75) black = 0) stub(wh) predn(whpr) mgen, at(age = (20(5)75) black = 1) stub(bl) predn(blpr) line whwhpr1 blblpr1 whwhpr5 blblpr5 whage, scheme(sj) name(byrace) * mchange mchange black female age, stats(change start end) dec(5) delta(10) * Appendix A: Adjusted predictions & Marginal effects * For those condemned to using Stata 13 version 13.1 webuse nhanes2f, clear keep if !missing(diabetes, black, female, age) // Note: In later versions of Stata, some of these labels // are already defined. When that is so, the capture // prefix keeps the program from aborting with an error capture label define black 0 "nonBlack" 1 "black" capture label define female 0 "male" 1 "female" capture label values black black capture label values female female fre health ologit health i.female i.black c.age, nolog * AAPs using margins margins black, predict(outcome(#1)) margins black, predict(outcome(#2)) margins black, predict(outcome(#3)) margins black, predict(outcome(#4)) margins black, predict(outcome(#5)) * AMEs using margins margins r.black, predict(outcome(#1)) margins r.black, predict(outcome(#2)) margins r.black, predict(outcome(#3)) margins r.black, predict(outcome(#4)) margins r.black, predict(outcome(#5))