em: Expectation-Maximization estimation of a finite mixture model

Description Usage Arguments Details Value References See Also Examples

View source: R/em.R

Description

em returns points estimations of the parameters of a finite mixture model using the Expectation-Maximization (E-M) algorithm.

Usage

1
em(data, D1, D2, t = 1e-64)

Arguments

data

A vector of real numbers, the data to model with a finite mixture model.

D1, D2

Probability distributions constituting the finite mixture model. See Details.

t

A numerical scalar indicating the value below which the E-M algorithm should stop.

Details

The finite mixture model considered in this function is a mixture of two probability distributions that are one of the following: normal, log-normal, gamma or Weibull. Each of these distributions is defined by two parameters: a location and a scale parameter:

location scale
normal mean sd
log-normal meanlog sdlog
gamma shape rate
Weibull shape scale

These parameters, together with the mixture parameter, are estimated by the Expection-Maximization algorithm.

Value

A list with class em containing the following components:

lambda

a numerical vector of length length(data) containing, for each datum, the probability to belong to distribution D1.

param

the location (mu) and scale (sigma) parameters of the probability distributions D1 and D2.

mu2 and lambda2.

References

Chuong B. Do and Serafim Batzoglou (2008) What is the expectation maximization algorithm? Nature Biotechnology 26(8): 897-899.

Peter Schlattmann (2009) Medical Applications of Finite Mixture Models. Springer-Verlag, Berlin.

See Also

confint.em method for calculating the confidence intervals of the parameters and cutoff for deriving a cut-off value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Measles IgG concentration data:
length(measles)
range(measles)
# Plotting the data:
hist(measles,100,F,xlab="concentration",ylab="density",ylim=c(0,.55),
  main=NULL,col="grey")
# The kernel density:
lines(density(measles),lwd=1.5,col="blue")
# Estimating the parameters of the finite mixture model:
(measles_out <- em(measles,"normal","normal"))
# The confidence interval of the parameter estimates:
confint(measles_out,t=1e-64,nb=100,level=.95)
# Adding the E-M estimated finite mixture model:
lines(measles_out,lwd=1.5,col="red")
# The legend:
legend("topleft",leg=c("non-parametric","E-M"),col=c("blue","red"),
  lty=1,lwd=1.5,bty="n")

qmiao19/CytoSpill documentation built on Nov. 5, 2019, 1:58 a.m.