EMbinom: Fit mixture of two binomial distributions using EM.

Description Usage Arguments Details Value

Description

Function to estimate the parameters of a mixture of two binomial distributions using the Expectation-Maximization algorithm (EM). Can be used in a setting where the data contains V independent observations. Each of these is a realization of a binomial data generating process with the probability of success (out of N trials) being either π 1 or π 2.

Usage

1
EMbinom(Y, N, iniL, iniPI1, iniPI2, max.iter = 500, tolerance = 0.001)

Arguments

Y

vector of length V with the observed data (number of successes)

N

the amount of trials

iniL

initial value for λ

iniPI1

initial value for π 1

iniPI2

initial value for π 2

max.iter

maximum iterations (optional)

tolerance

level of tolerance when comparing the likelihood of previous and current step in the algorithm (optional). Convergence is assumed when the absolute difference between both log likelihoods is smaller than the tolerance level.

Details

Assume Y is i.i.d. from

λ P1(Y;k, π 1) + (1 - λ) P2(Y;k,π 2)

The complete log-likelihood of the data over all observations (V) is then given as:

cst + ∑_{v = 1}^V log(λ(π 1)^Y(v) (1 - π 1)^(N - Y(v)) + (1 - λ)(π 2)^Y(v) (1 - π 2)^(N - Y(v)))

The EM algorithm is then used to estimate λ, π 1 and π 2.

Note on starting values: it is not advised to use the same values for the starting values of π 1 and π 2 as the algorithm does not seem to handle this setting very well. Starting values far away from the true value do converge to the true value most of the time, but take more iterations.

Value

Data frame with the parameter estimates and the number of iterations after convergence


NeuroStat/NeuRRoStat documentation built on May 15, 2019, 1:26 p.m.