fit.vars: fit.em

Description Usage Arguments Details Value Author(s) References Examples

Description

Fit a specific two Guassian mixture distribution

Usage

1
2
fit.vars(Z, pi0 = 0.9, s2 = 1, tol = 1e-04, verbose = TRUE,
  maxit = 10000)

Arguments

Z

numeric vector of observed data

pi0

initial proportion of samples from f0

s2

initial value for sigma^2

tol

how small a change lhood prompts continued optimization

maxit

maximum number of iterations

Details

Assumes Z ~ N(0,1) with prob pi0, Z ~ N(0,1+sigma^2) with prob 1-pi0

Aims to estimate sigma^2 and pi0.

Value

a list of two objects giving fitted values and history

Author(s)

Chris Wallace

References

Cut down from more general version at https://gist.github.com/chr1swallace/11421212 for speed.

Examples

1
2
3
4
5
6
7
s2 <- 10
pi0 <- 0.8
n <- 10000
Z <- c(rnorm(round(n*pi0),0,1),rnorm(round(n*(1-pi0)),0,sqrt(1+s2)))
fit<-fit.em(Z)
fit$pars
fit$history

chr1swallace/cFDR documentation built on May 13, 2019, 6:18 p.m.