R/rcompt.R

Defines functions rcompt

Documented in rcompt

################################
#### Random values generation from a multivariate
#### t distribution on the simplex
#### Tsagris Michail 02/2016
#### mtsagris@yahoo.gr
################################
rcompt <- function(n, m, s, dof, type = "alr") {
  ## n is the sample size
  ## m is the mean vector in R^d
  ## s is the covariance matrix in R^d
  ## dof is the degrees of freedom
  ## type is either alr or ilr
  x <- Rfast::rmvt(n, m, s, dof)
  
  if ( type == "alr" ) {
    y <- cbind( 1, exp(x) )
  } else {
    D <- dim(x)[2]
    y <- x %*% helm(D + 1)
    y < exp(y)
  }
  
  y / Rfast::rowsums(y)
}

Try the Compositional package in your browser

Any scripts or data that you put into this service are public.

Compositional documentation built on Oct. 23, 2023, 5:09 p.m.