Learn R Programming

simplexreg (version 1.3)

simplex: The Simplex Distribution Functions

Description

Density, cumulative distribution function, quantile function and random variable generation for the simplex distribution with mean equal to mu and dispersion equal to sig

Usage

dsimplex(x, mu, sig) psimplex(q, mu, sig) qsimplex(p, mu, sig) rsimplex(n, mu, sig) psimplex.norm(q, mu, sig) qsimplex.norm(p, mu, sig)

Arguments

x, q
vector of quantiles

p
vector of probabilities
n
number of observations
mu
vector of means

sig
vector of square root of dispersion parameter of simplex distribution

Value

gives density function, psimplex gives the distribution function, qsimplex gives quantile function and rsimplex gives random number generated from the simplex distribution. psim.norm and qsimplex.norm gives the renormalized distribution and quantile function.

Details

The simplex distribution has density $$p(y) = (2\pi \sigma^2)^{-\frac{1}{2}} (y(1-y))^{-\frac{3}{2}} \exp(-\frac{1}{2\sigma^2} d(y;\mu)), y \in (0, 1)$$ where $d(y;\mu)$ is a unit deviance function $$d(y;\mu) = \frac{(y-\mu)^2}{y(1-y) \mu^2 (1-\mu)^2}$$ $\mu$ is the mean of simplex distribution and $\sigma^2$ the dispersion parameter. qnorm provides results up to about 6 digits.

References

Barndorff-Nielsen, O.E. and Jorgensen, B. (1991) Some parametric models on the simplex. Journal of Multivariate Analysis, 39: 106--116 Jorgensen, B. (1997) The Theory of Dispersion Models. London: Chapman and Hall Song, P. and Qiu, Z. and Tan, M. (2004) Modelling Heterogeneous Dispersion in Marginal Models for Longitudinal Proportional Data. Biometrical Journal, 46: 540--553

Examples

Run this code
# simplex distribution function
dsimplex(seq(0.01,0.99,0.01), 0.5, 1)
psimplex(seq(0.01,0.99,0.01), 0.5, 1)
qsimplex(seq(0.01,0.99,0.01), 0.5, 1)

# random variable generation
n <- 200
ga0 <- 1.5
ga1 <- 0.5
ga2 <- -0.5
sigma <- 4
T <- c(rep(0, n/2), rep(1, n/2))
S <- runif(n, 0, 5)
eta <- ga0 + ga1 * T + ga2 * S
mu <- exp(eta)/(1+exp(eta))
Y <- rep(0, n)
for (i in 1:n){ 
  Y[i] <- rsimplex(1, mu[i], sigma)
}

Run the code above in your browser using DataLab