Learn R Programming

rebmix (version 2.6.1)

RNGMIX: Random Univariate or Multivariate Finite Mixture Generation

Description

Returns univariate or multivariate random datasets for mixtures of conditionally independent normal, lognormal, Weibull, gamma, binomial, Poisson or Dirac component densities.

Usage

RNGMIX(Dataset = NULL, rseed = -1, n = NULL, Theta = NULL)

Arguments

Dataset
a character vector containing list names of data frames of size $n \times d$ that d-dimensional datasets are written in.
rseed
set the random seed to any negative integer value to initialize the sequence. The first file in Dataset corresponds to it. For each next file the random seed is decremented $r_{\mathrm{seed}} = r_{\mathrm{seed}} - 1$. The default value is
n
a vector or a data frame containing number of observations in classes $n_{l}$, where number of observations $n = \sum_{l = 1}^{c} n_{l}$.
Theta
a matrix or a data frame containing $c$ parametric family types pdfi. One of "normal", "lognormal", "Weibull", "gamma", "binomial", "Poisson" or "Dirac"

Value

  • Dataseta list of data frames of size $n \times d$ containing d-dimensional datasets. Each of the $d$ columns represents one random variable. Number of observations $n$ equals the number of rows in the datasets.
  • wa data frame containing $c$ component weights $w_{l}$ summing to 1.
  • Thetaa data frame containing $c$ parametric family types pdfi. One of "normal", "lognormal", "Weibull", "gamma", "binomial", "Poisson" or "Dirac". Component parameters theta1.i follow the parametric family types. One of $\mu_{il}$ for normal and lognormal distributions and $\theta_{il}$ for Weibull, gamma, binomial, Poisson and Dirac distributions. Component parameters theta2.i follow theta1.i. One of $\sigma_{il}$ for normal and lognormal distributions, $\beta_{il}$ for Weibull and gamma distributions and $p_{il}$ for binomial distribution.
  • Variablesa character vector containing types of variables. One of "continuous" or "discrete".
  • ymina vector of length $d$ containing minimum observations.
  • ymaxa vector of length $d$ containing maximum observations.

Details

RNGMIX is based on the "Minimal" random number generator ran1 of Park and Miller with the Bays-Durham shuffle and added safeguards that returns a uniform random deviate between 0.0 and 1.0 (exclusive of the endpoint values).

References

W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical Recipes in C: The Art of Scientific Computing. Cambridge University Press, Cambridge, 1992.

Examples

Run this code
## Generate and print simulated dataset.

n <- c(75, 100, 125, 150, 175)

Theta <- rbind(pdf1 = rep("normal", 5),
  theta1.1 = c(10, 8.5, 12, 13, 7),
  theta2.1 = c(1, 1, 1, 2, 3),
  pdf2 = rep("normal", 5),
  theta1.2 = c(12, 10, 14, 15, 9),
  theta2.2 = c(1, 1, 1, 2, 3),
  pdf3 = rep("normal", 5),
  theta1.3 = c(10, 8.5, 12, 7, 13),
  theta2.3 = c(1, 1, 1, 2, 3),
  pdf4 = rep("normal", 5),
  theta1.4 = c(12, 10.5, 14, 9, 15),
  theta2.4 = c(1, 1, 1, 2, 3))

simulated <- RNGMIX(Dataset = paste("simulated_", 1:25, sep = ""),
  rseed = -1,
  n = n,
  Theta = Theta)

## Generate and print simulated dataset.

Theta <- rbind(pdf1 = rep("normal", 5),
  theta1.1 = c(10, 8.5, 12, 13, 7),
  theta2.1 = c(1, 1, 1, 2, 3),
  pdf2 = rep("Weibull", 5),
  theta1.2 = c(12, 10, 14, 15, 9),
  theta2.2 = c(2, 4.1, 3.2, 7.1, 5.3),
  pdf3 = rep("binomial", 5),
  theta1.3 = c(10, 8, 12, 7, 13),
  theta2.3 = c(0.1, 0.5, 0.9, 0.4, 0.2),
  pdf4 = rep("Dirac", 5),
  theta1.4 = c(1, 1, 1, 1, 1))

simulated <- RNGMIX(Dataset = paste("simulated_", 1:25, sep = ""),
  rseed = -1,
  n = n,
  Theta = Theta)
  
simulated

## Generate and print simulated dataset.

Theta <- rbind(pdf = rep("W", 5),
  theta1 = c(12, 10, 14, 15, 9),
  theta2 = c(2, 4.1, 3.2, 7.1, 5.3))

simulated <- RNGMIX(Dataset = paste("simulated_", 1:2, sep = ""),
  rseed = -1,
  n = n,
  Theta = Theta)
  
simulated

Run the code above in your browser using DataLab