------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\25_Hierarch > ical_Centring.smcl log type: smcl opened on: 27 Mar 2020, 18:19:14 . **************************************************************************** . * MLwiN MCMC Manual . * . * 25 Hierarchical Centring . . . . . . . . . . . . . . . . . . . . . . .401 . * . * 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/ . **************************************************************************** . . * 25.1 What is hierarchical centering? . . . . . . . . . . . . . . . . . 401 . . * 25.2 Centring Normal models using WinBUGS . . . . . . . . . . . . . . .403 . . 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.55 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 ------------------------------------------------------------------------------ . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(hcen(2) savewinbugs( /// > model("m.txt", replace) /// > inits("i.txt", replace) /// > data("d.txt", replace) /// > )) 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) = 2.49 Deviance (dbar) = 9209.11 Deviance (thetabar) = 9149.12 Effective no. of pars (pd) = 59.99 Bayesian DIC = 9269.09 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .00234 .0404096 4763 0.486 -.077548 .0805077 standlrt | .5634167 .0124695 4155 0.000 .5387731 .5881572 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0970734 .0198435 3292 .0647191 .1421221 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5661784 .0124846 5056 .5422037 .5909002 ------------------------------------------------------------------------------ . . . . * 25.3 Binomial hierarchical centering algorithm . . . . . . . . . . . . 408 . . * 25.4 Binomial example in practice . . . . . . . . . . . . . . . . . . .410 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/bang1.dta", clear . . gen onekid = (lc==1) . . gen twokids = (lc==2) . . gen threepluskids = (lc==3) . . runmlwin use cons age onekid twokids threepluskids urban, /// > level2(district: cons urban) /// > level1(woman:) /// > discrete(distribution(binomial) link(logit) denom(denomb)) nopause MLwiN 3.05 multilevel model Number of obs = 1934 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ district | 60 2 32.2 118 ----------------------------------------------------------- Run time (seconds) = 0.59 Number of iterations = 6 ------------------------------------------------------------------------------ use | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -1.588613 .1504406 -10.56 0.000 -1.883471 -1.293755 age | -.0245528 .0076899 -3.19 0.001 -.0396248 -.0094809 onekid | 1.058287 .154513 6.85 0.000 .7554469 1.361127 twokids | 1.267062 .1702631 7.44 0.000 .9333524 1.600772 threeplusk~s | 1.261499 .1748145 7.22 0.000 .9188685 1.604129 urban | .7535827 .1596888 4.72 0.000 .4405985 1.066567 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: district | var(cons) | .3227052 .1006486 .1254376 .5199728 cov(cons,urban) | -.3384171 .1384327 -.6097402 -.067094 var(urban) | .5638111 .2495843 .0746349 1.052987 ------------------------------------------------------------------------------ . . matrix b = e(b) . . matrix V = e(V) . . runmlwin use cons age onekid twokids threepluskids urban, /// > level2(district: cons urban) /// > level1(woman:) /// > discrete(distribution(binomial) link(logit) denom(denomb)) /// > mcmc(hcen(2) seed(1)) initsb(b) initsv(V) nopause MLwiN 3.05 multilevel model Number of obs = 1934 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ district | 60 2 32.2 118 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 6.62 Deviance (dbar) = 2329.54 Deviance (thetabar) = 2272.87 Effective no. of pars (pd) = 56.67 Bayesian DIC = 2386.21 ------------------------------------------------------------------------------ use | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -1.729273 .1610972 73 0.000 -2.043586 -1.409182 age | -.0269652 .0077628 210 0.000 -.0414718 -.0117237 onekid | 1.145302 .164188 128 0.000 .8073729 1.469217 twokids | 1.374303 .171396 121 0.000 1.032786 1.702875 threeplusk~s | 1.375463 .1819382 71 0.000 1.000407 1.723951 urban | .8153156 .1750221 280 0.000 .4827751 1.162113 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: district | var(cons) | .4199909 .1336713 272 .2132961 .7311914 cov(cons,urban) | -.433723 .1712022 156 -.8186344 -.160567 var(urban) | .7315171 .302971 138 .2698202 1.426537 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . runmlwin use cons age onekid twokids threepluskids urban, /// > level2(district: cons urban) /// > level1(woman:) /// > discrete(distribution(binomial) link(logit) denom(denomb)) /// > mcmc(orth hcen(2) seed(1)) initsb(b) initsv(V) nopause MLwiN 3.05 multilevel model Number of obs = 1934 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ district | 60 2 32.2 118 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 8.03 Deviance (dbar) = 2328.88 Deviance (thetabar) = 2271.36 Effective no. of pars (pd) = 57.52 Bayesian DIC = 2386.40 ------------------------------------------------------------------------------ use | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -1.732559 .1665884 427 0.000 -2.075239 -1.414301 age | -.0270358 .0080282 1054 0.000 -.0422706 -.01131 onekid | 1.142796 .1601106 1039 0.000 .8383517 1.464134 twokids | 1.372206 .177129 1024 0.000 1.026537 1.739403 threeplusk~s | 1.372404 .1822787 1135 0.000 1.019997 1.740626 urban | .8292014 .1788179 149 0.000 .4893562 1.194032 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: district | var(cons) | .4325854 .1448904 193 .2169633 .7838718 cov(cons,urban) | -.4497919 .1855826 128 -.8868291 -.173796 var(urban) | .7566416 .3245115 121 .2898034 1.530352 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . . . * 25.5 The Melanoma example . . . . . . . . . . . . . . . . . . . . . . .414 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/mmmec1.dta", clear . . generate logexp = ln(exp) . . tabulate nation nation | Freq. Percent Cum. ------------+----------------------------------- 1 | 11 3.11 3.11 2 | 30 8.47 11.58 3 | 14 3.95 15.54 4 | 94 26.55 42.09 5 | 70 19.77 61.86 6 | 95 26.84 88.70 7 | 26 7.34 96.05 8 | 3 0.85 96.89 9 | 11 3.11 100.00 ------------+----------------------------------- Total | 354 100.00 . . generate belgium = (nation==1) . . generate wgermany = (nation==2) . . generate denmark = (nation==3) . . generate france = (nation==4) . . generate uk = (nation==5) . . generate italy = (nation==6) . . generate ireland = (nation==7) . . generate luxembourg = (nation==8) . . generate netherlands = (nation==9) . . foreach var of varlist belgium-netherlands { 2. . generate `var'Xuvbi = `var'*uvbi 3. . } . . quietly runmlwin obs belgium-netherlands belgiumXuvbi-netherlandsXuvbi, /// > level2(region: cons) /// > level1(county:) /// > discrete(distribution(poisson) offset(logexp)) nopause . . matrix b = e(b) . . matrix V = e(V) . . runmlwin obs belgium-netherlands belgiumXuvbi-netherlandsXuvbi, /// > level2(region: cons) /// > level1(county:) /// > discrete(distribution(poisson) offset(logexp)) /// > mcmc(chain(50000) hcen(2) seed(1)) initsb(b) initsv(V) nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ region | 78 1 4.5 13 ----------------------------------------------------------- Burnin = 500 Chain = 50000 Thinning = 1 Run time (seconds) = 23 Deviance (dbar) = 2029.27 Deviance (thetabar) = 1967.33 Effective no. of pars (pd) = 61.94 Bayesian DIC = 2091.22 ------------------------------------------------------------------------------ obs | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- belgium | .6344551 .8086144 35 0.211 -1.067865 2.107082 wgermany | .4685593 .1288986 232 0.000 .222529 .7273262 denmark | .1541567 .8071914 31 0.439 -1.292867 1.67495 france | -.5928513 .0551532 7342 0.000 -.701494 -.4858677 uk | .6189206 .2094821 76 0.000 .2598655 1.097101 italy | .2824637 .1041681 471 0.003 .0793841 .4848699 ireland | -.6366052 1.064506 49 0.282 -2.784577 1.301226 luxembourg | -5.512701 5.38529 30 0.152 -14.28981 7.948633 netherlands | -.3433798 .8174411 34 0.376 -2.070648 1.079362 belgiumXuvbi | .2417766 .2729565 35 0.188 -.3355824 .7408125 wgermanyXu~i | -.0166465 .0349852 181 0.317 -.0844576 .0537408 denmarkXuvbi | -.1117068 .1422447 30 0.246 -.3684851 .1555855 franceXuvbi | .0127139 .0182538 1704 0.248 -.0224746 .0489742 ukXuvbi | .1428447 .043206 69 0.000 .070917 .2431493 italyXuvbi | -.0874236 .0156754 402 0.000 -.1182812 -.0576964 irelandXuvbi | -.0217733 .2140812 50 0.480 -.4532746 .3685868 luxembourg~i | -2.395931 2.338974 30 0.152 -6.20565 3.488969 netherland~i | -.1121418 .1955258 33 0.310 -.5298594 .224013 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .036632 .0091533 6046 .0220665 .0576786 ------------------------------------------------------------------------------ . . mcmcsum [FP1]belgium, detail [FP1]belgium ------------------------------------------------------------------------------ Percentiles Mean .6344551 0.5% -1.443225 Thinned Chain Length 50000 MCSE of Mean .0372374 2.5% -1.067865 Effective Sample Size 35 Std. Dev. .8086144 5% -.8410825 Raftery Lewis (2.5%) 30349 Mode .7608854 25% .1234688 Raftery Lewis (97.5%) 26212 P(mean) 0.211 Brooks Draper (mean) 1.07e+07 P(mode) 0.211 50% .6914034 P(median) 0.211 75% 1.198814 95% 1.901319 97.5% 2.107082 99.5% 2.449369 ------------------------------------------------------------------------------ . . runmlwin obs belgium-netherlands belgiumXuvbi-netherlandsXuvbi, /// > level2(region: cons) /// > level1(county:) /// > discrete(distribution(poisson) offset(logexp)) /// > mcmc(chain(50000) orth hcen(2) seed(1)) initsb(b) initsv(V) nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ region | 78 1 4.5 13 ----------------------------------------------------------- Burnin = 500 Chain = 50000 Thinning = 1 Run time (seconds) = 23 Deviance (dbar) = 2028.35 Deviance (thetabar) = 1965.03 Effective no. of pars (pd) = 63.32 Bayesian DIC = 2091.67 ------------------------------------------------------------------------------ obs | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- belgium | .6963412 .7447422 5554 0.174 -.7442576 2.183346 wgermany | .4763741 .1234807 1603 0.000 .2331022 .7186109 denmark | .3108411 .8714214 5831 0.359 -1.378257 2.016197 france | -.5942674 .0546849 12338 0.000 -.7015169 -.4868215 uk | .6034939 .2062884 1165 0.001 .2061065 1.014925 italy | .2813497 .1042834 2290 0.004 .0730488 .4831597 ireland | -.4876346 1.299768 6815 0.352 -3.029335 2.061627 luxembourg | 17.31496 16.00512 1614 0.132 -11.27219 51.23437 netherlands | -.3663473 .9448242 2358 0.349 -2.253864 1.464567 belgiumXuvbi | .2629637 .2509026 5516 0.146 -.2224142 .7688527 wgermanyXu~i | -.0142658 .0330603 1199 0.333 -.08011 .0496555 denmarkXuvbi | -.0838312 .1537606 5617 0.291 -.380418 .2170434 franceXuvbi | .0136253 .0180097 1934 0.227 -.0210113 .0496735 ukXuvbi | .1396867 .0424692 1049 0.000 .0581191 .2243297 italyXuvbi | -.0870459 .0157133 1652 0.000 -.1174557 -.0558679 irelandXuvbi | .0092 .2630139 6024 0.487 -.4989054 .529943 luxembourg~i | 7.554192 6.987538 1583 0.132 -4.862838 22.3914 netherland~i | -.1176386 .2267886 2315 0.301 -.5705932 .3222391 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .0369009 .0091723 6703 .0222543 .0578925 ------------------------------------------------------------------------------ . . mcmcsum [FP1]belgium, detail [FP1]belgium ------------------------------------------------------------------------------ Percentiles Mean .6963412 0.5% -1.17078 Thinned Chain Length 50000 MCSE of Mean .0091278 2.5% -.7442576 Effective Sample Size 5554 Std. Dev. .7447422 5% -.524561 Raftery Lewis (2.5%) 12144 Mode .6815762 25% .1853247 Raftery Lewis (97.5%) 11740 P(mean) 0.174 Brooks Draper (mean) 640120 P(mode) 0.174 50% .6916292 P(median) 0.174 75% 1.19587 95% 1.935145 97.5% 2.183346 99.5% 2.653359 ------------------------------------------------------------------------------ . . . . * 25.6 Normal response models in MLwiN . . . . . . . . . . . . . . . . . 419 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . 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(femethod(univariatemh) remethod(univariatemh) hcen(2) seed(1)) i > nitsb(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) = 1.81 Deviance (dbar) = 9209.49 Deviance (thetabar) = 9149.35 Effective no. of pars (pd) = 60.13 Bayesian DIC = 9269.62 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0035657 .0405962 3203 0.465 -.0748694 .0843925 standlrt | .5636642 .0122516 1149 0.000 .5395894 .5873429 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .096001 .0198858 2098 .0635012 .1406532 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5661922 .0126051 4275 .5422698 .591421 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . runmlwin normexam cons standlrt, /// > level2(school: cons) /// > level1(student: cons) /// > mcmc(hcen(2) seed(1)) 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.53 Deviance (dbar) = 9209.11 Deviance (thetabar) = 9149.12 Effective no. of pars (pd) = 59.99 Bayesian DIC = 9269.09 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .00234 .0404096 4763 0.486 -.077548 .0805077 standlrt | .5634167 .0124695 4155 0.000 .5387731 .5881572 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0970734 .0198435 3292 .0647191 .1421221 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5661784 .0124846 5056 .5422037 .5909002 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . .422 . . . . . . **************************************************************************** . exit end of do-file