Learn R Programming

pcensmix (version 1.2-1)

mixgen: Generating Mixture Datasets

Description

This function generates two-component mixture data from a various different mixture distributions.

Usage

mixgen(N, dist1, dist2, control)

Arguments

N

population size.

dist1, dist2

respective distributions of the first and second mixture components to be simulated from. For Normal, Log-normal, Weibull, Gamma, Cauchy and Beta distributions, they must be provided as 'norm', 'lnorm', 'weibull', 'gamma', 'cauchy' and 'beta' respectively. The Exponential distribution can be included as a Gamma distribution with scale parameter one.

control

a list of parameters for controlling the simulation process. This includes parameters of the first and second mixture component distributions and the mixture proportion \(\pi\) which should be provided in the order mentioned, i.e., parameters for the first component come first, those of the second component come after and then the value of the mixing proportion. All values should be provided in a list of numerics. Note parameters for each component distribution should be added in the order as required in their generator functions, see rnorm, rlnorm, rweibull, rgamma, rcauchy and rbeta.

Value

An object of class data.frame containing the following information:

z

mixture data

label

component indicator

Details

It generates a two-component mixture dataset from a density function $$\pi f_1 + (1 - \pi) f_2,$$ where \(f_1\) and \(f_2\) are the first and the second mixture component distributions respectively.

See Also

pcgen

Examples

Run this code
# NOT RUN {
## Generate a sample from a two component Normal-Weibull mixture distribution
## with mixing components as N(12, 2) and Weibull(15, 4), mixing proportion 0.3
## and size of N = 20.

mixture<- mixgen(N = 20, dist1 = 'norm', dist2 = 'weibull', control = list(12, 2, 15, 4, 0.3))

# }

Run the code above in your browser using DataLab