knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of {{riskparity}}
is to demonstrate different approaches to asset allocation to achieve risk parity.
You can install {{riskparity}}
from GitHub with:
# install.packages("devtools") devtools::install_github("samthorold/riskparity")
library(riskparity) # asset allocation w <- c(.55, .25, .2) # asset standard deviations s <- c(.24, .18, .15) # asset correlation C <- matrix(c(1, 0.85, 0.3, 0.85, 1, -0.15, 0.3, -0.15, 1), nrow = 3) # total contribution to portfolio standard deviation asset_stdev_contrib(w, s, C) # marginal contribution to portfolio standard deviation asset_stdev_contrib(w, s, C, marginal = TRUE) # dispersion measures effective_constituents(w) entropy(w) entropy(asset_stdev_contrib(w, s, C)) # df <- read.csv("../data/equity.csv")[,-1] # head(df) # dim(df) # # w <- matrix(1 / rep(ncol(df), ncol(df))) # s <- apply(df, 2, sd) # # C <- cor(df) # round(C, 2) # all(round(cor_robust(C, 0), 2) == round(C, 2)) # round(cor_robust(C, 0.55), 2) # # V <- cov(df) # round(V, 6) # all(round(cov_robust(V, 0), 6) == round(V, 6)) # round(cov_robust(V, 0.55), 6) # # q <- asset_stdev_contrib(w, s, C) / sum(asset_stdev_contrib(w, s, C)) # q # encb <- entropy(q) # encb # # C <- cor_robust(C, 0.55) # # asset_stdev_contrib(w, s, C) # sum(asset_stdev_contrib(w, s, C)) # # q <- asset_stdev_contrib(w, s, C) / sum(asset_stdev_contrib(w, s, C)) # q # encb <- entropy(q) # encb # # factor_stdev_contrib(w, s, C) # sum(factor_stdev_contrib(w, s, C)) # # p <- factor_stdev_contrib(w, s, C) / sum(factor_stdev_contrib(w, s, C)) # p # enb <- entropy(p) # enb # Diversification ratio w <- matrix(c(.55, .25, .2)) s <- matrix(c(.24, .18, .15)) C <- matrix(c(1, 0.85, 0.3, 0.85, 1, -0.15, 0.3, -0.15, 1), nrow = 3) diversification_ratio(w, s, C)
Variance of returns can be estimated with more confidence than the returns themselves.
Diversification ratio
$$ D(w)=\frac{w's}{w'Vw} $$
where;
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.