mix.synthetic: Generate synthetic mixtures for testing of 'mix.mle'.

Description Usage Arguments Value See Also Examples

Description

These functions can be helpful in assessing the convergence of mix.mle.

Usage

1
2
3
mix.synthetic.normal(N = 200, mix.prob = 0.5,  mu1, sd1, mu2, sd2)
mix.synthetic.facing.gamma(N = 200, mix.prob = 0.5, lower, upper, 
    shape1, scale1, shape2, scale2)

Arguments

N

Number of draws.

mix.prob

Probability of drawing from upper distribution.

lower, upper

Bounds for facing gamma.

shape1, scale1, shape2, scale2

Distribution parameters for facing.gammas. Lower = 1, upper = 2.

mu1, sd1, mu2, sd2

Distribution parameters for normals. Lower = 1, upper = 2.

Value

Numeric vector of random deviates from the mixture of distributions.

See Also

mix.loglik

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Normal: draw samples
normalmix.draws <- mix.synthetic.normal(mix.prob=0.1,
    mu1=10, sd1=2, mu2=20, sd2=2)
## Estimated initial conditions may fail for mix.prob far from 0.5
normalmix.fit <- mix.mle(normalmix.draws)
plot(normalmix.fit)

## Facing gamma: draw samples
gammamix.params <- list(lower = 0.37, upper=4.72, mix.prob=0.55,
    dist1.par1=1.50, dist1.par2=.4, dist2.par1=3.2, dist2.par2=.5)
    ## simulate synthetic data
gammamix.draws <- with(gammamix.params, 
    mix.synthetic.facing.gamma( lower=lower, upper=upper,  mix.prob=mix.prob,
        shape1=dist1.par1, scale1=dist1.par2, 
        shape2=dist2.par1, scale2=dist2.par2
        )
)
## Fit and return
## Use parameters as initial values 
gammamix.fit <- with(gammamix.params,
    mix.mle(gammamix.draws,  method='facing.gamma', 
          lower=lower, upper=upper, mix.prob=mix.prob,
          dist1.par1=dist1.par1, dist1.par2=dist1.par2, 
          dist2.par1=dist2.par1, dist2.par2=dist2.par2
    )
)
plot(gammamix.fit)

discrimARTs documentation built on May 2, 2019, 2:04 a.m.