mmlcr {mmlcr} | R Documentation |
This function fits a latent class regression model, where the responses may be of different types, as well as longitudinal or time-invariant.
mmlcr(object = NULL, ...) ## Default S3 method: mmlcr(object = NULL, outer, components, data = error("data must be given (as a data.frame)"), subset, n.groups = 2, prior.prob = NULL, post.prob = NULL, no.fit = FALSE, max.iter = 50, trace = TRUE, tol = 0.005, ...) ## S3 method for class 'mmlcr': mmlcr(object, max.iter = 50, trace = TRUE, tol = 0.005, ...)
outer |
a formula of the form ~ predictors | id where the model statement for predictors is
as for regression models and id is the subject factor. The expression 1 can be used
for the predictors when there is no other suitable candidate.
|
components |
a list of the response components. Each element of the list is itself a list.
At a minimum, that list consists of a formula of the form resp ~ covars , where resp is the
response variable for that component and covars are any additional
covariates (resp ~ 1 is commonly used, or something like resp ~ age for longitudinal classes),
and a class. Implemented classes include
cnormlong , cnormonce , multinomlong , multinomonce , nb1long , nblong , nbonce ,
normlong , normonce , poislong , and poisonce . Some classes require additional list
elements. Details can be found with the mmlcrcomponentinit help files.
|
data |
a data frame in which to interpret the variables occurring in outer and in the formulas for the individual components. |
subset |
expression giving which subset of the rows of the data should be used in the fit. All observations are included by default. |
n.groups |
the number of latent classes. |
prior.prob |
a data.frame giving the prior probabilities of class membership according to covariate information, not ``prior knowledge.'' The row.names should match the subject id given in outer. If no value is given, which is recommended, the default is equal probabilities. |
post.prob |
a data.frame giving the posterior probabities of class membership. The row.names
should match the subject id given in outer. If post.prob is not given, starting values
are assigned randomly. If one is fitting a modification of a prior fit called fit1 ,
perhaps by changing the covariates, the recommendation is to include the term
post.prob = fit1$post.prob .
|
no.fit |
if TRUE, returns a mmlcrObject without fitting. The mmlcrObject
could be fit later by a call to mmlcr(mmlcrObject) .
|
object |
an mmlcr object. See the mmlcrObject help file for details.
|
max.iter |
the maximum number of iterations |
trace |
if TRUE, traces through the iterations, giving the loglikelihood, a convergence speed index, the loglikelihood goal, and the current class percentages. |
tol |
the tolerance between the loglikelihood and the loglikelihood goal, used as a stopping criterion. |
... |
possible additional arguments. |
The components portion of the call refers to components of the response, not components in the sense, used in much of the mixtures literature, that is here called latent classes or groups.
It is not yet possible to specify a prior, or even starting values, for the parameters of the individual latent classes. Instead, one can assign starting values to the posterior probabilities of each individual via the post.prob part of the function call.
In a typical use of this package, one might want to model, say, alcohol use. The idea is that there may be several model trajectories over the years, such as little or no use, heavy use, adolescent-limited use, and so on. For each class, we would like to model a different longitudinal regression (i.e., the same form for the regression, but different coefficients for each latent class). Furthermore, we would like to include covariates for class membership, so that the model looks like
Covariates ==> Latent Class ==> Longitudinal Trajectory,
with the regression coefficients on the right independent of the covariates on the left conditional on class membership. One could potentially have a number of arrows leading off of the latent class, so that one could simultaneously model cigarette and alcohol use, for example. The first arrow is modeled with the outer formula, which the second arrow is modeled with the formula(s) in the component term.
a fitted mmlcrObject
mmlcrObject
, mmlcrcomponentinit
,
summary.mmlcr
, plot.mmlcr
data(mmlcrdf) mmlcrdf.mmlcr2 <- mmlcr(outer = ~ sex + cov1 | id, components = list( list(formula = resp1 ~ 1, class = "cnormonce", min = 0, max = 50), list(formula = resp2 ~ poly(age, 2) + tcov1, class = "poislong"), list(formula = resp3 ~ poly(age, 2), class = "multinomlong") ), data = mmlcrdf, n.groups = 2) mmlcrdf.mmlcr2.inter <- mmlcr(outer = ~ sex * cov1 | id, components = list( list(formula = resp1 ~ 1, class = "cnormonce", min = 0, max = 50), list(formula = resp2 ~ poly(age, 2) + tcov1, class = "poislong"), list(formula = resp3 ~ poly(age, 2), class = "multinomlong") ), data = mmlcrdf, n.groups = 2, post.prob = mmlcrdf.mmlcr2$post.prob, no.fit = TRUE) mmlcrdf.mmlcr2.inter <- mmlcr(mmlcrdf.mmlcr2.inter)