View source: R/normal_to_logn.R
normal_to_logn | R Documentation |
This function converts mean vector and covariance matrix of a multivariate Normal distribution to mean vector and covariance matrix of the associated multivariate Log-Normal distribution.
normal_to_logn(mu, covMatrix)
mu |
Array object containing means of the multivariate Normal distribution. |
covMatrix |
Matrix object containing covariance matrix of the multivariate Normal distribution. |
A list containing:
muLn | Array object. It contains mean of the multivariate Log-Normal distribution associated to the Normal one. |
sigmaLn | Matrix object. It contains covariance matrix of the multivariate Log-Normal distribution associated to the Normal one. |
Alessandro De Carlo alessandro.decarlo01@universitadipavia.it
logn_to_normal
#define correlations
corr<- diag(rep(1,4))
corr[1,4] <- 0.9
corr[4,1]<-corr[1,4]
corr[2,4] <- -0.3
corr[4,2] <- corr[2,4]
corr[3,2] <- -0.2
corr[2,3] <- corr[3,2]
#define sd of variables
sd2 <- array(c(rep(1,4)))
#obtain covariance matrix
covMatrix2 <- sd2%*%t(sd2)*corr
#define mean vector
mu2 <- array(rep(2.5,4))
normal_to_logn(mu2,covMatrix2)
#output:
# $muLn
# [1] 20.08554 20.08554 20.08554 20.08554
#
# $sigmaLn
# [,1] [,2] [,3] [,4]
# [1,] 693.2044 0.00000 0.00000 588.8459
# [2,] 0.0000 693.20436 -73.12923 -104.5614
# [3,] 0.0000 -73.12923 693.20436 0.0000
# [4,] 588.8459 -104.56139 0.00000 693.2044
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.