This dataset includes 6 manifest items about abortion and several covariates from 355 respondents to the 2008 General Social Survey. Respondents answer the questions whether or not think it should be possible for a pregnant woman to obtain a legal abortion. The covariates include age, sex, race, region, and degree of respondents.
A data frame with 355 observations on 11 variables.
DEFECT
If there is a strong chance of serious defect in the baby?
HLTH
If the womans own health is seriously endangered by the pregnancy?
RAPE
If she became pregnant as a result of rape?
POOR
If the family has a very low income and cannot afford any more children?
SINGLE
If she is not married and does not want to marry the man?
NOMORE
If she is married and does not want any more children?
AGE
Respondent's age
SEX
Respondent's race
RACE
Respondent's sex
REGION
Region of interview
DEGREE
Respondent's degree
Smith, Tom W, Peter Marsden, Michael Hout, and Jibum Kim. General Social Surveys, 2008/Principal Investigator, Tom W. Smith; Co-Principal Investigator, Peter V. Marsden; Co-Principal Investigator, Michael Hout; Sponsored by National Science Foundation. -NORC ed.- Chicago: NORC at the University of Chicago
data("gss08")
# Model 1: LCA
lca = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
data = gss08, nclass = 3)
#> Manifest items :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#>
#> Deleted observation(s) :
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -687.4488
#> SET : 2 .....loglik : -687.4486
#> SET : 3 .....loglik : -687.4486
#> SET : 4 .....loglik : -687.4493
#> SET : 5 .....loglik : -687.4531
#> SET : 6 .....loglik : -687.4487
#> SET : 7 .....loglik : -687.4486
#> SET : 8 .....loglik : -694.8509
#> SET : 9 .....loglik : -687.4486
#> SET : 10 .....loglik : -687.4548
#>
#> Start with SET 9 (-687.4486)
#>
#> Latent class analysis Fitting...
#>
#> 60 iteration
#>
#> Converged at 60 iteration (loglik :-687.4486)
summary(lca)
#>
#> Call:
#> glca(formula = item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~
#> 1, data = gss08, nclass = 3)
#>
#> Manifest items : DEFECT HLTH RAPE POOR SINGLE NOMORE
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> DEFECT YES NO
#> HLTH YES NO
#> RAPE YES NO
#> POOR YES NO
#> SINGLE YES NO
#> NOMORE YES NO
#>
#> Model : Latent class analysis
#>
#> Number of latent classes : 3
#> Number of observations : 352
#> Number of parameters : 20
#>
#> log-likelihood : -687.4486
#> G-squared : 29.82695
#> AIC : 1414.897
#> BIC : 1492.17
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.46396 0.19138 0.34467
#>
#> Item-response probabilities (Y = 1) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 1.0000 1.0000 1.0000 0.9813 0.9284 0.9657
#> Class 2 0.0466 0.3684 0.0949 0.0000 0.0000 0.0000
#> Class 3 0.8275 0.9453 0.7960 0.0638 0.0390 0.1344
#>
#> Item-response probabilities (Y = 2) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.0000 0.0000 0.0000 0.0187 0.0716 0.0343
#> Class 2 0.9534 0.6316 0.9051 1.0000 1.0000 1.0000
#> Class 3 0.1725 0.0547 0.2040 0.9362 0.9610 0.8656
# Model 2: LCA with a covariate
lcr = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ SEX,
data = gss08, nclass = 3)
#> Manifest items :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Covariates (Level 1) :
#> SEX
#>
#> Deleted observation(s) :
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -680.7823
#> SET : 2 .....loglik : -686.7172
#> SET : 3 .....loglik : -680.7823
#> SET : 4 .....loglik : -680.7823
#> SET : 5 .....loglik : -691.2091
#> SET : 6 .....loglik : -680.7823
#> SET : 7 .....loglik : -680.7823
#> SET : 8 .....loglik : -680.7825
#> SET : 9 .....loglik : -680.7823
#> SET : 10 .....loglik : -680.8225
#>
#> Start with SET 7 (-680.7823)
#>
#> Latent class analysis Fitting...
#>
#> 72 iteration
#>
#> Converged at 72 iteration (loglik :-680.7823)
summary(lcr)
#>
#> Call:
#> glca(formula = item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~
#> SEX, data = gss08, nclass = 3)
#>
#> Manifest items : DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Covariates (Level 1) : SEX
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> DEFECT YES NO
#> HLTH YES NO
#> RAPE YES NO
#> POOR YES NO
#> SINGLE YES NO
#> NOMORE YES NO
#>
#> Model : Latent class analysis
#>
#> Number of latent classes : 3
#> Number of observations : 352
#> Number of parameters : 22
#>
#> log-likelihood : -680.7823
#> G-squared : 57.97919
#> AIC : 1405.565
#> BIC : 1490.564
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.34093 0.19486 0.46421
#>
#> Logistic regression coefficients :
#> Class 1/3 Class 2/3
#> (Intercept) -0.3958 -1.6024
#> SEXFEMALE 0.1766 1.1942
#> Item-response probabilities (Y = 1) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.8286 0.9464 0.8030 0.0640 0.0393 0.1356
#> Class 2 0.0581 0.3756 0.0922 0.0000 0.0000 0.0000
#> Class 3 1.0000 1.0000 1.0000 0.9812 0.9281 0.9656
#>
#> Item-response probabilities (Y = 2) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.1714 0.0536 0.1970 0.9360 0.9607 0.8644
#> Class 2 0.9419 0.6244 0.9078 1.0000 1.0000 1.0000
#> Class 3 0.0000 0.0000 0.0000 0.0188 0.0719 0.0344
coef(lcr)
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> (Intercept) 0.6732 -0.3958 0.1822 -2.172 0.0321 *
#> SEXFEMALE 1.1931 0.1766 0.2611 0.676 0.5003
#> ---
#> 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) 0.2014 -1.6024 0.3076 -5.209 9.53e-07 ***
#> SEXFEMALE 3.3010 1.1942 0.3512 3.400 0.000953 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
# Model 3: MGLCA
mglca = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
group = REGION, data = gss08, nclass = 3)
#> Manifest items :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Grouping variable : REGION
#>
#> Deleted observation(s) :
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -681.807
#> SET : 2 .....loglik : -667.0649
#> SET : 3 .....loglik : -667.0651
#> SET : 4 .....loglik : -680.7367
#> SET : 5 .....loglik : -667.065
#> SET : 6 .....loglik : -667.065
#> SET : 7 .....loglik : -680.8944
#> SET : 8 .....loglik : -667.0649
#> SET : 9 .....loglik : -667.0649
#> SET : 10 .....loglik : -667.065
#>
#> Start with SET 9 (-667.0649)
#>
#> Multiple-group latent class analysis Fitting...
#>
#> 70 iteration
#>
#> Converged at 70 iteration (loglik :-667.0649)
# Model 4: MGLCA with covariates
summary(mglca)
#>
#> Call:
#> glca(formula = item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~
#> 1, group = REGION, data = gss08, nclass = 3)
#>
#> Manifest items : DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Grouping variable : REGION
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> DEFECT YES NO
#> HLTH YES NO
#> RAPE YES NO
#> POOR YES NO
#> SINGLE YES NO
#> NOMORE YES NO
#>
#> Model : Multiple-group latent class analysis
#>
#> Number of latent classes : 3
#> Number of groups : 9
#> Number of observations : 352
#> Number of parameters : 36
#>
#> log-likelihood : -667.0649
#> G-squared : 149.4701
#> AIC : 1406.13
#> BIC : 1545.221
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.34554 0.18922 0.46524
#>
#> Class prevalences by group :
#> Class 1 Class 2 Class 3
#> NEW ENGLAND 0.71336 0.00000 0.28664
#> MIDDLE ATLANTIC 0.13706 0.15987 0.70307
#> E. NOR. CENTRAL 0.42665 0.10906 0.46428
#> W. NOR. CENTRAL 0.26556 0.21327 0.52117
#> SOUTH ATLANTIC 0.27324 0.30461 0.42216
#> E. SOU. CENTRAL 0.50597 0.35920 0.13484
#> W. SOU. CENTRAL 0.50605 0.25716 0.23679
#> MOUNTAIN 0.43191 0.14423 0.42386
#> PACIFIC 0.33324 0.12720 0.53956
#>
#> Item-response probabilities (Y = 1) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.8156 0.9441 0.7982 0.0624 0.0384 0.1321
#> Class 2 0.0513 0.3649 0.0737 0.0000 0.0000 0.0000
#> Class 3 1.0000 1.0000 1.0000 0.9806 0.9270 0.9656
#>
#> Item-response probabilities (Y = 2) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.1844 0.0559 0.2018 0.9376 0.9616 0.8679
#> Class 2 0.9487 0.6351 0.9263 1.0000 1.0000 1.0000
#> Class 3 0.0000 0.0000 0.0000 0.0194 0.0730 0.0344
mglcr = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ AGE,
group = SEX, data = gss08, nclass = 3)
#> Manifest items :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Grouping variable : SEX
#> Covariates (Level 1) :
#> AGE
#>
#> Deleted observation(s) :
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#>
#> SET : 1 .....loglik : -679.8355
#> SET : 2 .....loglik : -679.8356
#> SET : 3 .....loglik : -679.8357
#> SET : 4 .....loglik : -679.8355
#> SET : 5 .....loglik : -679.8364
#> SET : 6 .....loglik : -685.8839
#> SET : 7 .....loglik : -679.843
#> SET : 8 .....loglik : -679.8355
#> SET : 9 .....loglik : -679.8369
#> SET : 10 .....loglik : -680.2349
#>
#> Start with SET 4 (-679.8355)
#>
#> Multiple-group latent class analysis Fitting...
#>
#> 65 iteration
#>
#> Converged at 65 iteration (loglik :-679.8355)
summary(mglcr)
#>
#> Call:
#> glca(formula = item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~
#> AGE, group = SEX, data = gss08, nclass = 3)
#>
#> Manifest items : DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Grouping variable : SEX
#> Covariates (Level 1) : AGE
#>
#> Categories for manifest items :
#> Y = 1 Y = 2
#> DEFECT YES NO
#> HLTH YES NO
#> RAPE YES NO
#> POOR YES NO
#> SINGLE YES NO
#> NOMORE YES NO
#>
#> Model : Multiple-group latent class analysis
#>
#> Number of latent classes : 3
#> Number of groups : 2
#> Number of observations : 352
#> Number of parameters : 24
#>
#> log-likelihood : -679.8355
#> G-squared : 786.9738
#> AIC : 1407.671
#> BIC : 1500.398
#>
#> Marginal prevalences for latent classes :
#> Class 1 Class 2 Class 3
#> 0.33888 0.19715 0.46398
#>
#> Class prevalences by group :
#> Class 1 Class 2 Class 3
#> MALE 0.35677 0.11018 0.53305
#> FEMALE 0.32362 0.27130 0.40508
#>
#> Logistic regression coefficients :
#> Group : MALE
#> Class 1/3 Class 2/3
#> (Intercept) -0.6909 -1.2019
#> AGE 0.0061 -0.0081
#>
#> Group : FEMALE
#> Class 1/3 Class 2/3
#> (Intercept) -0.5227 -0.0198
#> AGE 0.0061 -0.0081
#>
#> Item-response probabilities (Y = 1) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.8392 0.9462 0.7997 0.0645 0.0398 0.1368
#> Class 2 0.0505 0.3854 0.1057 0.0000 0.0000 0.0000
#> Class 3 1.0000 1.0000 1.0000 0.9814 0.9283 0.9656
#>
#> Item-response probabilities (Y = 2) :
#> DEFECT HLTH RAPE POOR SINGLE NOMORE
#> Class 1 0.1608 0.0538 0.2003 0.9355 0.9602 0.8632
#> Class 2 0.9495 0.6146 0.8943 1.0000 1.0000 1.0000
#> Class 3 0.0000 0.0000 0.0000 0.0186 0.0717 0.0344
coef(mglcr)
#> Coefficients :
#>
#> Class 1 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> AGE 1.006069 0.006050 0.003584 1.688 0.0924 .
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Class 2 / 3 :
#> Odds Ratio Coefficient Std. Error t value Pr(>|t|)
#> AGE 0.991883 -0.008150 0.005049 -1.614 0.107
#>