Get startedGet started for free

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().

This exercise is part of the course

Introduction to Portfolio Analysis in R

View Course

Exercise instructions

  • 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().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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 = ___)
Edit and Run Code