This dataset includes 5 manifest items about abortion and several covariates. From the original 2018 National Youth Tobacco Survey data, the Non Hispanic, white students are selected and schools with 30-50 students were selected. Thus, the dataset has 1743 respondents. The covariates include the sex of the respondents and the school ID to which the respondnets belong, and the level of the corresponding school.
A data frame with 1734 observations on the following 8 variables.
ECIGT
Whether to have tried cigarette smoking, even one or two puffs
ECIGAR
Whether to have ever tried cigar smoking, even one or two puffs
ESLT
Whether to have used chewing tobacco, snuff, or dip
EELCIGT
Whether to have used electronic cigarettes or e-cigarettes
EHOOKAH
Whether to have tried smoking tobacco from a hookah or a waterpipe
SEX
Respondent's Sex
SCH_ID
School ID to which the respondent belongs
SCH_LEV
Level of the corresponding school
data("nyts18")
# \donttest{
# Model 1: LCA
lca = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
data = nyts18, nclass = 3)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -2087.91
#> SET : 2 .....loglik : -2088.307
#> SET : 3 .....loglik : -2119.035
#> SET : 4 .....loglik : -2118.658
#> SET : 5 .....loglik : -2088.554
#> SET : 6 .....loglik : -2086.869
#> SET : 7 .....loglik : -2100.749
#> SET : 8 .....loglik : -2094.886
#> SET : 9 .....loglik : -2088.368
#> SET : 10 .....loglik : -2109.467
#>
#> Start with SET 6 (-2086.869)
#>
#> Latent class analysis Fitting...
#>
#> .. 231 iteration
#>
#> Converged at 231 iteration (loglik :-2086.857)
summary(lca)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> 1, data = nyts18, nclass = 3)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Latent class analysis
#>
#> Number of latent classes : 3
#> Number of observations : 1734
#> Number of parameters : 17
#>
#> log-likelihood : -2086.857
#> G-squared : 29.52011
#> AIC : 4207.714
#> BIC : 4300.503
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.12572 0.04460 0.82968
#>
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.5308 0.3655 0.1901 0.8717 0.0618
#> Class 2 0.9340 0.9777 0.6542 0.9767 0.6776
#> Class 3 0.0125 0.0074 0.0102 0.0843 0.0071
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.4692 0.6345 0.8099 0.1283 0.9382
#> Class 2 0.0660 0.0223 0.3458 0.0233 0.3224
#> Class 3 0.9875 0.9926 0.9898 0.9157 0.9929
# Model 2: LCR
lca = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ SEX,
data = nyts18, nclass = 3)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Covariates (Level 1) :
#> SEX
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -2085.498
#> SET : 2 .....loglik : -2083.957
#> SET : 3 .....loglik : -2112.708
#> SET : 4 .....loglik : -2089.61
#> SET : 5 .....loglik : -2098.521
#> SET : 6 .....loglik : -2085.283
#> SET : 7 .....loglik : -2086.116
#> SET : 8 .....loglik : -2083.78
#> SET : 9 .....loglik : -2084.815
#> SET : 10 .....loglik : -2111.966
#>
#> Start with SET 8 (-2083.78)
#>
#> Latent class analysis Fitting...
#>
#> .. 283 iteration
#>
#> Converged at 283 iteration (loglik :-2083.746)
summary(lca)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> SEX, data = nyts18, nclass = 3)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Covariates (Level 1) : SEX
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Latent class analysis
#>
#> Number of latent classes : 3
#> Number of observations : 1734
#> Number of parameters : 19
#>
#> log-likelihood : -2083.746
#> G-squared : 98.82476
#> AIC : 4205.492
#> BIC : 4309.197
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.12821 0.82078 0.05102
#>
#> Logistic regression coefficients :
#> Class 1/3 Class 2/3
#> (Intercept) 1.3004 3.1542
#> SEXFemale -0.6691 -0.6633
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.4939 0.3160 0.1632 0.8466 0.0554
#> Class 2 0.0109 0.0069 0.0099 0.0787 0.0069
#> Class 3 0.9102 0.9695 0.6368 0.9786 0.6113
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.5061 0.6840 0.8368 0.1534 0.9446
#> Class 2 0.9891 0.9931 0.9901 0.9213 0.9931
#> Class 3 0.0898 0.0305 0.3632 0.0214 0.3887
coef(lca)
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> (Intercept) 3.6707 1.3004 0.3032 4.289 9.68e-05 ***
#> SEXFemale 0.5121 -0.6691 0.3607 -1.855 0.0703 .
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Class 2 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> (Intercept) 23.4332 3.1542 0.2765 11.408 9.86e-15 ***
#> SEXFemale 0.5151 -0.6633 0.2855 -2.323 0.0249 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
# Model 3: MGLCA
mglca = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
group = SEX, data = nyts18, nclass = 3)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SEX
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -2085.195
#> SET : 2 .....loglik : -2107.331
#> SET : 3 .....loglik : -2085.416
#> SET : 4 .....loglik : -2084.726
#> SET : 5 .....loglik : -2113.222
#> SET : 6 .....loglik : -2113.414
#> SET : 7 .....loglik : -2086.518
#> SET : 8 .....loglik : -2083.899
#> SET : 9 .....loglik : -2114.25
#> SET : 10 .....loglik : -2092.189
#>
#> Start with SET 8 (-2083.899)
#>
#> Multiple-group latent class analysis Fitting...
#>
#> .. 249 iteration
#>
#> Converged at 249 iteration (loglik :-2083.746)
summary(mglca)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> 1, group = SEX, data = nyts18, nclass = 3)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SEX
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Multiple-group latent class analysis
#>
#> Number of latent classes : 3
#> Number of groups : 2
#> Number of observations : 1734
#> Number of parameters : 19
#>
#> log-likelihood : -2083.746
#> G-squared : 98.82476
#> AIC : 4205.492
#> BIC : 4309.197
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.12820 0.82079 0.05101
#>
#> Class prevalences by group :
#> Class 1 Class 2 Class 3
#> Male 0.13060 0.83382 0.03558
#> Female 0.12573 0.80739 0.06688
#>
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.4940 0.3161 0.1632 0.8467 0.0554
#> Class 2 0.0109 0.0069 0.0099 0.0788 0.0069
#> Class 3 0.9102 0.9695 0.6368 0.9786 0.6114
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.5060 0.6839 0.8368 0.1533 0.9446
#> Class 2 0.9891 0.9931 0.9901 0.9212 0.9931
#> Class 3 0.0898 0.0305 0.3632 0.0214 0.3886
# Model 4: MLCA
mlca = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
group = SCH_ID, data = nyts18, nclass = 3, ncluster = 2)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -1955.488
#> SET : 2 .....loglik : -1968.406
#> SET : 3 .....loglik : -1955.593
#> SET : 4 .....loglik : -1957.32
#> SET : 5 .....loglik : -1957.826
#> SET : 6 .....loglik : -1977.273
#> SET : 7 .....loglik : -1955.499
#> SET : 8 .....loglik : -1958.045
#> SET : 9 .....loglik : -1955.491
#> SET : 10 .....loglik : -1958.555
#>
#> Start with SET 1 (-1955.488)
#>
#> Nonparametric multilevel latent class analysis Fitting...
#>
#> 69 iteration
#>
#> Converged at 69 iteration (loglik :-1955.487)
summary(mlca)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> 1, group = SCH_ID, data = nyts18, nclass = 3, ncluster = 2)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Nonparametric multilevel latent class analysis
#>
#> Number of latent classes : 3
#> Number of latent clusters : 2
#> Number of groups : 45
#> Number of observations : 1734
#> Number of parameters : 20
#>
#> log-likelihood : -1955.487
#> G-squared : 768.5035
#> AIC : 3950.973
#> BIC : 4060.137
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.76961 0.05960 0.17079
#>
#> Marginal prevalences for latent clusters :
#> Cluster 1 Cluster 2
#> 0.62069 0.37931
#>
#> Class prevalences by cluster :
#> Class 1 Class 2 Class 3
#> Cluster 1 0.92995 0.00876 0.06129
#> Cluster 2 0.51177 0.14137 0.34687
#>
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.0062 0.0043 0.0088 0.0413 0.0057
#> Class 2 0.9112 0.9750 0.5651 0.9778 0.5364
#> Class 3 0.3488 0.2006 0.1236 0.7783 0.0443
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.9938 0.9957 0.9912 0.9587 0.9943
#> Class 2 0.0888 0.0250 0.4349 0.0222 0.4636
#> Class 3 0.6512 0.7994 0.8764 0.2217 0.9557
#>
# Model 5: MLCA with level-1 covariate(s) only
mlcr = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ SEX,
group = SCH_ID, data = nyts18, nclass = 3, ncluster = 2)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#> Covariates (Level 1) :
#> SEX
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -1951.914
#> SET : 2 .....loglik : -1960.453
#> SET : 3 .....loglik : -1953.765
#> SET : 4 .....loglik : -1953.064
#> SET : 5 .....loglik : -1951.982
#> SET : 6 .....loglik : -2010.17
#> SET : 7 .....loglik : -1952.027
#> SET : 8 .....loglik : -1969.89
#> SET : 9 .....loglik : -1965.47
#> SET : 10 .....loglik : -1951.901
#>
#> Start with SET 10 (-1951.901)
#>
#> Nonparametric multilevel latent class analysis Fitting...
#>
#> . 168 iteration
#>
#> Converged at 168 iteration (loglik :-1951.879)
summary(mlcr)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> SEX, group = SCH_ID, data = nyts18, nclass = 3, ncluster = 2)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#> Covariates (Level 1) : SEX
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Nonparametric multilevel latent class analysis
#>
#> Number of latent classes : 3
#> Number of latent clusters : 2
#> Number of groups : 45
#> Number of observations : 1734
#> Number of parameters : 22
#>
#> log-likelihood : -1951.879
#> G-squared : 1116.424
#> AIC : 3947.757
#> BIC : 4067.837
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.06018 0.17105 0.76877
#>
#> Marginal prevalences for latent clusters :
#> Cluster 1 Cluster 2
#> 0.61682 0.38318
#>
#> Class prevalences by cluster :
#> Class 1 Class 2 Class 3
#> Cluster 1 0.00923 0.06023 0.93054
#> Cluster 2 0.14098 0.34682 0.51220
#>
#>
#> Logistic regression coefficients (level 1) :
#> Cluster 1
#> Class 1/3 Class 2/3
#> (Intercept) -4.9893 -2.7664
#> SEXFemale 0.6576 0.0578
#>
#> Cluster 2
#> Class 1/3 Class 2/3
#> (Intercept) -1.6489 -0.4171
#> SEXFemale 0.6576 0.0578
#>
#>
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.9025 0.9712 0.5744 0.9782 0.5341
#> Class 2 0.3502 0.1987 0.1188 0.7726 0.0438
#> Class 3 0.0059 0.0042 0.0087 0.0416 0.0057
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.0975 0.0288 0.4256 0.0218 0.4659
#> Class 2 0.6498 0.8013 0.8812 0.2274 0.9562
#> Class 3 0.9941 0.9958 0.9913 0.9584 0.9943
#>
coef(mlcr)
#>
#> Level 1 Coefficients :
#>
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SEXFemale 1.9301 0.6576 0.2071 3.176 0.00152 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Class 2 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SEXFemale 1.05946 0.05776 0.16491 0.35 0.726
#>
# Model 6: MLCA with level-1 and level-2 covariate(s)
# (SEX: level-1 covariate, PARTY: level-2 covariate)
mlcr2 = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ SEX + SCH_LEV,
group = SCH_ID, data = nyts18, nclass = 3, ncluster = 2)
#> Manifest items :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#> Covariates (Level 2) :
#> SCH_LEV
#> Covariates (Level 1) :
#> SEX
#>
#> Deleted observation(s) :
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -1921.21
#> SET : 2 .....loglik : -1919.94
#> SET : 3 .....loglik : -1921.655
#> SET : 4 .....loglik : -1919.938
#> SET : 5 .....loglik : -1944.429
#> SET : 6 .....loglik : -1942.334
#> SET : 7 .....loglik : -1944.573
#> SET : 8 .....loglik : -1942.551
#> SET : 9 .....loglik : -1920.384
#> SET : 10 .....loglik : -1921.833
#>
#> Start with SET 4 (-1919.938)
#>
#> Nonparametric multilevel latent class analysis Fitting...
#>
#> . 178 iteration
#>
#> Converged at 178 iteration (loglik :-1919.937)
summary(mlcr2)
#>
#> Call:
#> glca(formula = item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~
#> SEX + SCH_LEV, group = SCH_ID, data = nyts18, nclass = 3,
#> ncluster = 2)
#>
#> Manifest items : ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Grouping variable : SCH_ID
#> Covariates (Level 1) : SEX
#> Covariates (Level 2) : SCH_LEV
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> ECIGT Yes No
#> ECIGAR Yes No
#> ESLT Yes No
#> EELCIGT Yes No
#> EHOOKAH Yes No
#>
#> Model : Nonparametric multilevel latent class analysis
#>
#> Number of latent classes : 3
#> Number of latent clusters : 2
#> Number of groups : 45
#> Number of observations : 1734
#> Number of parameters : 24
#>
#> log-likelihood : -1919.937
#> G-squared : 1052.541
#> AIC : 3887.874
#> BIC : 4018.87
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.18159 0.06455 0.75385
#>
#> Marginal prevalences for latent clusters :
#> Cluster 1 Cluster 2
#> 0.45917 0.54083
#>
#> Class prevalences by cluster :
#> Class 1 Class 2 Class 3
#> Cluster 1 0.29044 0.1175 0.59206
#> Cluster 2 0.08978 0.0199 0.89032
#>
#>
#> Logistic regression coefficients (level 1) :
#> Cluster 1
#> Class 1/3 Class 2/3
#> (Intercept) 0.1671 -0.8997
#> SEXFemale 0.1159 0.6307
#>
#> Cluster 2
#> Class 1/3 Class 2/3
#> (Intercept) -1.0654 -2.6345
#> SEXFemale 0.1159 0.6307
#>
#> Logistic regression coefficients (level 2) :
#> Class 1/3 Class 2/3
#> SCH_LEVMiddle School -1.9522 -2.5656
#>
#>
#> Item-response probabilities (Y = 1) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.3227 0.1696 0.1127 0.7266 0.0394
#> Class 2 0.8914 0.9657 0.5507 0.9782 0.5049
#> Class 3 0.0033 0.0034 0.0074 0.0372 0.0056
#>
#> Item-response probabilities (Y = 2) :
#> ECIGT ECIGAR ESLT EELCIGT EHOOKAH
#> Class 1 0.6773 0.8304 0.8873 0.2734 0.9606
#> Class 2 0.1086 0.0343 0.4493 0.0218 0.4951
#> Class 3 0.9967 0.9966 0.9926 0.9628 0.9944
#>
coef(mlcr2)
#>
#> Level 1 Coefficients :
#>
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SEXFemale 1.1228 0.1159 0.1716 0.675 0.5
#>
#> Class 2 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SEXFemale 1.8788 0.6307 0.2189 2.881 0.00402 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#>
#> Level 2 Coefficients :
#>
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SCH_LEVMiddle School 0.1420 -1.9522 0.4185 -4.665 3.33e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Class 2 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> SCH_LEVMiddle School 0.07687 -2.56558 0.59246 -4.33 1.57e-05 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
# }