Last data update: 2014.03.03

R: Random Generation from a t Mixture Model with Box-Cox...
SimulateMixtureR Documentation

Random Generation from a t Mixture Model with Box-Cox Transformation

Description

This function can be used to generate a sample from a multivariate t mixture model with Box-Cox transformation.

Usage

SimulateMixture(N, w, mu, sigma, nu=4, lambda)

Arguments

N

The number of observations.

w

A vector of length K, containing the K cluster proportions.

mu

A matrix of size K x P, where K is the number of clusters and P is the dimension, containing the K mean vectors.

sigma

An array of dimension K x P x P, containing the K covariance matrices.

nu

The degrees of freedom used for the t distribution.

lambda

The Box-Cox transformation parameter. If missing, the conventional t distribution without transformation will be used.

Value

A matrix of size N x P.

Author(s)

Raphael Gottardo <raph@stat.ubc.ca>, Kenneth Lo <c.lo@stat.ubc.ca>

See Also

flowClust

Examples


### Number of components
K <- 5
### Dimension
p <- 2
### Number of observations
n <- 200
Mu <- matrix(runif(K*p, 0, 20), K, p)
Sigma <- array(0, c(K, p, p))

for (k in 1:K)
{
    Sigma[k,,][outer(1:p, 1:p, ">")] <- runif(p*(p-1)/2,-.1,.1)
    diag(Sigma[k,,]) <- runif(p,0,1)
    ### Make sigma positive definite
    Sigma[k,,] <- Sigma[k,,] %*% t(Sigma[k,,])
}

### Generate the weights
w <- rgamma(K,10,1)
w <- w/sum(w)

y <- SimulateMixture(n, w, Mu, Sigma, nu=4)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(flowClust)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: graph
Loading required package: RBGL
Loading required package: ellipse
Loading required package: flowViz
Loading required package: flowCore

Attaching package: 'flowCore'

The following object is masked from 'package:BiocGenerics':

    normalize

Loading required package: lattice
Loading required package: mnormt
Loading required package: corpcor
Loading required package: clue

Attaching package: 'flowClust'

The following object is masked from 'package:graphics':

    box

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/flowClust/SimulateMixture.Rd_%03d_medium.png", width=480, height=480)
> ### Name: SimulateMixture
> ### Title: Random Generation from a t Mixture Model with Box-Cox
> ###   Transformation
> ### Aliases: SimulateMixture
> ### Keywords: datagen
> 
> ### ** Examples
> 
> ### Number of components
> K <- 5
> ### Dimension
> p <- 2
> ### Number of observations
> n <- 200
> Mu <- matrix(runif(K*p, 0, 20), K, p)
> Sigma <- array(0, c(K, p, p))
> 
> for (k in 1:K)
+ {
+     Sigma[k,,][outer(1:p, 1:p, ">")] <- runif(p*(p-1)/2,-.1,.1)
+     diag(Sigma[k,,]) <- runif(p,0,1)
+     ### Make sigma positive definite
+     Sigma[k,,] <- Sigma[k,,] %*% t(Sigma[k,,])
+ }
> 
> ### Generate the weights
> w <- rgamma(K,10,1)
> w <- w/sum(w)
> 
> y <- SimulateMixture(n, w, Mu, Sigma, nu=4)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>