Exercise

Plotting consecutive portfolio returns

Regression to the mean is also an important concept in investing. Here you'll look at the annual returns from investing in companies in the Standard and Poor 500 index (S&P 500), in 2018 and 2019.

The sp500_yearly_returns dataset contains three columns:

variable meaning
symbol Stock ticker symbol uniquely identifying the company.
return_2018 A measure of investment performance in 2018.
return_2019 A measure of investment performance in 2019.

A positive number for the return means the investment increased in value; negative means it lost value.

Just as with baseball home runs, a naive prediction might be that the investment performance stays the same from year to year, lying on the "y equals x" line.

sp500_yearly_returns is available and ggplot2 is loaded.

Instructions

100 XP
  • Using sp500_yearly_returns, draw a scatter plot of return_2019 vs. return_2018.
  • Add an "A-B line", colored "green", with size 1.
  • Add a smooth trend line made with the linear regression method, and no standard error ribbon.
  • Fix the coordinates so distances along the x and y axes appear the same.