dmix: Mixtures of truncated distributions

Description Usage Arguments Examples

View source: R/dmix.R

Description

Compute the distribution and raw moments of a mixture of different, one dimenisonal, eventually truncated distributions.

Usage

1
2
3
dmix(lower = -Inf, upper = Inf, distrib, weights)

mmix(order = 1:4, lower = -Inf, upper = Inf, distrib, weights)

Arguments

lower

numeric giving the lower bound of the support. Defaults to -Inf.

upper

numeric giving the upper bound of the support. Defaults to Inf.

distrib

a list. Every element is itself a list representing a distribution. This list should have one named element spec which describes the distribution, i. e. "exp" for the exponential distribution or "norm" for the normal distribution. The other elements are optional additional parameters for the specfied distribution.

weights

numeric vector with the same length as distrib. Provides weights for every distribution given in distrib.

order

order of the moment

Examples

1
2
3
4
5
distributions <- list(list(spec="exp", rate = 2),
                     list(spec="norm", mean = 0, sd = 0.5),
                     list(spec="unif", min = 2, max = 3))
d <- dmix(-1, 3, weights = c(.1,.3,.1), distrib = distributions)
curve(d(x), -2, 5)

CharlotteJana/momcalc documentation built on Oct. 17, 2019, 7:21 a.m.