9.2 Respiratory infection in children: A random intercept model
Table 9.1 on page 286 using https://stats.idre.ucla.edu/wp-content/uploads/2016/02/xerop.dat data.
Model 1: Random intercept model
Title: Random intercept model; Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/xerop.dat ; Variable: Names are resp age xero cosine sine female height stunted time age1 season time2 id; usevar are resp age xero cosine sine female height stunted; within = age xero height sine cosine stunted; between = female ; missing are all (-9999) ; cluster = id; categorical = resp; Analysis: Type = twolevel random; estimator=mlr; integration = 50; Model: %within% resp on age xero cosine sine height stunted; %between% resp on female;TESTS OF MODEL FITLoglikelihoodH0 Value -334.648 H0 Scaling Correction Factor 0.983 for MLRInformation CriteriaNumber of Free Parameters 9 Akaike (AIC) 687.295 Bayesian (BIC) 733.106 Sample-Size Adjusted BIC 704.518 (n* = (n + 2) / 24)MODEL RESULTSEstimates S.E. Est./S.E.Within LevelRESP ON AGE -0.034 0.007 -5.012 XERO 0.623 0.459 1.357 COSINE -0.594 0.180 -3.297 SINE -0.165 0.154 -1.071 HEIGHT -0.048 0.029 -1.631 STUNTED 0.203 0.438 0.463Between LevelRESP ON FEMALE -0.437 0.256 -1.706Thresholds RESP$1 2.675 0.225 11.901Residual Variances RESP 0.656 0.382 1.717LOGISTIC REGRESSION ODDS RATIO RESULTSWithin LevelRESP ON AGE 0.967 XERO 1.865 COSINE 0.552 SINE 0.848 HEIGHT 0.953 STUNTED 1.225
Model 2: Marginal ‘model’ (GEE)
Mplus does not do GEE models in general with any correlation structure other than the independence structure.
9.3 Diagnosis of myocardial infarction: A latent class model
Table 9.2 and Table 9.3 using https://stats.idre.ucla.edu/wp-content/uploads/2016/02/mi.dat.
Title: Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mi.dat ; Variable: Names are qw ldh cpk his count; Categorical are qw ldh cpk his; freqweight is count; class = c(2); Missing are all (-9999) ; Analysis: Type = mixture ; estimator= ml; output: tech10; savedata: file is mi_out.txt; save = cprob;INAL CLASS COUNTS AND PROPORTIONS FOR THE LATENT CLASS PATTERNS BASED ON ESTIMATED POSTERIOR PROBABILITIESLatent Classes1 43.03375 0.45781 2 50.96625 0.54219MODEL RESULTSEstimates S.E. Est./S.E.Latent Class 1Thresholds QW$1 -1.191 0.418 -2.850 LDH$1 -1.571 0.474 -3.315 CPK$1 -15.000 0.000 0.000 HIS$1 -1.333 0.389 -3.426Latent Class 2Thresholds QW$1 15.000 0.000 0.000 LDH$1 3.588 1.009 3.556 CPK$1 1.414 0.412 3.432 HIS$1 1.417 0.388 3.651Categorical Latent VariablesMeans C#1 -0.169 0.226 -0.749
RESPONSE PATTERN FREQUENCIES AND CHI-SQUARE CONTRIBUTIONS
Response Frequency Standard Chi-square Contribution Pattern Observed Estimated Residual Pearson Loglikelihood Deleted 1 33.00 32.11 0.19 0.02 1.80 2 0.00 0.00 0.00 0.00 0.00 DELETED 3 1.00 0.89 0.12 0.01 0.24 4 0.00 0.00 0.00 0.00 0.00 DELETED 5 7.00 8.17 0.43 0.17 -2.16 6 2.00 1.18 0.75 0.56 2.10 7 3.00 1.95 0.76 0.57 2.59 8 4.00 5.70 0.73 0.51 -2.83 9 7.00 7.78 0.29 0.08 -1.48 10 0.00 0.00 0.00 0.00 0.00 DELETED 11 0.00 0.22 0.46 0.22 0.00 12 0.00 0.00 0.00 0.00 0.00 DELETED 13 5.00 3.26 0.98 0.93 4.28 14 3.00 4.49 0.72 0.50 -2.43 15 5.00 6.63 0.66 0.40 -2.82 16 24.00 21.62 0.58 0.26 5.01
The file created by using command savedata gives us the predicted probabilities for class =1 and class = 2. Notice that there are some discrepancy in terms of predicted probabilities for the patterns where the observed counts are zero.
1.000 1.000 1.000 1.000 24.000 1.000 0.000 1.000 0.000 1.000 1.000 1.000 5.000 0.992 0.008 1.000 1.000 1.000 1.000 0.000 4.000 1.000 0.000 1.000 0.000 1.000 1.000 0.000 3.000 0.889 0.111 1.000 1.000 0.000 1.000 1.000 3.000 1.000 0.000 1.000 0.000 0.000 1.000 1.000 5.000 0.419 0.581 2.000 1.000 0.000 1.000 0.000 2.000 1.000 0.000 1.000 0.000 0.000 1.000 0.000 7.000 0.044 0.956 2.000 1.000 1.000 0.000 1.000 0.000 0.990 0.010 1.000 0.000 1.000 0.000 1.000 0.000 0.000 1.000 2.000 1.000 1.000 0.000 0.000 0.000 0.865 0.135 1.000 0.000 1.000 0.000 0.000 1.000 0.000 1.000 2.000 1.000 0.000 0.000 1.000 0.000 0.366 0.634 2.000 0.000 0.000 0.000 1.000 7.000 0.000 1.000 2.000 1.000 0.000 0.000 0.000 0.000 0.036 0.964 2.000 0.000 0.000 0.000 0.000 33.000 0.000 1.000 2.000
9.4 Arithmetic reasoning: Item response models
Table 9.5 using data set https://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy.dat.
Mode 1: One-parameter
Title: 1 parameter model of IRT in genlat; Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy.dat ; Variable: Names are y1 y2 y3 y4 cwm cwf cbm cbf; Missing are all (-9999) ; usevar are y1 y2 y3 y4 count; FREQWEIGHT is count ; categorical = y1 y2 y3 y4; define: count = cwm + cwf + cbm + cbf; Analysis: estimator = mlr; model: f by y1@1 y2@1 y3@1 y4@1;
TESTS OF MODEL FITLoglikelihoodH0 Value -2004.939 H0 Scaling Correction Factor 0.999 for MLRInformation CriteriaNumber of Free Parameters 5 Akaike (AIC) 4019.878 Bayesian (BIC) 4043.148 Sample-Size Adjusted BIC 4027.271 (n* = (n + 2) / 24)Chi-Square Test of Model Fit for the Binary and Ordered Categorical (Ordinal) OutcomesPearson Chi-SquareValue 31.621 Degrees of Freedom 10 P-Value 0.0005Likelihood Ratio Chi-SquareValue 31.590 Degrees of Freedom 10 P-Value 0.0005MODEL RESULTSEstimates S.E. Est./S.E.F BY Y1 1.000 0.000 0.000 Y2 1.000 0.000 0.000 Y3 1.000 0.000 0.000 Y4 1.000 0.000 0.000Thresholds Y1$1 -0.578 0.098 -5.884 Y2$1 -0.238 0.096 -2.485 Y3$1 0.225 0.095 2.379 Y4$1 0.594 0.096 6.206Variances F 1.629 0.208 7.837
Model 2: Two-parameter
Title: Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy.dat ; Variable: Names are y1 y2 y3 y4 cwm cwf cbm cbf; Missing are all (-9999) ; usevar are y1 y2 y3 y4 count; FREQWEIGHT is count ; categorical = y1 y2 y3 y4; define: count = cwm + cwf + cbm + cbf; Analysis: estimator=mlr; model: f by y1 y2 y3 y4;TESTS OF MODEL FITLoglikelihoodH0 Value -2002.740 H0 Scaling Correction Factor 1.001 for MLRInformation CriteriaNumber of Free Parameters 8 Akaike (AIC) 4021.480 Bayesian (BIC) 4058.713 Sample-Size Adjusted BIC 4033.310 (n* = (n + 2) / 24)Chi-Square Test of Model Fit for the Binary and Ordered Categorical (Ordinal) OutcomesPearson Chi-SquareValue 27.119 Degrees of Freedom 7 P-Value 0.0003Likelihood Ratio Chi-SquareValue 27.193 Degrees of Freedom 7 P-Value 0.0003MODEL RESULTSEstimates S.E. Est./S.E.F BY Y1 1.000 0.000 0.000 Y2 0.647 0.152 4.253 Y3 0.694 0.170 4.082 Y4 0.897 0.213 4.215Thresholds Y1$1 -0.645 0.116 -5.566 Y2$1 -0.219 0.089 -2.479 Y3$1 0.216 0.091 2.356 Y4$1 0.625 0.112 5.579Variances F 2.599 0.839 3.097
Table 9.6 using data set https://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy_long.dat.
Model 1: Restricted model
Data: File is C:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy_long.dat ; Variable: Names are y1 y2 y3 y4 count black female; Missing are all (-9999) ; categorical are y1 y2 y3 y4; usevar are y1 y2 y3 y4 count black female bf; freqweight is count; define: bf = black*female; Analysis: estimator = mlr; !This is required; model: f by y1 y2 y3 y4; [y1$1@0 y2$1 y3$1 y4$1]; f on black@0 female@0 bf@0; [f];TESTS OF MODEL FIT Loglikelihood H0 Value -2002.740 H0 Scaling Correction Factor 1.001 for MLR Information Criteria Number of Free Parameters 8 Akaike (AIC) 4021.480 Bayesian (BIC) 4058.713 Sample-Size Adjusted BIC 4033.310 (n* = (n + 2) / 24) Chi-Square Test of Model Fit for the Binary and Ordered Categorical (Ordinal) Outcomes Pearson Chi-Square Value 27.124 Degrees of Freedom 7 P-Value 0.0003 Likelihood Ratio Chi-Square Value 27.193 Degrees of Freedom 7 P-Value 0.0003 MODEL RESULTS Estimates S.E. Est./S.E. F BY Y1 1.000 0.000 0.000 Y2 0.647 0.152 4.270 Y3 0.696 0.170 4.081 Y4 0.897 0.212 4.237 F ON BLACK 0.000 0.000 0.000 FEMALE 0.000 0.000 0.000 BF 0.000 0.000 0.000 Intercepts F 0.645 0.116 5.572 Thresholds Y1$1 0.000 0.000 0.000 Y2$1 0.198 0.124 1.600 Y3$1 0.664 0.148 4.480 Y4$1 1.204 0.194 6.203 Residual Variances F 2.596 0.835 3.110
Model 2:
Data: File is C:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy_long.dat ; Variable: Names are y1 y2 y3 y4 count black female; Missing are all (-9999) ; categorical are y1 y2 y3 y4; usevar are y1 y2 y3 y4 count black female bf; freqweight is count; define: bf = black*female; Analysis: estimator = mlr; !This is required; model: f by y1 y2 y3 y4; [y1$1@0 y2$1 y3$1 y4$1]; f on black female bf; [f];Loglikelihood H0 Value -1956.234 H0 Scaling Correction Factor 0.966 for MLR Information Criteria Number of Free Parameters 11 Akaike (AIC) 3934.468 Bayesian (BIC) 3985.664 Sample-Size Adjusted BIC 3950.733 (n* = (n + 2) / 24) MODEL RESULTS Estimates S.E. Est./S.E. F BY Y1 1.000 0.000 0.000 Y2 0.676 0.139 4.871 Y3 0.772 0.164 4.695 Y4 0.861 0.160 5.393 F ON BLACK -1.685 0.301 -5.607 FEMALE -0.620 0.219 -2.836 BF 0.670 0.310 2.158 Intercepts F 1.436 0.211 6.796 Thresholds Y1$1 0.000 0.000 0.000 Y2$1 0.211 0.122 1.733 Y3$1 0.714 0.152 4.703 Y4$1 1.158 0.168 6.912 Residual Variances F 1.973 0.564 3.499
Model 3: Direct effect of the interaction term on y1
Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/mislevy_long.dat ;Variable: Names are y1 y2 y3 y4 count black female; Missing are all (-9999) ; categorical are y1 y2 y3 y4; usevar are y1 y2 y3 y4 count black female bf; freqweight is count; define: bf = black*female; Analysis: estimator = mlr; !This is required; model: y1 on bf ; f by y1 y2 y3 y4 ; [y1$1@0 y2$1 y3$1 y4$1]; f on black female bf; [f];TESTS OF MODEL FITLoglikelihoodH0 Value -1954.849 H0 Scaling Correction Factor 0.972 for MLRInformation CriteriaNumber of Free Parameters 12 Akaike (AIC) 3933.697 Bayesian (BIC) 3989.547 Sample-Size Adjusted BIC 3951.442 (n* = (n + 2) / 24)MODEL RESULTSEstimates S.E. Est./S.E.F BY Y1 1.000 0.000 0.000 Y2 0.596 0.135 4.424 Y3 0.686 0.156 4.391 Y4 0.760 0.157 4.847F ON BLACK -1.837 0.341 -5.394 FEMALE -0.685 0.243 -2.821 BF 0.536 0.324 1.657Y1 ON BF 0.519 0.345 1.505Intercepts F 1.475 0.231 6.383Thresholds Y1$1 0.000 0.000 0.000 Y2$1 0.119 0.126 0.945 Y3$1 0.609 0.152 4.001 Y4$1 1.034 0.168 6.147Residual Variances F 2.361 0.733 3.223
9.5 Nicotine gum and smoking cessation: A meta-analysis
Model: Empirical Bayes using https://stats.idre.ucla.edu/wp-content/uploads/2016/02/gum_exp.dat.
Title: Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/gum_exp.dat ; Variable: Names are quit study gum treat; categorical are quit; Missing are all (-9999) ; usevar are quit treat; within is treat; cluster is study; Analysis: Type = twolevel random; model: %within% s | quit on treat; %between% quit s; quit with s@0;LoglikelihoodH0 Value -3074.150 H0 Scaling Correction Factor 1.046 for MLRInformation CriteriaNumber of Free Parameters 4 Akaike (AIC) 6156.300 Bayesian (BIC) 6183.036 Sample-Size Adjusted BIC 6170.325 (n* = (n + 2) / 24)MODEL RESULTSEstimates S.E. Est./S.E.Within LevelBetween LevelQUIT WITH S 0.000 0.000 0.000Means S 0.569 0.094 6.045Thresholds QUIT$1 1.162 0.143 8.119Variances QUIT 0.488 0.184 2.645 S 0.055 0.044 1.254
9.6 Wives’ employment transitions: Markov models with unobserved heterogeneity
Table 9.10 on page 309 using https://stats.idre.ucla.edu/wp-content/uploads/2016/02/wemp.dat
Model 1:
Data: File is c:genlathttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/wemp.dat ; Variable: Names are case y hunemp time child1 child5 age agesq ly; Missing are all (-9999) ; categorical are y; usevar are y hunemp time child1 child5 age agesq ly; Analysis: estimator=ml; model: y on hunemp time child1 child5 age agesq ly;TESTS OF MODEL FITLoglikelihoodH0 Value -411.500Information CriteriaNumber of Free Parameters 8 Akaike (AIC) 838.999 Bayesian (BIC) 881.095 Sample-Size Adjusted BIC 855.682 (n* = (n + 2) / 24)MODEL RESULTSEstimates S.E. Est./S.E.Y ON HUNEMP -1.406 0.373 -3.765 TIME -0.012 0.025 -0.466 CHILD1 -3.008 0.392 -7.678 CHILD5 -0.165 0.253 -0.653 AGE -0.005 0.014 -0.328 AGESQ -0.001 0.001 -0.592 LY 4.391 0.209 21.051Thresholds Y$1 1.277 0.240 5.319
Model 2:
Data: File is c:genlatwemp_stata.dat ; Variable: Names are case y hunemp time child1 child5 age agesq ly; Missing are all (-9999) ; categorical are y; cluster = case; within are hunemp time child1 child5 age agesq ly; usevar are y hunemp time child1 child5 age agesq ly; Analysis: type = twolevel random; estimator=ml; model: %within% y on hunemp time child1 child5 age agesq ly; %between% y;TESTS OF MODEL FITLoglikelihoodH0 Value -410.890Information CriteriaNumber of Free Parameters 9 Akaike (AIC) 839.781 Bayesian (BIC) 887.138 Sample-Size Adjusted BIC 858.548 (n* = (n + 2) / 24)MODEL RESULTSEstimates S.E. Est./S.E.Within LevelY ON HUNEMP -1.512 0.411 -3.683 TIME -0.011 0.026 -0.414 CHILD1 -2.948 0.408 -7.229 CHILD5 -0.241 0.273 -0.884 AGE 0.000 0.016 0.011 AGESQ -0.001 0.001 -0.655 LY 4.222 0.264 16.017Between LevelThresholds Y$1 1.111 0.299 3.711Variances Y 0.311 0.327 0.953
9.7 Counting snowshoe hares: Capture-recapture models with heterogeneity