------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\12_Modellin > g_Count_Data.smcl log type: smcl opened on: 27 Mar 2020, 17:42:45 . **************************************************************************** . * MLwiN User Manual . * . * 12 Modelling Count Data 181 . * . * Rasbash, J., Steele, F., Browne, W. J. and Goldstein, H. (2012). . * A User’s Guide to 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/ . **************************************************************************** . . * 12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . .181 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/mmmec.dta", clear . . describe Contains data from http://www.bristol.ac.uk/cmm/media/runmlwin/mmmec.dta obs: 354 vars: 7 21 Oct 2011 12:19 ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- nation byte %9.0g nation Nation ID region byte %9.0g Region ID county int %9.0g Country ID obs int %9.0g Observed number of deaths exp float %9.0g Expected number of deaths cons byte %9.0g Constant uvbi float %9.0g UV B radiation ------------------------------------------------------------------------------- Sorted by: . . . . * 12.2 Fitting a simple Poisson model . . . . . . . . . . . . . . . . . .182 . . generate lnexpected = ln(exp) . . runmlwin obs cons uvbi, /// > level1(county) /// > discrete(distribution(poisson) offset(lnexpected)) nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.63 Number of iterations = 4 ------------------------------------------------------------------------------ obs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0701054 .0110454 -6.35 0.000 -.091754 -.0484569 uvbi | -.0571914 .0026768 -21.37 0.000 -.0624378 -.0519449 ------------------------------------------------------------------------------ . . . . * 12.3 A three-level analysis . . . . . . . . . . . . . . . . . . . . . .184 . . runmlwin obs cons, /// > level3(nation: cons) level2(region: cons) level1(county) /// > discrete(distribution(poisson) offset(lnexpected)) rigls nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: RIGLS, MQL1 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ nation | 9 3 39.3 95 region | 78 1 4.5 13 ----------------------------------------------------------- Run time (seconds) = 0.58 Number of iterations = 5 ------------------------------------------------------------------------------ obs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .1103248 .1604479 0.69 0.492 -.2041473 .4247969 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: nation | var(cons) | .2144996 .1089356 .0009897 .4280095 -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .0453665 .0096476 .0264575 .0642754 ------------------------------------------------------------------------------ . . runmlwin obs cons, /// > level3(nation: cons) level2(region: cons) level1(county) /// > discrete(distribution(poisson) offset(lnexpected) pql2) rigls nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: RIGLS, PQL2 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ nation | 9 3 39.3 95 region | 78 1 4.5 13 ----------------------------------------------------------- Run time (seconds) = 0.62 Number of iterations = 7 ------------------------------------------------------------------------------ obs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0245101 .1516912 -0.16 0.872 -.3218194 .2727992 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: nation | var(cons) | .1854493 .0970516 -.0047683 .3756669 -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .0576268 .0124557 .033214 .0820396 ------------------------------------------------------------------------------ . . runmlwin obs cons uvbi, /// > level3(nation: cons) level2(region: cons) level1(county) /// > discrete(distribution(poisson) offset(lnexpected) pql2) rigls nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: RIGLS, PQL2 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ nation | 9 3 39.3 95 region | 78 1 4.5 13 ----------------------------------------------------------- Run time (seconds) = 0.59 Number of iterations = 6 ------------------------------------------------------------------------------ obs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0821951 .1422564 -0.58 0.563 -.3610124 .1966223 uvbi | -.0277222 .0113226 -2.45 0.014 -.0499141 -.0055303 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: nation | var(cons) | .1572794 .0828079 -.0050211 .3195798 -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .0492207 .0109474 .0277643 .0706771 ------------------------------------------------------------------------------ . . . . * 12.4 A two-level model using separate country terms . . . . . . . . . .186 . . tabulate nation Nation ID | Freq. Percent Cum. ------------+----------------------------------- Belgium | 11 3.11 3.11 W.Germany | 30 8.47 11.58 Denmark | 14 3.95 15.54 France | 94 26.55 42.09 UK | 70 19.77 61.86 Italy | 95 26.84 88.70 Ireland | 26 7.34 96.05 Luxembourg | 3 0.85 96.89 Netherlands | 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. . } . . runmlwin obs belgium-netherlands belgiumXuvbi-netherlandsXuvbi, /// > level2(region: cons) level1(county) /// > discrete(distribution(poisson) offset(lnexpected) pql2) /// > rigls nopause MLwiN 3.05 multilevel model Number of obs = 354 Poisson response model (hierarchical) Estimation algorithm: RIGLS, PQL2 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ region | 78 1 4.5 13 ----------------------------------------------------------- Run time (seconds) = 0.67 Number of iterations = 7 ------------------------------------------------------------------------------ obs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- belgium | .6979009 .7465837 0.93 0.350 -.7653762 2.161178 wgermany | .4776062 .1202215 3.97 0.000 .2419763 .7132361 denmark | .3191143 .8794121 0.36 0.717 -1.404502 2.04273 france | -.5941078 .054329 -10.94 0.000 -.7005906 -.487625 uk | .6140034 .2069723 2.97 0.003 .2083452 1.019662 italy | .2815136 .1045505 2.69 0.007 .0765984 .4864289 ireland | -.5286718 1.302839 -0.41 0.685 -3.08219 2.024847 luxembourg | 14.71263 15.53246 0.95 0.344 -15.73043 45.15568 netherlands | -.3475209 .9230149 -0.38 0.707 -2.156597 1.461555 belgiumXuvbi | .2647173 .2519098 1.05 0.293 -.2290168 .7584514 wgermanyXu~i | -.0133642 .0321108 -0.42 0.677 -.0763002 .0495719 denmarkXuvbi | -.0813623 .1552085 -0.52 0.600 -.3855653 .2228407 franceXuvbi | .0128253 .0179673 0.71 0.475 -.0223901 .0480406 ukXuvbi | .1422951 .0426689 3.33 0.001 .0586656 .2259247 italyXuvbi | -.0874861 .0157854 -5.54 0.000 -.1184249 -.0565472 irelandXuvbi | -.0009567 .2627575 -0.00 0.997 -.5159519 .5140385 luxembourg~i | 6.407484 6.779037 0.95 0.345 -6.879185 19.69415 netherland~i | -.1120154 .2215914 -0.51 0.613 -.5463266 .3222959 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: region | var(cons) | .0357153 .0079396 .0201539 .0512767 ------------------------------------------------------------------------------ . . predict xb . . twoway /// > (line xb uvbi if belgium==1) /// > (line xb uvbi if wgermany==1) /// > (line xb uvbi if denmark==1) /// > (line xb uvbi if france==1) /// > (line xb uvbi if uk==1) /// > (line xb uvbi if italy==1) /// > (line xb uvbi if ireland==1) /// > (line xb uvbi if luxembourg==1) /// > (line xb uvbi if netherlands==1), /// > legend(position(3) col(1) order( /// > 1 "Belgium" /// > 2 "W Germany" /// > 3 "Denmark" /// > 4 "France" /// > 5 "UK" /// > 6 "Italy" /// > 7 "Ireland" /// > 8 "Luxembourg" /// > 9 "Netherlands")) . . . * 12.5 Some issues and problems for discrete response models . . . . . . 190 . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . .190 . . . . **************************************************************************** . exit end of do-file