Skip to contents

Computes the Principal Components Torsion and the Minimum Torsion for diversification analysis.

Usage

torsion(sigma, model = "minimum-torsion", method = "exact", max_niter = 10000L)

Arguments

sigma

A n x n covariance matrix.

model

One of: "pca" or "minimum-torsion".

method

One of: "approximate" or "exact". Only used when model = "minimum-torsion".

max_niter

An integer with the maximum number of iterations.

Value

A n x n torsion matrix.

Examples

# extract the invariants from the data
set.seed(123)
log_ret <- matrix(rnorm(400), ncol = 4) / 10

# calculate the covariance matrix
sigma <- stats::cov(log_ret)

# torsion
torsion(sigma = sigma, model = 'minimum-torsion', method ='exact')
#>            [,1]        [,2]        [,3]        [,4]
#> [1,] 1.00534916  0.02148323  0.06301570  0.02088640
#> [2,] 0.02410872  1.00122793 -0.01410694 -0.02018601
#> [3,] 0.06823684 -0.01361221  1.00506025  0.02313965
#> [4,] 0.02704863 -0.02329473  0.02767377  1.00160337