Hi, I am trying to produce marginal effects and predicted probabilities, and marginsplot for multiply imputed data by using the command -mimrgns-; however, from the Stata help file, the degree of freedom by using this command is wrong. I found a website from UCLA showing another way to produce marginal effects and plots for multiply imputed data. See below. Does this method get the correct degree of freedom? Thanks!
https://stats.idre.ucla.edu/stata/fa...-imputed-data/
The website code:
https://stats.idre.ucla.edu/stata/fa...-imputed-data/
The website code:
Code:
set seed 1234543 mi set mlong mi register imputed female math read science socst mi impute mvn female math read science socst = /// ses write awards, add(10) * this is to get the ologit coefficients and standard errors mi estimate: ologit ses female read math * loop once for each of the response values of ses forvalues i=1/3 { mi estimate, cmdok: emargins `i' // emargins is defined above mat b= e(b_mi) // save mi point estimates mat V = e(V_mi) // save mi vce * run ologit and margins on the _mi_m==0 data quietly ologit ses female read math if _mi_m == 0 quietly margins, at(female=(0 1) read=(30(10)70)) /// atmeans asbalanced predict(outcome(`i')) myret // myret is defined above *Technically we ran the program myret between margins and marginsplot. *E(cmd) is the eclass scalar that tells Stata what the previous command was. * So we have to set that to "margins" for marginsplot to work correctly. mata: st_global("e(cmd)", "margins") // set previous cmd to margins marginsplot, x(read) recast(line) noci name(ologit`i', replace)
Comment