validate_logN_corrMatrix: Validation of Correlation matrix of Log-Normal distribution

View source: R/validate_logN_corrMatrix.R

validate_logN_corrMatrixR Documentation

Validation of Correlation matrix of Log-Normal distribution

Description

Given a set of Log-Normal variables with their means, standard deviations and correlation matrix, this function evaluates if the correlation structure respects two conditions:

  1. For each couple of variables, X1, X2, it is tested if \rho(X1,X2) satisfies the condition necessary to obtain a positive definite correlation/covariance matrix for the Normal distribution underlying the Log-Normal one. This condition is also sufficient for 2x2 matrix [1]. If this condition is not satisfied, a warning message is displayed but covariance matrix of the Normal distribution is still computed even if it is not positive definite.

  2. For each couple of variables, X1, X2, it is tested if \rho(X1,X2)*cv1*cv2 > -1. If this condition is not satisfied for all the couples the covariance matrix of the underlying Normal distribution cannot be computed. In fact, the covariance between X1, X2 of the Normal distribution, \Sigma^2(X1,X2), is defined as ln((\rho(X1,X2)*cv1*cv2 )+1) [1]. In this case, a warning message will be displayed and a summary of the performed tests is returned.

Usage

validate_logN_corrMatrix(mu, sd, corrMatrix)

Arguments

mu

Array object which contains mean values of variables with a Log-Normal distribution.

sd

Array object which contains sd values of variables with a Log-Normal distribution.

corrMatrix

Matrix object which contains correlations of variables with a Log-Normal distribution.

Value

A list containing:

is_valid_logN_corrMat Boolean flag which indicates if the input correlation matrix satisfies condition 1.
can_log_transf_covMat Boolean flag which indicates if the input correlation matrix satisfies condition 2.
validation_res Matrix object which contains a brief summary of the tested conditions on the input correlation matrix. It is composed by N(=number of Log-Normal variables couples) rows and 8 columns:
  • var1: numerical index of the first Log-Normal variable of the couple, X1

  • var2: numerical index of the second Log-Normal variable of the couple, X2

  • lower: lower bound for the range of Log-Normal correlation between var1 and var2

  • upper: upper bound for the range of Log-Normal correlation between var1 and var2

  • tested_corr: input correlation value between var1 and var2

  • is_valid_bound: numerical flag. If 1 tested_corr is inside the range, 0 otherwise

  • tested_for_logTransf: value computed for testing condition 2 (\rho(X1,X2)*cv1*cv2)

  • can_logTransf: numerical flag. If 1 covariance of normal distribution between var1 and var2 can be computed, 0 otherwise.

Note

Within this package, function used for sampling from the multivariate Log-Normal distribution (mvlogn) can overcome situations in which covariance matrix of the Normal distribution underlying the Log-Normal one is not positive definite (i.e. condition 1 not satisfied) by approximating it to the nearest positive definite. This may alter the desired correlation structure, but simulation is still allowed. On the contrary, if condition 2 is not satisfied, simulation cannot be performed because computing Normal covariance matrix is impossible to calculate since the argument of logarithmic transformation would be negative for some couples of variables.

Author(s)

Alessandro De Carlo alessandro.decarlo01@universitadipavia.it

References

[1] Henrique S. Xavier, Filipe B. Abdalla, Benjamin Joachimi, Improving lognormal models for cosmological fields, Monthly Notices of the Royal Astronomical Society, Volume 459, Issue 4, 11 July 2016, Pages 3693–3710, https://doi.org/10.1093/mnras/stw874

See Also

nearPD

get_logNcorr_bounds

logn_to_normal

Examples


#CONDITION 1 AND 2 SATISFIED
#input correlation matrix
corr<- diag(rep(1,4))
corr[1,4] <- 0.9
corr[4,1]<-corr[1,4]
corr[2,4] <- -0.2
corr[4,2] <- corr[2,4]
corr[3,2] <- -0.1
corr[2,3] <- corr[3,2]
#input standard deviations
sd2 <- array(c(rep(1,4)))
#input means
mu2 <- array(rep(2.5,4))
validate_logN_corrMatrix(mu2,sd2,corr)

#output

#$is_valid_logN_corrMat
#[1] TRUE
#
#$can_log_transf_covMat
#[1] TRUE

#$validation_res
#      var1 var2 lower      upper tested_corr   is_valid_bound tested_for_logTransf  can_logTransf
#[1,]    1    2 -0.862069     1         0.0              1                0.000             1
#[2,]    1    3 -0.862069     1         0.0              1                0.000             1
#[3,]    1    4 -0.862069     1         0.9              1                0.144             1
#[4,]    2    3 -0.862069     1        -0.1              1               -0.016             1
#[5,]    2    4 -0.862069     1        -0.2              1               -0.032             1
#[6,]    3    4 -0.862069     1         0.0              1                0.000             1

AlessandroDeCarlo27/mvlognCorrEst documentation built on March 23, 2023, 10:11 a.m.