Skip to contents

Sampling is done in the unconstrained coordinates and mapped back; sampling the parts directly and renormalising gives a different distribution. The Cholesky factor is used because it is unique for a positive-definite Sigma, so both arms map the same normal draws to the same compositions.

Usage

Lgtnsim(mu, Sigma, n, seed = 1, total = 1)

Arguments

mu

Mean of the alr coordinates, length D-1.

Sigma

Positive-definite covariance of the alr coordinates.

n

Number of compositions drawn.

seed

Seed for the pinned generator.

total

Constant each composition sums to.

Value

List with sample, alr, center, mean_alr, n, D.

Details

Formula: Z ~ N(0, I_{D-1}); Y = mu + L Z with L L' = Sigma; X = alr^-1(Y) = C(exp(Y_1), ..., exp(Y_{D-1}), 1)

References

Aitchison (1986), The Statistical Analysis of Compositional Data, Chapter 6. The reference part is the LAST, matching aitalr and aitalri.

Examples

Lgtnsim(mu = 5L, Sigma = 0.5, n = 5L)
#> $sample
#>           [,1]        [,2]
#> [1,] 0.8923250 0.107675024
#> [2,] 0.9825336 0.017466446
#> [3,] 0.9944125 0.005587500
#> [4,] 0.9971945 0.002805462
#> [5,] 0.9981839 0.001816088
#> 
#> $alr
#>          [,1]
#> [1,] 2.114713
#> [2,] 4.029853
#> [3,] 5.181620
#> [4,] 5.873378
#> [5,] 6.309253
#> 
#> $center
#> [1] 0.993307149 0.006692851
#> 
#> $mean_alr
#> [1] 4.701763
#> 
#> $n
#> [1] 5
#> 
#> $D
#> [1] 2
#> 
#> $method
#> [1] "Logistic-normal sampling via alr^-1"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"