# rankscore: Calculate the rankings and regularization scores of a... In jeanmarcgp/ResilientPortfolio: Resilient Portfolio Management System

## Description

Calculate the pairwise rankings and regularization scores between all assets in a universe vs. a portfolio of assets that is rebalanced daily. The regularization formula considers both daily correlation and daily volatility.

## Usage

 ```1 2 3``` ```rankscore(rets, portassets = colnames(rets)[1], maxwtsvec = 1, momvec = NA, rho = 0, abscor = FALSE, sigma = 0, epsilon = 0, eta = 1, port_size = length(portassets)) ```

## Arguments

 `rets` An xts matrix of asset returns that include all assets in the universe which must also include the assets in the portfolio. The regularization score and its terms are calculated over all returns provided by this matrix rets. `portassets` A character vector containing the names of assets in the portfolio. Must contain at least one name. `maxwtsvec` Either an ordered or named numeric vector containing the relative weight of each asset in the universe or a single number. The sum of all weights does not need to equal one (in fact, it would normally exceed one), as this is used for relative weightings. If a single number (for example maxwtsvec is set to 1) then it results in an equal weights portfolio using portassets. `momvec` A named numeric vector containing annualized momentum values for each asset in the universe. If set to NA, then a momentum value is computed inside the function using the equivalent equity curve from the rets matrix argument (last row / first row). `rho` The regularization parameter to control the amount of correlation penalty between the asset and the portfolio during regularization. Default is zero which means that correlation is not penalized during regularization. `abscor` Logical. Should the absolute value of correlations be used (negative correlations are considered as positive) or not. Default is FALSE (no absolute values). Setting this to TRUE may be helpful when using inverse ETFs since these will be negatively correlated AND also exhibit inverse performance. NOTE: When FALSE, one is added to epsilon to offset the correlation values so it can vary from 0 to 2 instead of -1 to +1. This ensures that the regularized correlation term always results in a positive term. `sigma` The regularization parameter to control the amount of relative volatility penalty taken during regularization. The asset relative volatility is the asset volatility divided by the portfolio volatility, where volatility is defined to be the daily standard deviation over the timeframe defined by the rets matrix. Default value is zero which means that volatility is not penalized. `epsilon` A small positive offset added to the correlation value of the asset against the portfolio before regularization is applied. Default is zero. `eta` The exponent value for the correlation term. This is equivalent to the norm in a standard regularization problem. Default is 1. `port_size` The size of the portfolio in number of assets. This is used to compute the weights of a newly added asset during the correlation test (function portfolio_cor).

## Details

The portfolio (portassets) must be made up of assets present in the universe otherwise an error will result. The assets in the universe are the named columns in the daily returns matrix (rets).

For each asset present in the universe AND not in the portfolio, a regularization score is calculated according to the formula:

reguscore = 1 + ρ(cor + ε)^η + σ * relvol

Similarly, a momentum score (momscore) is calculated from the asset momentum divided by the above reguscore value:

momscore = asset momentum / reguscore

A named vector is returned with the above regularization score for each asset not in the portfolio compared with the portfolio. The portfolio may be built of equal weights or a set of predefined weights, as specified by maxwtsvec. The quantity cor corresponds to the correlation of the asset vs. the portfolio over the timeframe specified by the index of rets, the returns xts matrix provided. Similarly, relvol corresponds to the relative volatility between the asset and the portfolio as calculated using the standard deviation of returns over the timeframe specified by the rets matrix.

rho (ρ)

Regularization parameter applied to correlation term

epsilon (ε)

Small optional offset added to correlation value

eta η

Norm exponent applied to correlation term

sigma σ

Regulation parameter applied to relative volatility

## Value

Returns a list of the following named vector. Each vector contains a value for an asset present in the universe and not in the portfolio.

`\$regurank`

A named vector containing the regurank for each asset. The regurank is the relative ranking of the regularization score (reguscore) for each asset.

`\$momrank`

A named vector containing the momrank for each asset. The momrank is the relative ranking of the momscore (see below).

`\$reguscore`

A named vector of the regularization score for each asset. This is the result of the regularization formula described in the Details section.

`\$momscore`

A named vector of the regularized momentum score for each asset. This quantity is the result of dividing momvec by reguscore.

jeanmarcgp/ResilientPortfolio documentation built on April 8, 2018, 5:43 p.m.