Here's what I did:
Within Stata, I used the runmlwin command to run a series of multilevel models using nested loops. I started with MQL1 estimation, then PQL2, and used the PQL2 estimates as inputs for the MCMC model. After each MCMC model was run, I used Stata’s ‘estimates store’ command to store the model estimates:
Code: Select all
foreach y of varlist EX IN CO {
foreach x of varlist pos4 pos8 {
forvalues i = 1/8 {
runmlwin `y' cons i.`x' gender01 i.langcat atsi specialneeds i.m_educat3 if capcity==`i', ///
level2(sa1_maincode_2016:cons) ///
level1(record_id) discrete(distribution(binomial) link(logit) denom(cons) ///
mql1) igls nopause or mlwinpath("C:\Program Files\MLwiN v3.04\mlwin.exe")
runmlwin `y' cons i.`x' gender01 i.langcat atsi specialneeds i.m_educat3 if capcity==`i', ///
level2(sa1_maincode_2016:cons) ///
level1(record_id) discrete(distribution(binomial) link(logit) denom(cons) ///
pql2) initsprevious igls nopause or mlwinpath("C:\Program Files\MLwiN v3.04\mlwin.exe")
runmlwin `y' cons i.`x' gender01 i.langcat atsi specialneeds i.m_educat3 if capcity==`i', ///
level2(sa1_maincode_2016:cons) ///
level1(record_id) discrete(distribution(binomial) link(logit) denom(cons)) ///
mcmc(chain(20000)) initsprevious igls nopause or mlwinpath("C:\Program Files\MLwiN v3.04\mlwin.exe")
estimates store Ch_`x'_`y'_`i'
mcmcsum, detail
mcmcsum, trajectories
graph export Ch_`x'_`y'_`i'.png, as(png) replace
}
}
}
Code: Select all
foreach y of varlist EX IN CO {
foreach x of varlist pos4 pos8 {
forvalues i = 1/8 {
estimates restore Ch_`x'_`y'_`i'
estimates save Ch_`x'_`y'_`i', replace
}
}
}
estimates clear
Code: Select all
estimates use Ch_pos8_EX_3
estimates store Ch_pos8_EX_3
estimates restore Ch_pos8_EX_3
estimates replay
Code: Select all
ereturn display, eform(_2_pos8 _3_pos8)
Is this the proper way to go about saving the results from an MCMC model executed using runmlwin, so that I can retrieve them in later Stata sessions (or, is there another way to do this)? Have I missed something important about how MCMC estimates retrieved by runmlwin need to be saved?
Thanks very much for your advice, it is much appreciated.
Amanda