Title: | Uncorrelated Bets via Minimum Torsion Algorithm |
---|---|
Description: | Implements Minimum Torsion for portfolio diversification as described in Meucci, Attilio (2013) <doi:10.2139/ssrn.2276632>. |
Authors: | Bernardo Reckziegel [aut, cre] |
Maintainer: | Bernardo Reckziegel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2.9000 |
Built: | 2025-01-29 03:37:31 UTC |
Source: | https://github.com/reckziegel/uncorbets |
Computes the diversification probability distribution and the effective number of bets of an allocation.
effective_bets(b, sigma, t)
effective_bets(b, sigma, t)
b |
A vector of exposures (allocations). |
sigma |
A |
t |
A |
A list
of length 2 with:
p
: the diversification probability distribution;
enb
: the effective number of bets.
# extract the invariants from the data set.seed(123) log_ret <- matrix(rnorm(400), ncol = 4) / 10 # compute the covariance matrix sigma <- stats::cov(log_ret) # torsion torsion_cov <- torsion(sigma = sigma, model = 'minimum-torsion', method ='exact') # 1/N reference b <- rep(1 / ncol(log_ret), ncol(log_ret)) # ENB effective_bets(b = b, sigma = sigma, t = torsion_cov)
# extract the invariants from the data set.seed(123) log_ret <- matrix(rnorm(400), ncol = 4) / 10 # compute the covariance matrix sigma <- stats::cov(log_ret) # torsion torsion_cov <- torsion(sigma = sigma, model = 'minimum-torsion', method ='exact') # 1/N reference b <- rep(1 / ncol(log_ret), ncol(log_ret)) # ENB effective_bets(b = b, sigma = sigma, t = torsion_cov)
Finds the allocation that maximizes the effective_bets
.
max_effective_bets(x0, sigma, t, tol = 1e-20, maxeval = 5000L, maxiter = 5000L)
max_effective_bets(x0, sigma, t, tol = 1e-20, maxeval = 5000L, maxiter = 5000L)
x0 |
A |
sigma |
A |
t |
A |
tol |
An |
maxeval |
An |
maxiter |
An |
A list
with the following components:
weights
: the optimal allocation policy
enb
: the optimal effective number of bets
counts
: the number of iterations of the objective and the gradient
lambda_lb
: the lower bound Lagrange multipliers
lambda_ub
: the upper bound Lagrange multipliers
lambda_eq
: the equality Lagrange multipliers
gradient
: the gradient of the objective function at the optimum
hessian
: hessian of the objective function at the optimum
# extract the invariants from the data set.seed(123) log_ret <- matrix(stats::rnorm(400), ncol = 4) / 10 # compute the covariance matrix sigma <- stats::cov(log_ret) # torsion torsion_cov <- torsion(sigma = sigma, model = 'minimum-torsion', method = 'exact') # 1/N reference b <- rep(1 / ncol(log_ret), ncol(log_ret)) max_effective_bets(x0 = b, sigma = sigma, t = torsion_cov)
# extract the invariants from the data set.seed(123) log_ret <- matrix(stats::rnorm(400), ncol = 4) / 10 # compute the covariance matrix sigma <- stats::cov(log_ret) # torsion torsion_cov <- torsion(sigma = sigma, model = 'minimum-torsion', method = 'exact') # 1/N reference b <- rep(1 / ncol(log_ret), ncol(log_ret)) max_effective_bets(x0 = b, sigma = sigma, t = torsion_cov)
Computes the Principal Components Torsion and the Minimum Torsion for diversification analysis.
torsion(sigma, model = "minimum-torsion", method = "exact", max_niter = 10000L)
torsion(sigma, model = "minimum-torsion", method = "exact", max_niter = 10000L)
sigma |
A |
model |
One of: "pca" or "minimum-torsion". |
method |
One of: "approximate" or "exact". Only used when |
max_niter |
An |
A n x n
torsion matrix.
# 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')
# 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')