Hi all,
I am trying to use marginsplots to graph a categorical by categorical variable interaction between gender (0 1) and level of drug use (0 1 2) for a logit model predicting lifetime sexual partners using multiply imputed data. I used the code from the ATS UCLA website as a template (
http://www.ats.ucla.edu/stat/stata/f...arginsplot.htm). However, I'm getting an error when I run it and still being rather new to STATA, I could use some help getting it to run. Here is the output with the error:
program emargins, eclass properties(mi)
version 12
args outcome
logit sexpartner_life i.user female borninus pared age condom drug_sex
margins, at(female=(0 1) user=(0 1 2) atmeans asbalanced ///
post predict(outcome(`outcome'))
end
program myret, rclass
return add
return matrix b = b
return matrix V= V
end
mi estimate, or: logit sexpartner_life i.user female borninus pared age condom drug_sex probuser##female
forvalues i=1/3 {
mi estimate, cmdok: emargins `i'
mat b= e(b_mi)
mat V = e(V_mi)
quietly logit sexpartner_life i.user female borninus pared age condom drug_sex probuser##female if _mi_m == 0
quietly margins, at(female=(0 1) user=(0 1 2)) ///
atmeans asbalanced predict(outcome(`i'))
myret
mata: st_global("e(cmd)", "margins")
marginsplot, x(user) recast(scatter) name(logit`i', replace)
}
an error occurred when mi estimate executed emargins on m=1
r(111);
Any help would be greatly appreciated. Please let me know if more information is needed.
Thanks, O