Correlations to partial correlations and vice versa for R-vines with independence, Gaussian and t-copulas.

RVineCor2pcor(RVM, corMat)

RVinePcor2cor(RVM)

Arguments

RVM

RVineMatrix() defining only the R-vine structure for Cor2pcor and providing as well the partial correlations for Pcor2cor.

corMat

correlation matrix

Value

RVM

RVineMatrix with transformed partial correlations (for Cor2pcor)

cor

correlation matrix (for Pcor2cor)

Note

The behavior of RVinePcor2ccor differs from older versions (<= 1.4). The RVM object is now normalized such that the order of the returned correlation matrix conforms with the correlation matrix of the data. If RVM$names are non-default, the initial ordering of the variables cannot be traced back and the matrix has to be interpreted as indicated by the row- and column names.

Examples


## create RVineMatrix-object for Gaussian vine
Matrix <- matrix(c(1, 3, 4, 2,
                   0, 3, 4, 2,
                   0, 0, 4, 2,
                   0, 0, 0, 2), 4, 4)
family <- matrix(c(0, 1, 1, 1,
                   0, 0, 1, 1,
                   0, 0, 0, 1,
                   0, 0, 0, 0), 4, 4)
par <- matrix(c(0, 0.2,   0, 0.6,
                0,   0, 0.2, 0.6,
                0,   0,   0, 0.6,
                0,   0,   0,   0), 4, 4)
RVM <- RVineMatrix(Matrix, family, par)

## calculate correlation matrix corresponding to the R-Vine model
newcor <- RVinePcor2cor(RVM)

## transform back to partial correlations
RVineCor2pcor(RVM, newcor)$par
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.0  0.0    0
#> [2,]  0.2  0.0  0.0    0
#> [3,]  0.0  0.2  0.0    0
#> [4,]  0.6  0.6  0.6    0

## check if they are equal
all.equal(RVM$par, RVineCor2pcor(RVM, newcor)$par)
#> [1] TRUE