mmlcr                 package:mmlcr                 R Documentation

_M_i_x_e_d _M_o_d_e _L_a_t_e_n_t _C_l_a_s_s _R_e_g_r_e_s_s_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     This function fits a latent class regression model, where the
     responses may be of different types, as well as longitudinal or
     time-invariant.

_U_s_a_g_e:

     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, ...)

_A_r_g_u_m_e_n_t_s:

   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.

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     a fitted 'mmlcrObject'

_S_e_e _A_l_s_o:

     'mmlcrObject', 'mmlcrcomponentinit',  'summary.mmlcr',
     'plot.mmlcr'

_E_x_a_m_p_l_e_s:

     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)

