1. Learn
  2. /
  3. Courses
  4. /
  5. Equity Valuation in R

Exercise

Calculating Returns

Suppose you are valuing a healthcare company and need to determine the firm's beta using peer companies. One of the peer companies you identified is Mylan (myl), which is a global healthcare company. In this exercise, you are asked to calculate Mylan's and the S&P 500 ETF's monthly returns over the last five years. Five years of monthly prices for myl and spy are stored in prices.

Use the Delt() function to calculate returns. The Delt() function is from the package quantmod, which has also been loaded in memory. Note that the Delt() function requires two observations to calculate a return, so in the time series data that we have the first observation will have a missing value. Thus, after calculating the returns for the remaining dates, we want to delete that first observation (i.e., the observation with a missing return) from the data.

Instructions

100 XP
  • Show first six observations of prices.
  • Calculate monthly returns for MYL and SPY.
  • Change label of first variable to "myl".
  • Remove the first observation, which is a missing value.