Learn R Programming

mixtools (version 2.0.0)

poisregmixEM: EM Algorithm for Mixtures of Poisson Regressions

Description

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

Usage

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

Value

poisregmixEM returns a list of class mixEM with items:

x

The predictor values.

y

The response values.

lambda

The final mixing proportions.

beta

The final Poisson 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.

Arguments

y

An n-vector of response values.

x

An nxp matrix of predictors. See addintercept below.

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.

References

McLachlan, G. J. and Peel, D. (2000) Finite Mixture Models, John Wiley and Sons, Inc.

Wang, P., Puterman, M. L., Cockburn, I. and Le, N. (1996) Mixed Poisson Regression Models with Covariate Dependent Rates, Biometrics, 52(2), 381--400.

See Also

logisregmixEM

Examples

Run this code
## EM output for data generated from a 2-component model.

set.seed(100)
beta <- matrix(c(1, .5, .7, -.8), 2, 2)
x <- runif(50, 0, 10)
xbeta <- cbind(1, x)%*%beta
w <- rbinom(50, 1, .5)
y <- w*rpois(50, exp(xbeta[, 1]))+(1-w)*rpois(50, exp(xbeta[, 2]))
out <- poisregmixEM(y, x, verb = TRUE,  epsilon = 1e-03)
out

Run the code above in your browser using DataLab