Get startedGet started for free

Using Regression to Test the Projections

After visually inspecting the data, you decide that you also want to use regression analysis to determine whether there is a statistically significant shift in the trend from the historical revenues to the projected revenues. Recall you have to create a trend (trend) and a shift (shift) variable.

For this exercise, the revenue data you created in the prior exercise is stored in the rev object. In that data, you will have two time series: historical revenues (hist_rev) and projected revenues (proj_rev). Historical revenues has positive values for the first 10 years of historical data and 0 for projection period. Projected revenues has 0 for the first 10 years and positive values during the projection period.

This exercise is part of the course

Equity Valuation in R

View Course

Exercise instructions

  • Create a single revenue series that adds both historical and projected data.
  • Add a trend variable to rev_all_df using seq().
  • Add a shift variable to rev_all_df using ifelse().
  • Regress rev_all on trend and shift.

Hands-on interactive exercise

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

# Create a data frame of single series
rev_all <- ___
rev_all_df <- data.frame(rev_all)

# Create Trend Variable
rev_all_df$trend <- seq(___, nrow(rev_all_df), ___)

# Create Shift Variable
rev_all_df$shift <- ifelse(rev_all_df$trend <= 7, ___, ___)

# Run regression
reg <- lm(___, data = rev_all_df)
summary(reg)
Edit and Run Code