Main Content

portfolioRiskContribution

Compute individual asset risk contribution to overall portfolio volatility

Since R2022a

Description

example

riskCont = portfolioRiskContribution(portWeights,Sigma) computes individual asset risk contribution to overall portfolio volatility and returns riskCont as a matrix of risk contributions.

example

riskCont = portfolioRiskContribution(___,Name=Value) specifies an option using a name-value argument in addition to the input arguments in the previous syntax.

Examples

collapse all

Use portfolioRiskContribution to compute the risk contribution per asset with respect to the portfolio total risk.

Assume the returns covariance matrix is given by the following values.

Sigma = [0.0100    0.0075    0.0100    0.0150
         0.0075    0.0225    0.0150    0.0225
         0.0100    0.0150    0.0400    0.0450
         0.0150    0.0225    0.0450    0.0900];

The portWeights are the following values:

portWeights = [0.4101; 0.2734; 0.1899; 0.1266];

Use portfolioRiskContribution to compute the percent of risk contribution per asset.

riskCont = portfolioRiskContribution(portWeights,Sigma)
riskCont = 4×1

    0.2500
    0.2500
    0.2500
    0.2500

The default is to compute the relative risk contribution. However, you can compute the absolute risk contribution by using the name-value argument RiskContributionType="absolute". Use portfolioRiskContribution to compute each asset's relative risk contribution.

riskCont = portfolioRiskContribution(portWeights,Sigma,RiskContributionType="relative")
riskCont = 4×1

    0.2500
    0.2500
    0.2500
    0.2500

Use portfolioRiskContribution to compute the risk contribution of each asset with respect to the portfolio total risk when the assets returns used to compute the variance have NaN values.

Assume the returns covariance matrix is given by the following values.

load('CAPMuniverse.mat','AssetsTimeTable')
Sigma = cov(AssetsTimeTable{:,1:12},'partialrows')
Sigma = 12×12

    0.0012    0.0005    0.0005    0.0005    0.0005    0.0001    0.0004    0.0003    0.0006    0.0003    0.0005    0.0006
    0.0005    0.0023    0.0007    0.0005    0.0009    0.0001    0.0005    0.0003    0.0006    0.0004    0.0006    0.0011
    0.0005    0.0007    0.0012    0.0006    0.0007    0.0000    0.0006    0.0004    0.0007    0.0005    0.0008    0.0008
    0.0005    0.0005    0.0006    0.0009    0.0006    0.0000    0.0005    0.0003    0.0006    0.0004    0.0005    0.0006
    0.0005    0.0009    0.0007    0.0006    0.0017    0.0002    0.0005    0.0003    0.0005    0.0004    0.0007    0.0010
    0.0001    0.0001    0.0000    0.0000    0.0002    0.0006   -0.0000    0.0000    0.0000    0.0000    0.0000    0.0002
    0.0004    0.0005    0.0006    0.0005    0.0005   -0.0000    0.0009    0.0003    0.0005    0.0003    0.0005    0.0005
    0.0003    0.0003    0.0004    0.0003    0.0003    0.0000    0.0003    0.0004    0.0003    0.0002    0.0004    0.0004
    0.0006    0.0006    0.0007    0.0006    0.0005    0.0000    0.0005    0.0003    0.0010    0.0005    0.0006    0.0006
    0.0003    0.0004    0.0005    0.0004    0.0004    0.0000    0.0003    0.0002    0.0005    0.0006    0.0004    0.0005
      ⋮

The risk parity portfolio is subject to the following weights for all the assets.

portWeights = [0.1; 0.1; 0.1; 0.03; 0.1; 0.1; 0.1; 0.05; 0.1; 0.1; 0.1; 0.1];

Use portfolioRiskContribution to compute the percentage risk contribution per asset.

riskCont = portfolioRiskContribution(portWeights,Sigma)
riskCont = 12×1

    0.0911
    0.1261
    0.1103
    0.0251
    0.1197
    0.0203
    0.0805
    0.0258
    0.0978
    0.0660
      ⋮

The default values returned by portfolioRiskContribution are the relative risk contribution of the individual assets to the overall portfolio risk. Also, you can compute the absolute risk contribution by using the name-value argument RiskContributionType="absolute". Use portfolioRiskContribution to compute each asset's absolute risk contribution.

riskCont = portfolioRiskContribution(portWeights,Sigma,RiskContributionType="absolute")
riskCont = 12×1

    0.0023
    0.0031
    0.0027
    0.0006
    0.0030
    0.0005
    0.0020
    0.0006
    0.0024
    0.0016
      ⋮

Use portfolioRiskContribution to compute the risk contribution per asset with respect to the portfolio total risk when portWeights is a matrix.

Assume the returns covariance matrix is given by the following values.

Sigma = [0.0100    0.0075    0.0100    0.0150
         0.0075    0.0225    0.0150    0.0225
         0.0100    0.0150    0.0400    0.0450
         0.0150    0.0225    0.0450    0.0900];

The matrix of portWeights is the values:

portWeights = [0.25    0.10    0.10828;
               0.25    0.20    0.17197;
               0.25    0.30    0.28026;
               0.25    0.40    0.43949];

Use portfolioRiskContribution to compute the percent of risk contribution per asset.

riskCont = portfolioRiskContribution(portWeights,Sigma)
riskCont = 4×3

    0.1083    0.0308    0.0322
    0.1720    0.1005    0.0816
    0.2803    0.2735    0.2455
    0.4395    0.5952    0.6407

The default is to compute the relative risk contribution. However, you can compute the absolute risk contribution by using the name-value argument RiskContributionType="absolute". Use portfolioRiskContribution to compute each asset's absolute risk contribution.

riskCont = portfolioRiskContribution(portWeights,Sigma,RiskContributionType="absolute")
riskCont = 4×3

    0.0170    0.0060    0.0064
    0.0269    0.0194    0.0162
    0.0439    0.0528    0.0488
    0.0688    0.1149    0.1274

Input Arguments

collapse all

Portfolio weights, specified using an NumAssets-by-NumPortfolios matrix. portWeights must be nonempty, numeric, finite, and real. portWeights can be negative and does not need to sum to 1. portWeights and Sigma must have the same number of NumAssets.

Data Types: double

Covariance matrix of returns, specified using an NumAssets-by-NumAssets positive semidefinite covariance matrix. Sigma and portWeights must have the same number of NumAssets.

Note

If Sigma is not a positive symmetric positive semidefinite matrix, use nearcorr to create a positive semidefinite matrix.

Data Types: double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: riskCont = portfolioRiskContribution(portWeights,Sigma,RiskContributionType="relative")

Type of risk contribution to compute, specified as RiskContributionType and a scalar character vector or string:

  • "relative" — Computes the relative contribution.

  • "absolute" — Computes the absolute risk contribution.

Data Types: char | string

Output Arguments

collapse all

Risk contributions, returned as a matrix. The default values returned by portfolioRiskContribution are the relative contribution of the assets to the portfolio. However, portfolioRiskContribution can also return the absolute risk contribution by passing the name-value argument RiskContributionType with a value of "absolute".

Version History

Introduced in R2022a