LoslegenKostenlos loslegen

Interpreting correlation

Now you will learn how to compute the correlation between bond returns and equity returns. Just like volatilities, these correlations are dynamic. Therefore you need to distinguish between a static analysis that calculates correlations over a complete sample and a dynamic analysis that calculates correlations over a rolling sample. This is a similar analysis as you did for the time-varying performance evaluation in terms of mean return and volatility.

In this exercise you will learn 3 new functions from the PerformanceAnalytics package: chart.Scatter(), chart.Correlation(), and chart.RollingCorrelation().

Diese Übung ist Teil des Kurses

Introduction to Portfolio Analysis in R

Kurs anzeigen

Anleitung zur Übung

  • Plot the equity returns (returns_equities) against the bond returns (returns_bonds) using the function chart.Scatter() with the bond returns on the x-axis. Do you see a relation?
  • Compute the correlation between the variables returns_bonds and returns_equities using cor().
  • Merge returns_bonds, and returns_equities using merge(). Call this returns.
  • Compute and visualize the correlation again, using chart.Correlation() with returns as the argument.
  • Compute the rolling 24-month estimates of the bond-equity correlation using the function chart.RollingCorrelation().

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create a scatter plot
chart.Scatter(___, ___, xlab = "bond returns", ylab = "equity returns", main = "bond-equity returns")

# Find the correlation


# Merge returns_bonds and returns_equities 
returns <- merge(___, ___)

# Find and visualize the correlation using chart.Correlation


# Visualize the rolling estimates using chart.RollingCorrelation
chart.RollingCorrelation(___, ___, width = ___)
Code bearbeiten und ausführen