small.em: Carry out several short EM fits to test for optimal starting...

Description Usage Arguments Value Examples

Description

Carry out several short EM fits to test for optimal starting locations.

Usage

1
2
3
4
small.em(x, y, b.init = "fit", weight = c(1), K = 2, maxiter = 5,
  tol.1 = 1e-04, tol.2 = 1e-04, noise = 0.2, sample.size = 500,
  repeats = 5, debug = FALSE, family = "poisson",
  method = "numeric", maxiter.NR = 20)

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.

maxiter

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

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.

sample.size

Number of cases to randomly select from the input data.

repeats

Number of repetitions of the initialization to make.

debug

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

family

GLM family to fit.

method

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

maxiter.NR

Maximum number of Newton-Raphson steps to take.

Value

A 'small.em' list containing the parameters, weights, log likelihood and BIC values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- model.matrix(~ factor(wool) + factor(tension), warpbreaks)
y <- warpbreaks$breaks

warm_up <- small.em(x = x, y = y, K = 2, b.init = "random", sample.size = 50)
summary(warm_up)

params <- select_best(warm_up)

m <- em.glm(x = x, y = y, K = 2, b.init = params)
summary(m)

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