poLCA.predcell: Predicted cell percentages in a latent class model

Description Usage Arguments Details Value See Also Examples

View source: R/poLCA.predcell.R

Description

Calculates the predicted cell percentages from a latent class model, for specified values of the manifest variables.

Usage

1

Arguments

lc

A model object estimated using the poLCA function.

y

A vector or matrix containing series of responses on the manifest variables in lc.

Details

The parameters estimated by a latent class model can be used to produce a density estimate of the underlying probability mass function across the cells in the multi-way table of manifest variables. This function calculates cell percentages for that density estimate, corresponding to selected sets of responses on the manifest variables, y.

Value

A vector containing cell percentages corresponding to the specified sets of responses y, based on the estimated latent class model lc.

See Also

poLCA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(carcinoma)
f <- cbind(A,B,C,D,E,F,G)~1
lca3 <- poLCA(f,carcinoma,nclass=3) # log-likelihood: -293.705

# Only 20 out of 32 possible response patterns are observed
lca3$predcell

# Produce cell probabilities for one sequence of responses
poLCA.predcell(lc=lca3,y=c(1,1,1,1,1,1,1))

# Estimated probabilities for a cell with zero observations
poLCA.predcell(lc=lca3,y=c(1,1,1,1,1,1,2))

# Cell probabilities for both cells at once; y entered as a matrix
poLCA.predcell(lc=lca3,y=rbind(c(1,1,1,1,1,1,1),c(1,1,1,1,1,1,2)))

Example output

Loading required package: scatterplot3d
Loading required package: MASS
Conditional item response (column) probabilities,
 by outcome variable, for each class (row) 
 
$A
           Pr(1)  Pr(2)
class 1:  0.4872 0.5128
class 2:  0.0000 1.0000
class 3:  0.9427 0.0573

$B
           Pr(1)  Pr(2)
class 1:  0.0000 1.0000
class 2:  0.0191 0.9809
class 3:  0.8621 0.1379

$C
           Pr(1)  Pr(2)
class 1:  1.0000 0.0000
class 2:  0.1425 0.8575
class 3:  1.0000 0.0000

$D
           Pr(1)  Pr(2)
class 1:  0.9424 0.0576
class 2:  0.4138 0.5862
class 3:  1.0000 0.0000

$E
           Pr(1)  Pr(2)
class 1:  0.2494 0.7506
class 2:  0.0000 1.0000
class 3:  0.9449 0.0551

$F
           Pr(1)  Pr(2)
class 1:  1.0000 0.0000
class 2:  0.5236 0.4764
class 3:  1.0000 0.0000

$G
           Pr(1)  Pr(2)
class 1:  0.3693 0.6307
class 2:  0.0000 1.0000
class 3:  1.0000 0.0000

Estimated class population shares 
 0.1817 0.4447 0.3736 
 
Predicted class memberships (by modal posterior prob.) 
 0.1949 0.4322 0.3729 
 
========================================================= 
Fit for 3 latent classes: 
========================================================= 
number of observations: 118 
number of estimated parameters: 23 
residual degrees of freedom: 95 
maximum log-likelihood: -293.705 
 
AIC(3): 633.41
BIC(3): 697.1357
G^2(3): 15.26171 (Likelihood ratio/deviance statistic) 
X^2(3): 20.50335 (Chi-square goodness of fit) 
 
   A B C D E F G observed expected
1  1 1 1 1 1 1 1       34   33.849
2  1 1 1 1 2 1 1        2    1.973
3  1 2 1 1 1 1 1        6    6.323
4  1 2 1 1 1 1 2        1    1.548
5  1 2 1 1 2 1 1        4    3.045
6  1 2 1 1 2 1 2        5    4.660
7  2 1 1 1 1 1 1        2    2.058
8  2 1 2 1 2 1 2        1    0.186
9  2 2 1 1 1 1 1        2    1.284
10 2 2 1 1 1 1 2        1    1.630
11 2 2 1 1 2 1 1        2    2.892
12 2 2 1 1 2 1 2        7    6.494
13 2 2 1 1 2 2 2        1    1.446
14 2 2 1 2 1 1 2        1    0.100
15 2 2 1 2 2 1 2        2    2.552
16 2 2 1 2 2 2 2        3    2.049
17 2 2 2 1 2 1 2       13    9.563
18 2 2 2 1 2 2 2        5    8.701
19 2 2 2 2 2 1 2       10   13.550
20 2 2 2 2 2 2 2       16   12.328
          [,1]
[1,] 0.2868564
             [,1]
[1,] 7.196555e-22
             [,1]
[1,] 2.868564e-01
[2,] 7.196555e-22

poLCA documentation built on May 29, 2017, 5:59 p.m.