Learn R Programming

imputeMulti (version 0.4.5)

multinomial_em: EM algorithm for multinomial data

Description

Implement the EM algorithm for multvariate multinomial data given observed counts of complete and missing data ($Y_obs$ and $Y_mis$). Allows for specification of a Dirichlet conjugate prior.

Usage

multinomial_em(x_y, z_Os_y, enum_comp, n_obs, conj_prior = c("none",
  "data.dep", "flat.prior", "non.informative"), alpha = NULL, tol = 5e-07,
  max_iter = 10000, verbose = FALSE)

Arguments

x_y
A data.frame of observed counts for complete observations.
z_Os_y
A data.frame of observed marginal-counts for incomplete observations.
enum_comp
A data.frame specifying a vector of all possible observed patterns.
n_obs
An integer specifying the number of observations in the original data.
conj_prior
A string specifying the conjugate prior. One of c("none", "data.dep", "flat.prior", "non.informative").
alpha
The vector of counts $\alpha$ for a $Dir(\alpha)$ prior. Must be specified if conj_prior is either c("data.dep", "flat.prior"). If flat.prior, specify as a scalar. If data.dep, specify as a vector with
tol
A scalar specifying the convergence criteria. Defaults to 5e-7
max_iter
An integer specifying the maximum number of allowable iterations. Defaults to 10000.
verbose
Logical. If TRUE, provide verbose output on each iteration.

Value

See Also

multinomial_data_aug, multinomial_impute

Examples

Run this code
data(tract2221)
 x_y <- multinomial_stats(tract2221[,1:4], output= "x_y")
 z_Os_y <- multinomial_stats(tract2221[,1:4], output= "z_Os_y")
 x_possible <- multinomial_stats(tract2221[,1:4], output= "possible.obs")

 imputeEM_mle <- multinomial_em(x_y, z_Os_y, x_possible, n_obs= nrow(tract_2221),
                     conj_prior= "none", verbose= TRUE)

Run the code above in your browser using DataLab