latentFactor | R Documentation |
A latent factor is a categorical variable whose values are entirely
missing. The function latentFactor
provides a convenient way to
create a latent factor with a given number of base levels, which is
useful for latent-class modeling with cvam
.
latentFactor( n, levels = 2L ) is.latentFactor(x)
n |
length of the factor |
levels |
either an integer specifying the number of base levels, or a character vector containing labels for the base levels |
x |
an object to be tested |
For latentFactor
, a latent coarsened factor of length
n
; for is.latentFactor
, TRUE
or FALSE
.
Joe Schafer Joseph.L.Schafer@census.gov
For more information, refer to the package vignettes Understanding Coarsened Factors in cvam and Log-Linear Modeling with Missing and Coarsened Values Using the cvam Package.
cvam
,
coarsened
,
baseLevels
,
is.naCoarsened
# fit latent class model to hivtest data hivtest$L <- latentFactor( NROW(hivtest), 2 ) set.seed(125) fit <- cvam( ~ L*A + L*B + L*C + L*D, data=hivtest, freq=COUNT, control=list(startValJitter=.1) ) cvamEstimate( list( ~L, ~A|L, ~B|L, ~C|L, ~D|L ), fit )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.