fit.4g: fit.4g

Description Usage Arguments Value Author(s) Examples

Description

Fit a four-part mixture normal model to bivariate data. Assumes that data are distributed as one of N(0,1) x N(0,1) with probability pi0 N(0,s1^2) x N(0,1) with probability pi1 N(0,1) x N(0,t1^2) with probability pi2 N(0,s2^2) x N(0,t2^2) with probability 1-pi0-pi1-pi2 Fits the set of parameters (pi0,pi1,pi2,s1,s2,t1,t2) using an E-M algorithm

Usage

1
2
fit.4g(P, pars = c(0.7, 0.1, 0.1, 2, 2, 2, 2), weights = rep(1,
  dim(Z)[1]), C = 1, maxit = 10000, tol = 1e-04, sgm = c(1, 100))

Arguments

P

matrix N x 2 of data points (Z scores or P-values)

pars

initial parameter values

weights

weights for points

C

include additive term C*log(pi0*pi1*pi2*(1-pi0-pi1-pi2)) in objective function to ensure identifiability of model

maxit

maximum number of iterations (supersedes tol)

tol

stop after increment in log-likelihood is smaller than this

sgm

force s1,s2,t1,t2 to be at least this value

Value

list with elements pars (fitted parameters), lhood (log likelihood) and hist (fitted parameters during algorithm

Author(s)

James Liley

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
pi0=0.5; pi1=0.15; pi2=0.25
s1=3; s2=2; t1=2; t2=3
true_pars=c(pi0,pi1,pi2,s1,s2,t1,t2)


n=100000; n0=round(pi0*n); n1=round(pi1*n); n2=round(pi2*n); n3=n-n0-n1-n2

zs=c(rnorm(n0,sd=1),rnorm(n1,sd=s1),rnorm(n2,sd=1),rnorm(n3,sd=s2))
zt=c(rnorm(n0,sd=1),rnorm(n1,sd=1),rnorm(n2,sd=t1),rnorm(n3,sd=t2))

Z=cbind(zs,zt)

f=fit.4g(Z)
f$pars

jamesliley/cfdr documentation built on July 31, 2020, 9:42 a.m.