mixBinom: EM algorithm for estimating binomial mixture model

View source: R/binomial_models.R

mixBinomR Documentation

EM algorithm for estimating binomial mixture model

Description

EM algorithm for estimating binomial mixture model

Usage

mixBinom(
  k,
  n,
  n_components = 2,
  p_init = NULL,
  learn_p = TRUE,
  min_iter = 10,
  max_iter = 1000,
  logLik_threshold = 1e-05
)

Arguments

k

A vector of integers. number of success

n

A vector of integers. number of trials

n_components

A number. number of components

p_init

A vector of floats with length n_components, the initial value of p

learn_p

bool(1) or a vector of bool, whether learn each p

min_iter

integer(1). number of minimum iterations

max_iter

integer(1). number of maximum iterations

logLik_threshold

A float. The threshold of logLikelihood increase for detecting convergence

Value

a list containing p, a vector of floats between 0 and 1 giving the estimated success probability for each component, psi, estimated fraction of each component in the mixture, and prob, the matrix of fitted probabilities of each observation belonging to each component.

Examples

n1 <- array(sample(1:30, 50, replace = TRUE))
n2 <- array(sample(1:30, 200, replace = TRUE))
k1 <- apply(n1, 1, rbinom, n = 1, p = 0.5)
k2 <- apply(n2, 1, rbinom, n = 1, p = 0.01)
RV <- mixBinom(c(k1, k2), c(n1, n2))

PMBio/cardelino documentation built on Nov. 21, 2022, 4:52 a.m.