------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\24_Paramete > r_expansion.smcl log type: smcl opened on: 27 Mar 2020, 18:18:09 . **************************************************************************** . * MLwiN MCMC Manual . * . * 24 Parameter expansion . . . . . . . . . . . . . . . . . . . . . . . .381 . * . * 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/ . **************************************************************************** . . * 24.1 What is Parameter Expansion? . . . . . . . . . . . . . . . . . . .381 . . * 24.2 The tutorial example . . . . . . . . . . . . . . . . . . . . . . .383 . . 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.66 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) . . 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.44 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 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), detail [RP2]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .0973183 0.5% .057521 Thinned Chain Length 5000 MCSE of Mean .0003753 2.5% .064413 Effective Sample Size 2828 Std. Dev. .02049 5% .0688548 Raftery Lewis (2.5%) 4484 Mode .0917529 25% .0827398 Raftery Lewis (97.5%) 4129 P(mean) 0.000 Brooks Draper (mean) 10819 P(mode) 0.000 50% .0948958 P(median) 0.000 75% .1092218 95% .1347807 97.5% .1445396 99.5% .1651094 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), fiveway . . runmlwin normexam cons standlrt, /// > level2(school: cons, parexpansion) /// > 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.83 Deviance (dbar) = 9209.02 Deviance (thetabar) = 9148.93 Effective no. of pars (pd) = 60.08 Bayesian DIC = 9269.10 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .0032266 .0445792 219 0.472 -.0840121 .0931738 standlrt | .5630447 .0125101 4265 0.000 .5386873 .5868415 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0983274 .0203845 2985 .0648942 .1446498 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .566165 .0124882 5073 .5420677 .5909941 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), detail [RP2]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .0983274 0.5% .0577928 Thinned Chain Length 5000 MCSE of Mean .0003566 2.5% .0648942 Effective Sample Size 2985 Std. Dev. .0203845 5% .0691974 Raftery Lewis (2.5%) 3930 Mode .0930428 25% .0842184 Raftery Lewis (97.5%) 3803 P(mean) 0.000 Brooks Draper (mean) 9771 P(mode) 0.000 50% .0958057 P(median) 0.000 75% .1099665 95% .1360231 97.5% .1446498 99.5% .1630111 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), fiveway . . . . * 24.3 Binary responses - Voting example . . . . . . . . . . . . . . . . 386 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/bes83.dta", clear . . runmlwin votecons cons defence unemp taxes privat, /// > level2(area: cons) /// > level1(voter:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > nopause MLwiN 3.05 multilevel model Number of obs = 800 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ area | 110 1 7.3 16 ----------------------------------------------------------- Run time (seconds) = 0.66 Number of iterations = 6 ------------------------------------------------------------------------------ votecons | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.3552158 .0917617 -3.87 0.000 -.5350656 -.1753661 defence | .0893889 .0181955 4.91 0.000 .0537263 .1250515 unemp | .067076 .0134056 5.00 0.000 .0408016 .0933504 taxes | .0445018 .0191789 2.32 0.020 .0069118 .0820918 privat | .1382851 .0176275 7.84 0.000 .1037358 .1728345 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: area | var(cons) | .1323441 .111845 -.0868681 .3515564 ------------------------------------------------------------------------------ . . matrix b = e(b) . . matrix V = e(V) . . runmlwin votecons cons defence unemp taxes privat, /// > level2(area: cons) /// > level1(voter:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > mcmc(on) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 800 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ area | 110 1 7.3 16 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 4.53 Deviance (dbar) = 867.39 Deviance (thetabar) = 845.74 Effective no. of pars (pd) = 21.66 Bayesian DIC = 889.05 ------------------------------------------------------------------------------ votecons | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.3654746 .0943153 810 0.000 -.5457957 -.1813685 defence | .0920307 .0185029 968 0.000 .055517 .1285456 unemp | .0696328 .0137619 1014 0.000 .0434006 .0974678 taxes | .0464123 .019693 1039 0.015 .006449 .0837387 privat | .1429049 .0184198 975 0.000 .1060572 .1789377 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: area | var(cons) | .1428529 .1158866 28 .0042903 .4338606 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), detail [RP2]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .1428529 0.5% .0032072 Thinned Chain Length 5000 MCSE of Mean .0102823 2.5% .0042903 Effective Sample Size 28 Std. Dev. .1158866 5% .0057393 Raftery Lewis (2.5%) 89829 Mode 0 25% .0552181 Raftery Lewis (97.5%) 75362 P(mean) 0.000 Brooks Draper (mean) 81229 P(mode) 1.000 50% .1198902 P(median) 0.000 75% .2028327 95% .3740599 97.5% .4338606 99.5% .5677614 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), fiveway . // Note: The ACF appears to decay far less rapidly than in the manual. This . // is simply because the y-axis min in the manual is not zero. . . runmlwin votecons cons defence unemp taxes privat, /// > level2(area: cons, parexpansion) /// > level1(voter:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > mcmc(on) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 800 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ area | 110 1 7.3 16 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 5.82 Deviance (dbar) = 862.89 Deviance (thetabar) = 836.40 Effective no. of pars (pd) = 26.49 Bayesian DIC = 889.38 ------------------------------------------------------------------------------ votecons | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.3739992 .1020522 548 0.000 -.5852809 -.1735945 defence | .0933742 .0191242 1056 0.000 .0560072 .1319248 unemp | .0704762 .0139972 1030 0.000 .0442712 .0988752 taxes | .0452933 .0198114 903 0.010 .0067104 .0852814 privat | .1452582 .0184429 999 0.000 .1084074 .1806551 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: area | var(cons) | .1966972 .1426941 200 .0058794 .5475349 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), detail [RP2]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .1966972 0.5% .0001977 Thinned Chain Length 5000 MCSE of Mean .0074599 2.5% .0058794 Effective Sample Size 200 Std. Dev. .1426941 5% .0153824 Raftery Lewis (2.5%) 42835 Mode .0675364 25% .0904307 Raftery Lewis (97.5%) 21927 P(mean) 0.000 Brooks Draper (mean) 42757 P(mode) 0.000 50% .1764558 P(median) 0.000 75% .2705243 95% .460187 97.5% .547535 99.5% .7254679 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), fiveway . . . . * 24.4 The choice of prior distribution . . . . . . . . . . . . . . . . .390 . . runmlwin votecons cons defence unemp taxes privat, /// > level2(area: cons) /// > level1(voter:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > mcmc(rppriors(uniform)) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 800 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ area | 110 1 7.3 16 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 3.97 Deviance (dbar) = 855.59 Deviance (thetabar) = 822.18 Effective no. of pars (pd) = 33.41 Bayesian DIC = 889.01 ------------------------------------------------------------------------------ votecons | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.380685 .1067521 576 0.000 -.5940461 -.1693329 defence | .094892 .0192105 965 0.000 .0589361 .1336075 unemp | .0706254 .0141228 895 0.000 .0431121 .0991991 taxes | .0464161 .0193412 1178 0.008 .008158 .0847816 privat | .1469198 .018428 1091 0.000 .1104003 .1841221 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: area | var(cons) | .2937165 .16964 63 .0597007 .7216039 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), detail [RP2]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .2937165 0.5% .0390359 Thinned Chain Length 5000 MCSE of Mean .0116117 2.5% .0597007 Effective Sample Size 63 Std. Dev. .16964 5% .0768603 Raftery Lewis (2.5%) 106030 Mode .2310197 25% .1741275 Raftery Lewis (97.5%) 30028 P(mean) 0.000 Brooks Draper (mean) 103590 P(mode) 0.000 50% .2616522 P(median) 0.000 75% .3784746 95% .624557 97.5% .7216039 99.5% .909936 ------------------------------------------------------------------------------ . . mcmcsum [RP2]var(cons), fiveway . . . . * 24.5 Parameter expansion and WinBUGS . . . . . . . . . . . . . . . . . 391 . . runmlwin votecons cons defence unemp taxes privat, /// > level2(area: cons, parexpansion) /// > level1(voter:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > mcmc(savewinbugs( /// > model("votecons_model.txt", replace) /// > inits("votecons_inits.txt", replace) /// > data("votecons_data.txt", replace) /// > )) initsb(b) initsv(V) /// > nopause MLwiN 3.05 multilevel model Number of obs = 800 Binomial logit response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ area | 110 1 7.3 16 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 5.92 Deviance (dbar) = 862.89 Deviance (thetabar) = 836.40 Effective no. of pars (pd) = 26.49 Bayesian DIC = 889.38 ------------------------------------------------------------------------------ votecons | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.3739992 .1020522 548 0.000 -.5852809 -.1735945 defence | .0933742 .0191242 1056 0.000 .0560072 .1319248 unemp | .0704762 .0139972 1030 0.000 .0442712 .0988752 taxes | .0452933 .0198114 903 0.010 .0067104 .0852814 privat | .1452582 .0184429 999 0.000 .1084074 .1806551 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: area | var(cons) | .1966972 .1426941 200 .0058794 .5475349 ------------------------------------------------------------------------------ . . type "votecons_model.txt" # WINBUGS 1.4 code generated from MLwiN program #----MODEL Definition---------------- model { # Level 1 definition for(i in 1:N) { votecons[i] ~ dbin(p[i],denom[i]) logit(p[i]) <- beta[1] * cons[i] + beta[2] * defence[i] + beta[3] * unemp[i] + beta[4] * taxes[i] + beta[5] * privat[i] + alpha2 * u2[area[i]] * cons[i] } # Higher level definitions for (j in 1:n2) { u2[j] ~ dnorm(0,tau.u2) v2[j] <- u2[j]*alpha2 } # Priors for fixed effects for (k in 1:5) { beta[k] ~ dflat() } alpha2 ~ dflat() # Priors for random terms tau.u2 ~ dgamma(0.001,0.001) sigma2.u2 <- 1/tau.u2 sigma2.v2 <- sigma2.u2*alpha2*alpha2 } . . /* There is a known MLwiN bug here which will be fixed in version 2.29 > wbscript, /// > model("`c(pwd)'\votecons_model.txt") /// > data("`c(pwd)'\votecons_data.txt") /// > inits("`c(pwd)'\votecons_inits.txt") /// > log("`c(pwd)'\votecons_log.txt") /// > coda("`c(pwd)'\out") /// > set(beta sigma2.v2 sigma2.u2 alpha2) /// > burn(4000) update(5000) quit /// > saving("`c(pwd)'\votecons_script.txt", replace) > > > wbrun, /// > script("`c(pwd)'\votecons_script.txt") /// > winbugs("C:\WinBUGS14\winbugs14.exe") > > wbcoda, root("`c(pwd)'\out") clear > > mcmcsum alpha2, variables > > mcmcsum alpha2, variables fiveway > > mcmcsum sigma2_v2, variables > > mcmcsum sigma2_v2, variables fiveway > */ . . . * 24.6 Parameter expansion and random slopes . . . . . . . . . . . . . . 396 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . runmlwin normexam cons standlrt, /// > level2(school: cons standlrt) /// > 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.58 Number of iterations = 4 Log likelihood = -4658.435 Deviance = 9316.87 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0115051 .039783 -0.29 0.772 -.0894783 .066468 standlrt | .5567305 .019937 27.92 0.000 .5176547 .5958062 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0904446 .017924 .0553142 .1255749 cov(cons,standlrt) | .0180414 .0067229 .0048649 .031218 var(standlrt) | .0145361 .0044139 .0058851 .0231872 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5536575 .0124818 .5291937 .5781214 ------------------------------------------------------------------------------ . . matrix b = e(b) . . matrix V = e(V) . . runmlwin normexam cons standlrt, /// > level2(school: cons standlrt) /// > 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) = 3.16 Deviance (dbar) = 9122.67 Deviance (thetabar) = 9031.18 Effective no. of pars (pd) = 91.50 Bayesian DIC = 9214.17 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0132462 .0398381 243 0.358 -.0890089 .0733577 standlrt | .5568666 .020332 769 0.000 .515988 .5963049 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0970636 .0200401 2964 .06544 .1425988 cov(cons,standlrt) | .0195519 .0073726 1709 .0064736 .0359522 var(standlrt) | .0154917 .0048418 1029 .0080367 .0268087 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5543189 .0124713 4659 .5302743 .5795808 ------------------------------------------------------------------------------ . . . runmlwin normexam cons standlrt, /// > level2(school: cons standlrt, parexpansion) /// > 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) = 3.43 Deviance (dbar) = 9122.06 Deviance (thetabar) = 9029.64 Effective no. of pars (pd) = 92.42 Bayesian DIC = 9214.48 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.0149551 .0407773 260 0.364 -.0963707 .0631118 standlrt | .5558167 .0198686 1022 0.000 .5154737 .5939462 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .0977909 .0203897 3186 .0650807 .1433166 cov(cons,standlrt) | .0191364 .0073983 1885 .0060379 .0353343 var(standlrt) | .015835 .0048829 1122 .0079222 .0270286 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5539889 .0123977 4769 .5300325 .5784616 ------------------------------------------------------------------------------ . . . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . .399 . . . . . . **************************************************************************** . exit end of do-file