logisregmixEM            package:mixtools            R Documentation

_E_M _A_l_g_o_r_i_t_h_m _f_o_r _M_i_x_t_u_r_e_s _o_f _L_o_g_i_s_t_i_c _R_e_g_r_e_s_s_i_o_n_s

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

     Returns EM algorithm output for mixtures of logistic regressions
     with arbitrarily many components.

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

     logisregmixEM(y, x, N = NULL, lambda = NULL, beta = NULL, k = 2,
                   addintercept = TRUE, epsilon = 1e-08, 
                   maxit = 10000, verb = FALSE)

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

       y: An n-vector of successes out of N trials.

       x: An nxp matrix of predictors.  See 'addintercept' below.

       N: An n-vector of number of trials for the logistic regression. 
           If NULL, then 'N' is an n-vector of 1s for binary logistic
          regression.

  lambda: Initial value of mixing proportions.  Entries should sum to
          1.  This determines number of components.  If NULL, then
          'lambda' is random from uniform Dirichlet and number of
          components is determined by 'beta'.

    beta: Initial value of 'beta' parameters.  Should be a pxk matrix,
          where p is the number of columns of x and k is number of
          components. If NULL, then 'beta' is generated by binning the
          data into k bins and using 'glm' on the values in each of the
          bins.  If both 'lambda' and 'beta' are NULL, then  number of
          components is determined by 'k'.

       k: Number of components.  Ignored unless 'lambda' and 'beta' are
          both NULL.

addintercept: If TRUE, a column of ones is appended to the x matrix
          before the value of p is calculated.

 epsilon: The convergence criterion.

   maxit: The maximum number of iterations.

    verb: If TRUE, then various updates are printed during each
          iteration of the algorithm.

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

     'logisregmixEM' returns a list of class 'mixEM' with items: 

       x: The predictor values.

       y: The response values.

  lambda: The final mixing proportions.

    beta: The final logistic regression coefficients.

  loglik: The final log-likelihood.

posterior: An nxk matrix of posterior probabilities for observations.

all.loglik: A vector of each iteration's log-likelihood.

restarts: The number of times the algorithm restarted due to
          unacceptable choice of initial values.

      ft: A character vector giving the name of the function.

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

     McLachlan, G. J. and Peel, D. (2000) _Finite Mixture Models_, John
     Wiley & Sons, Inc.

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

     'poisregmixEM'

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

     ## EM output for data generated from a 2-component logistic regression model.

     beta<-matrix(c(1, .5, 2, -.8), 2, 2)
     x<-runif(50, 0, 10)
     x1<-cbind(1, x)
     xbeta<-x1%*%beta
     N<-ceiling(runif(50, 50, 75))
     w<-rbinom(50, 1, .3)
     y<-w*rbinom(50, size = N, prob = (1/(1+exp(-xbeta[, 1]))))+
                 (1-w)*rbinom(50, size = N, prob = 
                 (1/(1+exp(-xbeta[, 2]))))
     out.1<-logisregmixEM(y, x, N, verb = TRUE, epsilon = 1e-01)
     out.1

     ## EM output for data generated from a 2-component binary logistic regression model.

     beta<-matrix(c(-10, .1, 20, -.1), 2, 2)
     x<-runif(500, 50, 250)
     x1<-cbind(1, x)
     xbeta<-x1%*%beta
     w<-rbinom(500, 1, .3)
     y<-w*rbinom(500, size = 1, prob = (1/(1+exp(-xbeta[, 1]))))+
                 (1-w)*rbinom(500, size = 1, prob = 
                 (1/(1+exp(-xbeta[, 2]))))
     out.2<-logisregmixEM(y, x, beta = beta, lambda = c(.3, .7), 
                          verb = TRUE, epsilon = 1e-01)
     out.2

