Data frame or matrix of 0 and 1 defining the outcome patterns. May also include missing values, with randomLCA using maximum likelihood to fit the models using all available data.
freq
Frequency for each outcome pattern, if missing this is calculated from the patterns, and the patterns are summarised to remove duplicate values.
nclass
Number of classes to be fitted
calcSE
Calculate standard errors for parameters. Useful for bootstrapping.
notrials
For a standard latent class model, the number of random starting values used
random
Include random effect?
byclass
Vary random effect loading(s) by class?
quadpoints
Number of quadrature points for adaptive quadrature
constload
Outcome loadings are constant for random effects model?
blocksize
Where a random effects (single level) model is broken into blocks, that is the loadings are repeated, this defines the size of the blocks
probit
Probit model for random effect?
level2
Fit 2 level random effects model (further details to follow)?
level2size
Size of level 2 blocks if fitting 2 level models
qniterations
Number of Quasi-Newton iterations within each EM/adaptive cycle. Decrease if there is a failure to converge
penalty
penalty applied to likelihood for outcome probabilities. Shrinks outcome probabilities in slightly and can prevent extreme values. Setting penalty to 0 will produce an unpenalized fit.
verbose
Prints fit progress if true
seed
Initial random seed for generating starting values. This can be set to guarantee that the fit is the same each time, including the order of the classes.
Details
The structure of the patterns is assumed to be a number of blocks of different outcomes each of level2size, allowing outcomes to be repeated. Each outcome is assumed to have it's own loading.
An example is the width of the patterns is n and the level2size is n, resulting in n outcomes and therefore n loadings. Alternatively if the level2size is 1, then there are n repeats of the same outcome (but with different probabilities) with the same loading. In practice they may not be the same type of outcome, but usually will be.
The algorithm used is EM for the standard latent class and adaptive (in the sense of moving the location of the quadrature points) Gauss-Hermite quadrature for the random effects models. The number of quadrature points defaults to 21.
Value
randomLCA object
This contains
fit
Fit object from optim
nclass
Number of classes
classp
Class probabilities
outcomep
Outcome probability
lambdacoef
Loadings
se
Standard errors corresponding to results returned by optim
np
Number of parameters
nobs
Number of observations in total
logLik
log likelihood for fitted model
penlogLik
Penalised log likelihood for fitted model
observed
Observed numbers corresponding to each pattern
fitted
Fitted number corresponding to each pattern
deviance
Deviance
classprob
Posterior class probability for each pattern
bics
BIC obtained for each trial when fitting initial latent class models
call
call to randomLCA
random
random parameter to randomLCA
constload
constload parameter to randomLCA
level2
level2 parameter to randomLCA
level2size
level2size parameter to randomLCA
byclass
byclass parameter to randomLCA
probit
probit parameter to randomLCA
quadpoints
quadpoints parameter to randomLCA
blocksize
blocksize parameter to randomLCA
freq
frequency of each pattern
qniterations
qniterations parameter to randomLCA
penalty
penalty parameter to randomLCA
Note
In the returned object there a fields for patterns and frequencies. If frequencies are not supplied then the patterns and frequencies are constructed. If frequencies are supplied then zero rows are removed. When frequencies are supplied it is assumed that the data has been simplified. The returned fitted, posterior class probabilities etc, all correspond to the simplified patterns, not to the original data.
Author(s)
Ken Beath
Examples
## Not run:
# standard latent class with 2 classes
dentistry.lca2 <- randomLCA(dentistry[,1:5],freq=dentistry$freq,nclass=2)
# random effects model with constant random effect loading
dentistry.lca2random <- randomLCA(dentistry[,1:5],freq=dentistry$freq,
nclass=2,random=TRUE,constload=TRUE,probit=TRUE)
# allow loading to vary by dentist
# this is the 2LCR model from Qu et al (1996)
dentistry.lca2random1 <- randomLCA(dentistry[,1:5],freq=dentistry$freq,
nclass=2,random=TRUE,constload=FALSE,probit=TRUE)
## End(Not run)