flexmix               package:flexmix               R Documentation

_F_l_e_x_i_b_l_e _M_i_x_t_u_r_e _M_o_d_e_l_i_n_g

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

     FlexMix implements a general framework for finite mixtures of
     regression models. Parameter estimation is performed using the EM
     algorithm: the E-step is implemented by 'flexmix', while the user
     can specify the M-step.

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

     flexmix(formula, data = list(), k = NULL, cluster = NULL,
             model=NULL, control = NULL)
     ## S4 method for signature 'flexmix':
     summary(object, eps=1e-4, ...)

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

 formula: A symbolic description of the model to be fit. The general
          form is 'y~x|g' where 'y' is the response, 'x' the set of
          predictors and 'g' an optional grouping factor for repeated
          measurements.

    data: An optional data frame containing the variables in the model.

       k: Number of clusters (not needed if 'cluster' is specified).

 cluster: Factor or integer vector with the initial cluster assignments
          of observations at the  start of the EM algorithm (default is
          random assignment into 'k' clusters).

   model: Object of 'FLXmodel' of list of 'FLXmodel' objects. Default
          is the object returned by calling 'FLXglm()'.

 control: Object of class 'FLXcontrol' or a named list.

  object: Object of class 'flexmix'.

     eps: Probabilities below this treshold are treated as zero in the
          summary method.

     ...: Currently not used.

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

     FlexMix models are described by objects of class 'FLXmodel', which
     in turn are created by driver functions like 'FLXglm' or
     'FLXmclust'. Multivariate responses with independent components
     can be specified using a list of 'FLXmodel' objects.

     The 'summary' method lists for each component the prior
     probability, the number of observations assigned to the
     corresponding cluster, the number of observations with a posterior
     probability larger than 'eps' and the ratio of the latter two
     numbers (which indicates how separated the cluster is from the
     others).

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

     Returns an object of class 'flexmix'.

_A_u_t_h_o_r(_s):

     Friedrich Leisch

_R_e_f_e_r_e_n_c_e_s:

     Friedrich Leisch. FlexMix: A general framework for finite mixture
     models and latent class regression in R. Journal of Statistical
     Software, 11(8), 2004. http://www.jstatsoft.org/v11/i08/

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

     data(NPreg)

     ## mixture of two linear regression models. Note that control parameters
     ## can be specified as named list and abbreviated if unique.
     ex1 <- flexmix(yn~x+I(x^2), data=NPreg, k=2,
                        control=list(verb=5, iter=100))

     ex1
     summary(ex1)
     plot(ex1)

     ## now we fit a model with one Gaussian response and one Poisson
     ## response. Note that the formulas inside the call to FLXglm are
     ## relative to the overall model formula.
     ex2 <- flexmix(yn~x, data=NPreg, k=2,
                    model=list(FLXglm(yn~.+I(x^2)), 
                               FLXglm(yp~., family="poisson")))
     plot(ex2)

     ex2
     table(ex2@cluster, NPreg$class)

     ## for Gaussian responses we get coefficients and standard deviation
     parameters(ex2, component=1, model=1)

     ## for Poisson response we get only coefficients
     parameters(ex2, component=1, model=2)

     ## fitting a model only to the Poisson response is of course
     ## done like this
     ex3 <- flexmix(yp~x, data=NPreg, k=2, model=FLXglm(family="poisson"))

     ## if observations are grouped, i.e., we have several observations per
     ## individual, fitting is usually much faster:
     ex4 <- flexmix(yp~x|id1, data=NPreg, k=2, model=FLXglm(family="poisson"))

