em.glm: Expectation Maximization glm.

Description Usage Arguments Details Value References Examples

Description

Fit an Expectation Maximization glm using the glm family to define the link function. Two methods of optimization are included, using direct numeric approximations and using the pracma package to find the Hessian and Jacobian of the log-likelihood. The number of competing models to be fit is set by K.

Usage

1
2
3
4
em.glm(x, y, b.init = "random,", weight = c(1), K = 2,
  family = poisson, method = "numeric", maxiter = 50,
  maxiter.NR = Inf, tol.1 = 1e-08, tol.2 = 1e-08, noise = 0.2,
  debug = FALSE, param_errors = FALSE)

Arguments

x

An n-by-p design matrix.

y

A vector of observation of length n.

b.init

The method to initialize EM parameters. Built in methods are "random" and "fit" for pure white noise, and white noise around GLM estimates. Alternatively, pass a list of length K, each element consisting of a vector of length p. Users can also pass a zero-argument function to produce starting states.

weight

A n length vector of observation weight terms. This is currently designed to be either the exposure for a Poisson model or the number of trials for a Logistic model.

K

Number of EM classes to be fit.

family

GLM family to fit.

method

Control string. Set to 'numeric' or 'pracma'.

maxiter

Maximum number of re-weighting rounds to do in fitting the EM model. Primarily used to perform the 'small.em' warm-up routine.

maxiter.NR

Maximum number of Newton-Raphson steps to take.

tol.1

Escape tolerance of the Newton-Raphson step.

tol.2

Escape tolerance of the re-weighting step.

noise

Standard deviation of the white noise to be applied when generating random initial states.

debug

Returns step-size in NR and re-weighting steps as a message if TRUE.

param_errors

Bool flag - set to TRUE to calculate parameter errors.

Details

It is recommend users first call the em.small command to run small warm up trails to explore the parameter space.

Value

An 'em.glm' object containing the class parameters, and class weights.

References

Zeileis et al (2008) Regression Models for Count Data in R <doi:10.18637/jss.v027.i08>

Hastie et al (2009) The Elements of Statistical Learning Chapter 8.5 The EM Algorithm (2nd edition) <doi:10.1007/978-0-387-21606-5_7>

Jeff Bilmes (1998) A Gentle Tutorial of the EM Algorithm and its Application to Parameter Estimation for Gaussian Mixture and Hidden Markov Models

Dempster et al (1977) Maximum Likelihood from Incomplete Data via the EM Algorithm

Examples

1
2
3
4
x <- model.matrix(~ factor(wool) + factor(tension), warpbreaks)
y <- warpbreaks$breaks
m <- em.glm(x = x, y = y, K = 2, b.init = "random")
summary(m)

emax.glm documentation built on July 4, 2019, 5:04 p.m.