rAitchison | R Documentation |
The Aitchison distribution is a class of distributions the simplex, containing the normal and the Dirichlet as subfamilies.
dAitchison(x,
theta=alpha+sigma %*% clr(mu),
beta=-1/2*gsi.svdinverse(sigma),
alpha=mean(theta),
mu=clrInv(c(sigma%*%(theta-alpha))),
sigma=-1/2*gsi.svdinverse(beta),
grid=30,
realdensity=FALSE,
expKappa=AitchisonDistributionIntegrals(theta,beta,
grid=grid,mode=1)$expKappa)
rAitchison(n,
theta=alpha+sigma %*% clr(mu),
beta=-1/2*gsi.svdinverse(sigma),
alpha=mean(theta),
mu=clrInv(c(sigma%*%(theta-alpha))),
sigma=-1/2*gsi.svdinverse(beta), withfit=FALSE)
AitchisonDistributionIntegrals(
theta=alpha+sigma %*% clr(mu),
beta=-1/2*gsi.svdinverse(sigma),
alpha=mean(theta),
mu=clrInv(c(sigma%*%(theta-alpha))),
sigma=-1/2*gsi.svdinverse(beta),
grid=30,
mode=3)
x |
acomp-compositions the density should be computed for. |
n |
integer: number of datasets to be simulated |
theta |
numeric vector: Location parameter vector |
beta |
matrix: Spread parameter matrix (clr or ilr) |
alpha |
positiv scalar: departure from normality parameter (positive scalar) |
mu |
acomp-composition, normal reference mean parameter composition |
sigma |
matrix: normal reference variance matrix (clr or ilr) |
grid |
integer: number of discretisation points along each side of the simplex |
realdensity |
logical: if true the density is given with respect to the Haar measure of the real simplex, if false the density is given with respect to the Aitchison measure of the simplex. |
mode |
integer: desired output:
-1: Compute nothing, only transform parameters, |
expKappa |
The closing divisor of the density |
withfit |
Should a pre-spliting of the Aitchison density be used for simulation? |
The Aitchison Distribution is a joint generalisation of the Dirichlet
Distribution and the additive log-normal distribution (or normal on the
simplex). It can be parametrized by Ait(theta,beta) or by
Ait(alpha,mu,Sigma). Actually, beta and Sigma can be easily
transformed into each other, such that only one of them is
necessary. Parameter theta is a vector in R^D
, alpha is its sum, mu is a
composition in S^D
, and beta and sigma are symmetric matrices, which
can either be expressed in ilr or clr space.
The parameters are transformed as
\beta=-1/2 \Sigma^{-1}
\theta=clr(\mu)\Sigma+\alpha (1,\ldots,1)^t
The distribution exists, if either,
\alpha\geq 0
and Sigma is positive definite (or beta
negative definite) in
ilr-coordinates, or if each theta is strictly positive and Sigma has
at least one positive eigenvalue (or beta has at least one negative
eigenvalue). The simulation procedure currently only works with the
first case.
AitchisonDistributionIntegral is a convenience function to compute the
parameter transformation and several functions of these
parameters. This is done by numerical integration over a
multinomial simplex lattice of D parts with grid
many elements
(see xsimplex
).
The density of the Aitchison distribution is given by:
f(x,\theta,\beta)=exp((\theta-1)^t \log(x)+ilr(x)^t \beta ilr(x))/exp(\kappa_{Ait(\theta,\beta)})
with respect to the classical Haar measure on the simplex, and as
f(x,\theta,\beta)=exp(\theta^t \log(x)+ilr(x)^t \beta
ilr(x))/exp(\kappa_{Ait(\theta,\beta)})
with respect to the Aitchison
measure of the simplex. The closure constant expKappa is computed
numerically, in AitchisonDistributionIntegrals
.
The random composition generation is done by rejection sampling based on an optimally fitted additive logistic normal distribution. Thus, it only works if the correponding Sigma in ilr would be positive definite.
dAitchison |
Returns the density of the Aitchison distribution evaluated at x as a numeric vector. |
rAitchison |
Returns a sample of size n of simulated compostions as an acomp object. |
AitchisondistributionIntegrals |
Returns a list with
|
The simulation procedure currently only works with a positive definite Sigma. You need a relatively high grid constant for precise values in the numerical integration.
K.Gerald v.d. Boogaart, R. Tolosana-Delgado http://www.stat.boogaart.de
Aitchison, J. (1986) The Statistical Analysis of Compositional
Data Monographs on Statistics and Applied Probability. Chapman &
Hall Ltd., London (UK). 416p.
runif.acomp
, rnorm.acomp
,
rDirichlet.acomp
(erg<-AitchisonDistributionIntegrals(c(-1,3,-2),ilrvar2clr(-diag(c(1,2))),grid=20))
(myvar<-with(erg, -1/2*ilrvar2clr(solve(clrvar2ilr(beta)))))
(mymean<-with(erg,myvar%*%theta))
with(erg,myvar-clrVar)
with(erg,mymean-clrMean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.