Learn R Programming

BinaryReplicates (version 1.0.0)

EMFit: Compute the Maximum-A-Posteriori estimate with the EM algorithm

Description

Compute the Maximum-A-Posteriori estimate with the EM algorithm

Usage

EMFit(
  ni,
  si,
  ti = NULL,
  prior = list(a_FP = 2, b_FP = 2, a_FN = 2, b_FN = 2),
  N_init = 20,
  maxIter = 1000,
  errorMin = 1e-07
)

Value

A list with the following components:

score

The estimated values of the scores

parameters_hat

The estimated values of the parameters \(\theta\), \(p\) and \(q\)

Arguments

ni

Numeric vector of \(n_i\)'s, the total numbers of replicates for each individual

si

Numeric vector of \(s_i\)'s, the numbers of replicates equal to 1 for each individual

ti

Numeric vector of \(t_i\)'s, the true values of the binary variable for each individual. If NULL, the EM algorithm is used to estimate the parameters. Defaults to NULL. See details.

prior

A list of prior parameters for the model. The prior distribution is as follows:

  • The false positive rate: \(p \sim \text{Beta}(a_{FP}, b_{FP})\)

  • The false negative rate: \(q \sim \text{Beta}(a_{FN}, b_{FN})\)

N_init

The number of initializations if ti is not provided. Defaults to 20.

maxIter

The maximum number of iterations if the EM algorithm is used. Defaults to 1e3.

errorMin

The minimum error for convergence if the EM algorithm is used. Defaults to 1e-7.

Details

This function chooses its algorithm according to what is provided in the ti argument:

ti is fully provided

The function computes the Maximum-A-Posteriori estimate, with an explicit formula.

ti is not provided

The function uses the EM algorithm to estimate the parameters.

ti is partially provided

The function uses the EM algorithm to estimate the parameters.

See Also

classify_with_scores

Examples

Run this code
data("periodontal")
# Get ML estimate knowing the true values of the latent ti's
periodontal_ml <- EMFit(periodontal$ni, periodontal$si, periodontal$ti)
# Get MAP estimate without knowing the true values of the latent ti's
periodontal_EM <- EMFit(periodontal$ni, periodontal$si, ti = NULL)

Run the code above in your browser using DataLab