Mix: Mixtures of Univariate Distributions

Description Usage Arguments Details Value See Also Examples

View source: R/0_Mix_utils.R

Description

Objects of class Mix represent finite mixtures of any univariate distribution. Methods for construction, printing and plotting are provided.

Usage

1
2
3
4
5
6
Mix(dist, w = NULL, theta.list = NULL, name = NULL, ...)
  
is.Mix(x)
  
## S3 method for class 'Mix'
print(x, ...)  

Arguments

dist

a character string giving the (abbreviated) name of the component distribution, such that the function ddist evaluates its density function and rdist generates random numbers. For example, to create a gaussian mixture, dist has to be specified as norm instead of normal, gaussian etc. for the package to find the functions dnorm and rnorm.

w

numeric vector of length p, specifying the mixture weights w[i] of the components, i = 1,…,p. If the weights don't add up to 1, they will be scaled accordingly. Uses equal weights for all components by default.

theta.list

named list specifying the component parameters. The names of the list elements have to match the names of the formal arguments of the functions ddist and rdist exactly. For a gaussian mixture, the list elements would have to be named mean and sd, as these are the formal arguments used by rnorm and dnorm. Alternatively, the component parameters can be supplied directly as named vectors of length p via ...

name

optional name tag of the result (used for printing and plotting).

x
in is.Mix():

R object.

in print.Mix():

object of class Mix.

...
in Mix():

alternative way of supplying the component parameters (instead of using theta.list).

in print.Mix():

further arguments passed to the print method.

Details

Note that the Mix function will change the random number generator (RNG) state.

Value

An object of class Mix (implemented as a matrix) with the following attributes:

dim

dimensions of the matrix.

dimnames

a dimnames attribute for the matrix.

name

as entered via name.

dist

as entered via dist.

discrete

logical indicating whether the mixture distribution is discrete.

theta.list

as entered via theta.list.

See Also

dMix for the density, rMix for random numbers (and construction of an rMix object) and plot.Mix for the plot method.

Examples

1
2
3
4
5
6
7
# define 'Mix' object
normLocMix <- Mix("norm", w = c(0.3, 0.4, 0.3), mean = c(10, 13, 17), sd = c(1, 1, 1))
poisMix <- Mix("pois", w = c(0.45, 0.45, 0.1), lambda = c(1, 5, 10))

# plot 'Mix' object
plot(normLocMix)
plot(poisMix)

anjaweigel/mixComp_package documentation built on Sept. 2, 2020, 3:55 p.m.