------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\5_Prior_Dis > tributions,_Starting_Values_and_Random_Number_Seeds.smcl log type: smcl opened on: 27 Mar 2020, 17:45:37 . **************************************************************************** . * MLwiN MCMC Manual . * . * 5 Prior Distributions, Starting Values and Random Number Seeds . . . .61 . * . * 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/ . **************************************************************************** . . * 5.1 Prior distributions . . . . . . . . . . . . . . . . . . . . . . . . 61 . . * 5.2 Uniform on variance scale priors . . . . . . . . . . . . . . . . . .61 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Run time (seconds) = 0.60 Number of iterations = 4 Log likelihood = -4678.6211 Deviance = 9357.2423 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .0023908 .0400224 0.06 0.952 -.0760516 .0808332 standlrt | .5633712 .0124654 45.19 0.000 .5389395 .5878029 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0921275 .0181475 .0565591 .127696 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .565731 .0126585 .5409208 .5905412 ------------------------------------------------------------------------------ . . estimates store IGLS . . matrix b = e(b) . . matrix V = e(V) . . runmlwin normexam cons standlrt, /// > 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.41 Deviance (dbar) = 9208.82 Deviance (thetabar) = 9148.97 Effective no. of pars (pd) = 59.85 Bayesian DIC = 9268.66 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0013325 .0421552 231 0.498 -.0776169 .0851904 standlrt | .5633124 .0125354 3916 0.000 .5389242 .5879933 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0973183 .02049 2828 .064413 .1445396 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .566342 .0126871 4913 .5417516 .5919709 ------------------------------------------------------------------------------ . . estimates store GIBBS1 . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(rppriors(uniform)) 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.39 Deviance (dbar) = 9208.48 Deviance (thetabar) = 9148.47 Effective no. of pars (pd) = 60.01 Bayesian DIC = 9268.48 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0004504 .0421726 266 0.485 -.0787632 .0817816 standlrt | .5630518 .0125104 3801 0.000 .5387774 .5874746 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .1013118 .0215464 2792 .0667105 .15095 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .566524 .0127741 4891 .5419686 .5920795 ------------------------------------------------------------------------------ . . estimates store GIBBS2 . . estimates table IGLS GIBBS1 GIBBS2, b(%4.3f) se -------------------------------------------- Variable | IGLS GIBBS1 GIBBS2 -------------+------------------------------ FP1 | cons | 0.002 0.001 -0.000 | 0.040 0.042 0.042 standlrt | 0.563 0.563 0.563 | 0.012 0.013 0.013 -------------+------------------------------ RP2 | var(cons) | 0.092 0.097 0.101 | 0.018 0.020 0.022 -------------+------------------------------ RP1 | var(cons) | 0.566 0.566 0.567 | 0.013 0.013 0.013 -------------------------------------------- legend: b/se . . . . * 5.3 Using informative priors . . . . . . . . . . . . . . . . . . . . . .62 . . matrix P = (.*b \ .*b) . . matrix rownames P = mean sd . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . . . . sd . . . . . . matrix P[1,2] = 1 . . matrix P[2,2] = .01 . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . 1 . . sd . .01 . . . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(priormatrix(P)) 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.39 Deviance (dbar) = 9693.64 Deviance (thetabar) = 9636.54 Effective no. of pars (pd) = 57.10 Bayesian DIC = 9750.75 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0097079 .0387765 315 0.410 -.0647842 .0868276 standlrt | .8414723 .0083442 3696 0.000 .8252842 .8576113 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0795781 .0174652 2509 .0512773 .1200989 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6382096 .014882 3992 .6090293 .6684919 ------------------------------------------------------------------------------ . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . 1 . . sd . .01 . . . . matrix P[2,2] = .1 . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . 1 . . sd . .1 . . . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(priormatrix(P)) 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.42 Deviance (dbar) = 9209.45 Deviance (thetabar) = 9149.66 Effective no. of pars (pd) = 59.79 Bayesian DIC = 9269.25 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0015361 .0420376 234 0.496 -.0772965 .0851825 standlrt | .5700248 .0124408 3919 0.000 .5458035 .594545 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0967208 .0203797 2822 .0640383 .1437475 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5664306 .0126896 4898 .5417862 .592031 ------------------------------------------------------------------------------ . . . * 5.4 Specifying an informative prior for a random parameter . . . . . . .65 . . matrix P = (.*b \ .*b) . . matrix rownames P = mean sd . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . . . . sd . . . . . . matrix P[1,3] = .2 . . matrix P[2,3] = 100 . . matrix list P P[2,4] FP1: FP1: RP2: RP1: cons standlrt var(cons) var(cons) mean . . .2 . sd . . 100 . . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(priormatrix(P)) 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.42 Deviance (dbar) = 9206.44 Deviance (thetabar) = 9143.89 Effective no. of pars (pd) = 62.55 Bayesian DIC = 9268.99 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0021653 .0484418 144 0.473 -.0962751 .0946439 standlrt | .5617602 .0125239 4726 0.000 .5372732 .5863544 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .1626722 .018899 4179 .1302909 .2038363 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5656533 .0126995 5451 .5407081 .5907444 ------------------------------------------------------------------------------ . . . . * 5.5 Changing the random number seed and the parameter starting values .66 . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Run time (seconds) = 0.57 Number of iterations = 4 Log likelihood = -4678.6211 Deviance = 9357.2423 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .0023908 .0400224 0.06 0.952 -.0760516 .0808332 standlrt | .5633712 .0124654 45.19 0.000 .5389395 .5878029 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0921275 .0181475 .0565591 .127696 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .565731 .0126585 .5409208 .5905412 ------------------------------------------------------------------------------ . . matrix b = e(b) . . matrix V = e(V) . . matrix b[1,1] = -2 . . matrix b[1,2] = 5 . . matrix b[1,3] = 2 . . matrix b[1,4] = 4 . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(burnin(0) chain(500)) 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 = 0 Chain = 500 Thinning = 1 Run time (seconds) = .814 Deviance (dbar) = 9234.78 Deviance (thetabar) = 9157.76 Effective no. of pars (pd) = 77.03 Bayesian DIC = 9311.81 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.3752106 .5795644 3 0.358 -1.689586 .0789063 standlrt | .5630835 .0246992 405 0.000 .5378201 .5882738 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .6100837 .9701435 5 .0695262 3.176698 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6046365 .7863344 412 .5434352 .591656 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Run time (seconds) = 0.78 Number of iterations = 4 Log likelihood = -4678.6211 Deviance = 9357.2423 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .0023908 .0400224 0.06 0.952 -.0760516 .0808332 standlrt | .5633712 .0124654 45.19 0.000 .5389395 .5878029 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0921275 .0181475 .0565591 .127696 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .565731 .0126585 .5409208 .5905412 ------------------------------------------------------------------------------ . . matrix b = e(b) . . matrix V = e(V) . . forvalues s = 1/4 { 2. . quietly runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(seed(`s')) initsb(b) initsv(V) /// > nopause 3. . estimates store seed`s' 4. } . . estimates table seed1 seed2 seed3 seed4, b(%4.3f) ------------------------------------------------------ Variable | seed1 seed2 seed3 seed4 -------------+---------------------------------------- FP1 | cons | 0.001 0.004 0.003 0.008 standlrt | 0.563 0.563 0.563 0.563 -------------+---------------------------------------- RP2 | var(cons) | 0.097 0.097 0.097 0.097 -------------+---------------------------------------- RP1 | var(cons) | 0.566 0.566 0.566 0.566 ------------------------------------------------------ . . . . * 5.6 Improving the speed of MCMC Estimation . . . . . . . . . . . . . . .69 . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . . 70 . . . . . . **************************************************************************** . exit end of do-file