------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\21_Using_St > ructured_MCMC.smcl log type: smcl opened on: 27 Mar 2020, 18:11:24 . **************************************************************************** . * MLwiN MCMC Manual . * . * 21 Using Structured MCMC . . . . . . . . . . . . . . . . . . . . . . .327 . * . * Browne, W. J. (2009). MCMC Estimation in MLwiN, v2.26. Centre for . * Multilevel Modelling, University of Bristol. . **************************************************************************** . * Stata do-file to replicate all analyses using runmlwin . * . * George Leckie and Chris Charlton, . * Centre for Multilevel Modelling, 2012 . * http://www.bristol.ac.uk/cmm/software/runmlwin/ . **************************************************************************** . . * 21.1 SMCMC Theory . . . . . . . . . . . . . . . . . . . . . . . . . . .327 . . * 21.2 Fitting the model using MLwiN . . . . . . . . . . . . . . . . . . 330 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . quietly runmlwin normexam cons, /// > level2(school: cons) /// > level1(student: cons) /// > nopause . . matrix b = e(b) . . matrix V = e(V) . . runmlwin normexam cons, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(on) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 2.28 Deviance (dbar) = 10849.61 Deviance (thetabar) = 10789.73 Effective no. of pars (pd) = 59.88 Bayesian DIC = 10909.49 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0147387 .0564972 189 0.386 -.1203866 .0960318 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .1777477 .03642 3121 .119204 .26236 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .8484687 .0189967 4915 .8114711 .8871109 ------------------------------------------------------------------------------ . . mcmcsum [FP1]cons, fiveway . . runmlwin normexam cons, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(smcmc) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 2.28 Deviance (dbar) = 10849.65 Deviance (thetabar) = 10789.84 Effective no. of pars (pd) = 59.81 Bayesian DIC = 10909.45 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0132592 .0550344 4942 0.404 -.1220348 .096936 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .1772026 .0357664 3687 .1191213 .2601493 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .8482025 .0189986 4748 .8112915 .8850089 ------------------------------------------------------------------------------ . . mcmcsum [FP1]cons, fiveway . . . . * 21.3 A random intercepts model . . . . . . . . . . . . . . . . . . . . 334 . . quietly runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > nopause . . matrix b = e(b) . . matrix V = e(V) . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(smcmc) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 2.48 Deviance (dbar) = 9208.86 Deviance (thetabar) = 9149.14 Effective no. of pars (pd) = 59.72 Bayesian DIC = 9268.58 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0034357 .0412205 4875 0.469 -.0788388 .085473 standlrt | .5637347 .0124572 5098 0.000 .5393521 .5881602 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0972182 .0204681 3355 .0639784 .1441007 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5660725 .0126791 4611 .5423679 .5915801 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . . . * 21.4 Examining the residual chains . . . . . . . . . . . . . . . . . . 335 . . runmlwin normexam cons standlrt, /// > level2(school: cons, residuals(u, savechains("schoolresiduals.dta", > replace))) /// > level1(student: cons) /// > mcmc(chain(5001) smcmc) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5001 Thinning = 1 Run time (seconds) = 10.2 Deviance (dbar) = 9208.86 Deviance (thetabar) = 9149.14 Effective no. of pars (pd) = 59.72 Bayesian DIC = 9268.58 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0034208 .0412297 4875 0.470 -.078838 .0854651 standlrt | .5637309 .0124589 5109 0.000 .5393521 .5881585 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0972181 .020466 3356 .0639785 .1441 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .566071 .0126783 4613 .5423689 .5915791 ------------------------------------------------------------------------------ . . use "schoolresiduals.dta", clear . . keep if school==1 (320,064 observations deleted) . . keep iteration value . . mcmcsum value, variables detail value ------------------------------------------------------------------------------ Percentiles Mean .37083 0.5% .141476 Thinned Chain Length 5001 MCSE of Mean .001305 2.5% .190976 Effective Sample Size 5292 Std. Dev. .0927302 5% .2206255 Raftery Lewis (2.5%) 3646 Mode .369697 25% .3094077 Raftery Lewis (97.5%) 3802 P(mean) 0.000 Brooks Draper (mean) 1309 P(mode) 0.000 50% .3695874 P(median) 0.000 75% .4337998 95% .5207887 97.5% .5545473 99.5% .6137123 ------------------------------------------------------------------------------ . . mcmcsum value, variables fiveway . . . . * 21.5 Random slopes model theory . . . . . . . . . . . . . . . . . . . .336 . . * 21.6 Random Slopes model practice . . . . . . . . . . . . . . . . . . .338 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . quietly runmlwin normexam cons standlrt, /// > level2(school: cons standlrt) /// > level1(student: cons) /// > nopause . . runmlwin normexam cons standlrt, /// > level2(school: cons standlrt) /// > level1(student: cons) /// > mcmc(smcmc) initsprevious /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 6.16 Deviance (dbar) = 9122.70 Deviance (thetabar) = 9031.14 Effective no. of pars (pd) = 91.56 Bayesian DIC = 9214.26 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0110827 .0404524 5042 0.388 -.0912834 .0695935 standlrt | .5576264 .0203656 5112 0.000 .5174344 .5974464 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0971079 .0200746 3169 .065167 .1437884 cov(cons,standlrt) | .0195137 .0073951 1724 .006435 .035969 var(standlrt) | .0154854 .0048556 1053 .0079104 .0269458 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5543224 .0124705 4701 .5302392 .5795404 ------------------------------------------------------------------------------ . . . mcmcsum [FP1]cons, fiveway . . mcmcsum [FP1]standlrt, fiveway . . . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . .340 . . . . . . **************************************************************************** . exit end of do-file