------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\13.1.smcl log type: smcl opened on: 27 Mar 2020, 18:24:13 . **************************************************************************** . * Module 13: Multiple Membership Models - Stata Practical . * . * P13.1: Examining and Describing the Data . * . * George Leckie . * Centre for Multilevel Modelling, 2011 . **************************************************************************** . * Stata do-file to replicate all analyses using runmlwin . * . * George Leckie . * Centre for Multilevel Modelling, 2013 . * http://www.bristol.ac.uk/cmm/software/runmlwin/ . **************************************************************************** . . * P13.1.1 Exploring the multiple membership data structure . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/13.1.dta", clear . . describe Contains data from http://www.bristol.ac.uk/cmm/media/runmlwin/13.1.dta obs: 1,000 vars: 67 2 Aug 2013 17:08 ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- patient int %9.0g Patient ID satis float %3.2f Satisfaction Score cons byte %9.0g Constant assess float %9.0g Assessment Score nurses byte %9.0g Number of nurses seen by patient n1st byte %9.0g Nurse ID for patient's 1st nurse n2nd byte %9.0g Nurse ID for patient's 2nd nurse n3rd byte %9.0g Nurse ID for patient's 3rd nurse n4th byte %9.0g Nurse ID for patient's 4th nurse p1st float %9.0g Prop. time cared for by 1st nurse p2nd float %9.0g Prop. time cared for by 2nd nurse p3rd float %9.0g Prop. time cared for by 3rd nurse p4th float %9.0g Prop. time cared for by 4th nurse h1st float %3.2f Happiness score for 1st nurse h2nd float %3.2f Happiness score for 2nd nurse h3rd float %3.2f Happiness score for 3rd nurse h4th float %3.2f Happiness score for 4th nurse p1 float %9.0g Prop. time cared for by nurse 1 p2 float %9.0g Prop. time cared for by nurse 2 p3 float %9.0g Prop. time cared for by nurse 3 p4 float %9.0g Prop. time cared for by nurse 4 p5 float %9.0g Prop. time cared for by nurse 5 p6 float %9.0g Prop. time cared for by nurse 6 p7 float %9.0g Prop. time cared for by nurse 7 p8 float %9.0g Prop. time cared for by nurse 8 p9 float %9.0g Prop. time cared for by nurse 9 p10 float %9.0g Prop. time cared for by nurse 10 p11 float %9.0g Prop. time cared for by nurse 11 p12 float %9.0g Prop. time cared for by nurse 12 p13 float %9.0g Prop. time cared for by nurse 13 p14 float %9.0g Prop. time cared for by nurse 14 p15 float %9.0g Prop. time cared for by nurse 15 p16 float %9.0g Prop. time cared for by nurse 16 p17 float %9.0g Prop. time cared for by nurse 17 p18 float %9.0g Prop. time cared for by nurse 18 p19 float %9.0g Prop. time cared for by nurse 19 p20 float %9.0g Prop. time cared for by nurse 20 p21 float %9.0g Prop. time cared for by nurse 21 p22 float %9.0g Prop. time cared for by nurse 22 p23 float %9.0g Prop. time cared for by nurse 23 p24 float %9.0g Prop. time cared for by nurse 24 p25 float %9.0g Prop. time cared for by nurse 25 h1 float %3.2f Happiness score for nurse 1 h2 float %3.2f Happiness score for nurse 2 h3 float %3.2f Happiness score for nurse 3 h4 float %3.2f Happiness score for nurse 4 h5 float %3.2f Happiness score for nurse 5 h6 float %3.2f Happiness score for nurse 6 h7 float %3.2f Happiness score for nurse 7 h8 float %3.2f Happiness score for nurse 8 h9 float %3.2f Happiness score for nurse 9 h10 float %3.2f Happiness score for nurse 10 h11 float %3.2f Happiness score for nurse 11 h12 float %3.2f Happiness score for nurse 12 h13 float %3.2f Happiness score for nurse 13 h14 float %3.2f Happiness score for nurse 14 h15 float %3.2f Happiness score for nurse 15 h16 float %3.2f Happiness score for nurse 16 h17 float %3.2f Happiness score for nurse 17 h18 float %3.2f Happiness score for nurse 18 h19 float %3.2f Happiness score for nurse 19 h20 float %3.2f Happiness score for nurse 20 h21 float %3.2f Happiness score for nurse 21 h22 float %3.2f Happiness score for nurse 22 h23 float %3.2f Happiness score for nurse 23 h24 float %3.2f Happiness score for nurse 24 h25 float %3.2f Happiness score for nurse 25 ------------------------------------------------------------------------------- Sorted by: patient . . summarize patient satis assess nurses Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- patient | 1,000 500.5 288.8194 1 1000 satis | 1,000 -.0387974 .9809753 -2.981966 3.040571 assess | 1,000 .0204101 .9700845 -2.9099 3.22795 nurses | 1,000 2 1.0005 1 4 . . list patient satis n1st-n4th p1st-p4th if inrange(_n,1,5) /// > | inrange(_n,401,405) | inrange(_n,701,705) /// > | inrange(_n,901,905), noobs +-------------------------------------------------------------------------+ | patient satis n1st n2nd n3rd n4th p1st p2nd p3rd p4th | |-------------------------------------------------------------------------| | 1 2.09 24 0 0 0 1 0 0 0 | | 2 -0.13 10 0 0 0 1 0 0 0 | | 3 -0.34 15 0 0 0 1 0 0 0 | | 4 -0.90 16 0 0 0 1 0 0 0 | | 5 1.16 5 0 0 0 1 0 0 0 | |-------------------------------------------------------------------------| | 401 -0.59 22 16 0 0 .32 .68 0 0 | | 402 1.17 11 6 0 0 .55 .45 0 0 | | 403 0.80 8 2 0 0 .45 .55 0 0 | | 404 -0.61 6 12 0 0 .61 .39 0 0 | | 405 -0.09 21 13 0 0 .54 .46 0 0 | |-------------------------------------------------------------------------| | 701 0.25 24 20 12 0 .4 .2 .4 0 | | 702 -0.69 13 24 4 0 .41 .44 .15 0 | | 703 -2.03 7 22 8 0 .44 .38 .18 0 | | 704 0.79 3 14 21 0 .45 .45 .1 0 | | 705 -0.27 13 25 14 0 .44 .36 .2 0 | |-------------------------------------------------------------------------| | 901 0.00 5 19 4 3 .29 .23 .25 .23 | | 902 2.77 23 12 4 7 .35 .13 .29 .23 | | 903 -0.49 10 7 8 3 .23 .19 .29 .29 | | 904 -1.38 17 2 9 16 .21 .17 .24 .38 | | 905 -1.79 4 15 8 24 .25 .36 .37 .02 | +-------------------------------------------------------------------------+ . . list patient satis p1-p10 if inrange(_n,1,5) /// > | inrange(_n,401,405) | inrange(_n,701,705) /// > | inrange(_n,901,905), noobs +---------------------------------------------------------------------------- + | patient satis p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 | |---------------------------------------------------------------------------- | | 1 2.09 0 0 0 0 0 0 0 0 0 0 | | 2 -0.13 0 0 0 0 0 0 0 0 0 1 | | 3 -0.34 0 0 0 0 0 0 0 0 0 0 | | 4 -0.90 0 0 0 0 0 0 0 0 0 0 | | 5 1.16 0 0 0 0 1 0 0 0 0 0 | |---------------------------------------------------------------------------- | | 401 -0.59 0 0 0 0 0 0 0 0 0 0 | | 402 1.17 0 0 0 0 0 .45 0 0 0 0 | | 403 0.80 0 .55 0 0 0 0 0 .45 0 0 | | 404 -0.61 0 0 0 0 0 .61 0 0 0 0 | | 405 -0.09 0 0 0 0 0 0 0 0 0 0 | |---------------------------------------------------------------------------- | | 701 0.25 0 0 0 0 0 0 0 0 0 0 | | 702 -0.69 0 0 0 .15 0 0 0 0 0 0 | | 703 -2.03 0 0 0 0 0 0 .44 .18 0 0 | | 704 0.79 0 0 .45 0 0 0 0 0 0 0 | | 705 -0.27 0 0 0 0 0 0 0 0 0 0 | |---------------------------------------------------------------------------- | | 901 0.00 0 0 .23 .25 .29 0 0 0 0 0 | | 902 2.77 0 0 0 .29 0 0 .23 0 0 0 | | 903 -0.49 0 0 .29 0 0 0 .19 .29 0 .23 | | 904 -1.38 0 .17 0 0 0 0 0 0 .24 0 | | 905 -1.79 0 0 0 .25 0 0 0 .37 0 0 | +---------------------------------------------------------------------------- + . . recode p1-p25 (0=.) (p1: 910 changes made) (p2: 909 changes made) (p3: 927 changes made) (p4: 925 changes made) (p5: 921 changes made) (p6: 915 changes made) (p7: 918 changes made) (p8: 923 changes made) (p9: 926 changes made) (p10: 923 changes made) (p11: 931 changes made) (p12: 902 changes made) (p13: 905 changes made) (p14: 909 changes made) (p15: 918 changes made) (p16: 925 changes made) (p17: 931 changes made) (p18: 923 changes made) (p19: 922 changes made) (p20: 933 changes made) (p21: 905 changes made) (p22: 925 changes made) (p23: 921 changes made) (p24: 926 changes made) (p25: 927 changes made) . . tabstat p1-p25, statistics(count) columns(statistics) format(%2.0f) variable | N -------------+---------- p1 | 90 p2 | 91 p3 | 73 p4 | 75 p5 | 79 p6 | 85 p7 | 82 p8 | 77 p9 | 74 p10 | 77 p11 | 69 p12 | 98 p13 | 95 p14 | 91 p15 | 82 p16 | 75 p17 | 69 p18 | 77 p19 | 78 p20 | 67 p21 | 95 p22 | 75 p23 | 79 p24 | 74 p25 | 73 ------------------------ . . recode p1-p25 (.=0) (p1: 910 changes made) (p2: 909 changes made) (p3: 927 changes made) (p4: 925 changes made) (p5: 921 changes made) (p6: 915 changes made) (p7: 918 changes made) (p8: 923 changes made) (p9: 926 changes made) (p10: 923 changes made) (p11: 931 changes made) (p12: 902 changes made) (p13: 905 changes made) (p14: 909 changes made) (p15: 918 changes made) (p16: 925 changes made) (p17: 931 changes made) (p18: 923 changes made) (p19: 922 changes made) (p20: 933 changes made) (p21: 905 changes made) (p22: 925 changes made) (p23: 921 changes made) (p24: 926 changes made) (p25: 927 changes made) . . tabstat p1-p25, statistics(sum) columns(statistics) format(%2.1f) variable | sum -------------+---------- p1 | 44.3 p2 | 48.8 p3 | 34.8 p4 | 36.4 p5 | 41.0 p6 | 38.7 p7 | 39.6 p8 | 37.3 p9 | 42.9 p10 | 44.1 p11 | 32.4 p12 | 49.8 p13 | 48.7 p14 | 44.3 p15 | 43.5 p16 | 35.3 p17 | 29.9 p18 | 40.5 p19 | 38.8 p20 | 32.8 p21 | 47.0 p22 | 40.1 p23 | 37.7 p24 | 35.8 p25 | 35.6 ------------------------ . . scatter p1 p2 . . . . * P13.1.2 Summarising the response and predictor variables . . summarize satis assess Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- satis | 1,000 -.0387974 .9809753 -2.981966 3.040571 assess | 1,000 .0204101 .9700845 -2.9099 3.22795 . . twoway (kdensity satis) (kdensity assess) . . tabulate n1st Nurse ID | for | patient's | 1st nurse | Freq. Percent Cum. ------------+----------------------------------- 1 | 39 3.90 3.90 2 | 49 4.90 8.80 3 | 32 3.20 12.00 4 | 45 4.50 16.50 5 | 43 4.30 20.80 6 | 25 2.50 23.30 7 | 45 4.50 27.80 8 | 34 3.40 31.20 9 | 41 4.10 35.30 10 | 46 4.60 39.90 11 | 32 3.20 43.10 12 | 50 5.00 48.10 13 | 56 5.60 53.70 14 | 39 3.90 57.60 15 | 46 4.60 62.20 16 | 34 3.40 65.60 17 | 38 3.80 69.40 18 | 40 4.00 73.40 19 | 40 4.00 77.40 20 | 40 4.00 81.40 21 | 48 4.80 86.20 22 | 38 3.80 90.00 23 | 39 3.90 93.90 24 | 32 3.20 97.10 25 | 29 2.90 100.00 ------------+----------------------------------- Total | 1,000 100.00 . . egen pickone_n1st = tag(n1st) . . summarize h1st if pickone_n1st==1 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- h1st | 25 -.0057378 1.029708 -1.985823 1.767854 . . kdensity h1st if pickone_n1st==1 . end of do-file