A Boilerplate for EM algorithms¶
Description¶
EMfit
provides the boilerplate for EM algorithms and EMNR accelerated EM algorithms
(also known as the Louismethod of acceleration)
Usage¶
EMfit(psi.start, mk_cpl_data, ll_cpl, completeInfo, Jacobian, ...,
Mstep = Mstep.default, eps = 1e07, maxiter = 200,
maxiter.EM = maxiter, maxiter.inner = 25, Information = TRUE,
verbose = TRUE, verbose.inner = FALSE, show.psi = FALSE)
Arguments¶
psi.start

A numeric vector with starting values
mk_cpl_data

A function that creates the ‘complete data’ from the ‘observed’ data. Its return value can be anything that can be used by the other functions given as arguments. The return value can also have a component “weights”.
ll_cpl

A function that computes the completedata contributions to the loglikelihood. It should at least accept the arguments
psi
, the parameter vector, andcpl_data
, the completedata structure. It should return the completedata contributions to the loglikelihood, with an attributed named “i” that indicates unconditionally independent groups of observations. completeInfo

A function that computes the ‘completedata’ information matrix It should at least accept the arguments
psi
, the parameter vector,cpl_data
, the completedata structure, andweights
, which are weights determined e.g. by posterior probabilities and apriori weights. Jacobian

A function that computes the Jacobian of the loglikelihood function. It should return a matrix with the same number of rows as the length of the result of
ll_cpl
and the same number of colums as elements ofpsi
and should have an attribute named “i” that indicates unconditionally independent groups of observations. Mstep

A function that conducts the Mstep. It should accept the parameter vector as first argument, the completedata structure as second argument, a vector
wPPr
of posterior probabilities (weighted if applicable), and should accept anything that is passed via … eps

Numeric; a criterion for convergence
maxiter

Maximal number of iterations
maxiter.EM

Maximal number of iterations after which the algorithm should switch to NewtonRaphson steps
maxiter.inner

Maximal number of iterations for the Mstep
Information

Logical; should the observeddata information matrix be returned?
verbose

Logical; should an interation trace be displayed?
verbose.inner

Logical; should the iteration trace of the Mstep be displayed (if applicable)?
show.psi

Logical; should the current parameter value be displayed along with the iteration history?
...

Further arguments passed to
ll_cpl
,mk_cpl_data
, etc.
Value¶
A list with the following components:
 psi

The MLE of the parameter vector
 logLik

The maximized observeddata loglikelihood
 gradient

The gradient of the loglikelihood function
 cplInfo

The completedata information matrix
 missInfo

The missingdata information matrix
 obsInfo

The observeddata information matrix. Use this to compute standard errors.
 converged

A logical value, indicating whether the algorithm converged.
 psi.trace

A matrix which contains the parameter values for each iteration
 logLik.trace

A vector with the loglikelihood values of each iteration