Who did it?
In the previous video, you saw the difference between a capital allocation budget and a risk budget. In this exercise, you will construct a risk budget, and discover how large each asset's percent risk contribution is in the total portfolio volatility.
For this last exercise, you will calculate the risk contributions for a portfolio that is again invested 40% in equities, 40% in bonds, 10% in real estate, and 10% in commodities. The function StdDev() plays an important role in this exercise. The StdDev() function creates a list of the assets' standard deviation ($StdDev), their risk contribution ($contribution), and their percent risk contribution ($pct_contrib_StdDev). 
You will be using three arguments in the StdDev() function to do this calculation. The first is R, a vector, matrix, data frame, time series, or zoo object of returns. The second is portfolio_method, which you will set to component, and the third is weights.
The object returns is loaded in your workspace.
Diese Übung ist Teil des Kurses
Introduction to Portfolio Analysis in R
Anleitung zur Übung
- Create a vector of the portfolio weights called 
weights. Remember, order matters! - Calculate your volatility budget using 
StdDev()on the return seriesreturns. Setportfolio_method = "component"andweightsequal to the created vector ofweights. Call thisvol_budget. - Combine the weights and the percentage risk contributions in a table called 
weights_percriskusingcbind(). - Print the table and note how different the percentage risk contributions are compared to the portfolio weights.
 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Create portfolio weights
# Create volatility budget
vol_budget <- StdDev(___, portfolio_method = "___", weights = ___)
# Make a table of weights and risk contribution
colnames(weights_percrisk) <- c("weights", "perc vol contrib")
# Print the table