This note came from Matt Dancho’s webpage.

Factor models are used in many financial appplications, suhc as:

Capital Asset Pricing Model (CAPM) is the most popular factor model. Although CAPM does not perform well in empirical testing, it’s important because it provides a starting point of many cost of capital calculations.

## # A tibble: 16,029 x 8
## # Groups:   symbol [3]
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 AAPL   1990-05-02  1.42  1.43  1.40  1.42 33857600     1.15
##  2 AAPL   1990-05-03  1.42  1.44  1.42  1.43 41577200     1.16
##  3 AAPL   1990-05-04  1.43  1.46  1.40  1.43 42383600     1.16
##  4 AAPL   1990-05-07  1.42  1.49  1.42  1.48 33997600     1.21
##  5 AAPL   1990-05-08  1.46  1.5   1.46  1.49 28114800     1.21
##  6 AAPL   1990-05-09  1.49  1.5   1.47  1.50 24309600     1.22
##  7 AAPL   1990-05-10  1.49  1.49  1.45  1.48 44760800     1.20
##  8 AAPL   1990-05-11  1.48  1.53  1.46  1.52 53810400     1.24
##  9 AAPL   1990-05-14  1.53  1.53  1.47  1.49 56596400     1.21
## 10 AAPL   1990-05-15  1.48  1.5   1.46  1.49 37346400     1.21
## # … with 16,019 more rows
## # A tibble: 768 x 3
## # Groups:   symbol [3]
##    symbol date            Ra
##    <chr>  <date>       <dbl>
##  1 AAPL   1990-05-31  0.0406
##  2 AAPL   1990-06-29  0.0848
##  3 AAPL   1990-07-31 -0.0615
##  4 AAPL   1990-08-31 -0.116 
##  5 AAPL   1990-09-28 -0.216 
##  6 AAPL   1990-10-31  0.0603
##  7 AAPL   1990-11-30  0.199 
##  8 AAPL   1990-12-31  0.170 
##  9 AAPL   1991-01-31  0.291 
## 10 AAPL   1991-02-28  0.0337
## # … with 758 more rows
## # A tibble: 361 x 2
##    date             Rb
##    <date>        <dbl>
##  1 1990-05-31  0.0836 
##  2 1990-06-29  0.00719
##  3 1990-07-31 -0.0521 
##  4 1990-08-31 -0.130  
##  5 1990-09-28 -0.0963 
##  6 1990-10-31 -0.0427 
##  7 1990-11-30  0.0888 
##  8 1990-12-31  0.0409 
##  9 1991-01-31  0.108  
## 10 1991-02-28  0.0939 
## # … with 351 more rows
## # A tibble: 768 x 4
## # Groups:   symbol [3]
##    symbol date            Ra       Rb
##    <chr>  <date>       <dbl>    <dbl>
##  1 AAPL   1990-05-31  0.0406  0.0836 
##  2 AAPL   1990-06-29  0.0848  0.00719
##  3 AAPL   1990-07-31 -0.0615 -0.0521 
##  4 AAPL   1990-08-31 -0.116  -0.130  
##  5 AAPL   1990-09-28 -0.216  -0.0963 
##  6 AAPL   1990-10-31  0.0603 -0.0427 
##  7 AAPL   1990-11-30  0.199   0.0888 
##  8 AAPL   1990-12-31  0.170   0.0409 
##  9 AAPL   1991-01-31  0.291   0.108  
## 10 AAPL   1991-02-28  0.0337  0.0939 
## # … with 758 more rows
## # A tibble: 3 x 13
## # Groups:   symbol [3]
##   symbol ActivePremium  Alpha AnnualizedAlpha  Beta `Beta-` `Beta+` Correlation
##   <chr>          <dbl>  <dbl>           <dbl> <dbl>   <dbl>   <dbl>       <dbl>
## 1 AAPL          0.0962 0.0123           0.157  1.08    1.04   1.12        0.544
## 2 GOOG          0.129  0.0116           0.149  1.03    1.06   0.937       0.565
## 3 NFLX          0.288  0.0305           0.434  1.16    1.15   0.772       0.353
## # … with 5 more variables: `Correlationp-value` <dbl>, InformationRatio <dbl>,
## #   `R-squared` <dbl>, TrackingError <dbl>, TreynorRatio <dbl>

Interpretation

Q1 Import stock prices of Apple, Microsoft and Amazon for the last 20 years.

## # A tibble: 15,096 x 8
## # Groups:   symbol [3]
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AAPL   2000-05-02  4.40  4.51  4.20  4.21  59108000     3.65
##  2 AAPL   2000-05-03  4.25  4.33  3.99  4.11 122449600     3.57
##  3 AAPL   2000-05-04  4.11  4.12  3.95  3.95  99878800     3.43
##  4 AAPL   2000-05-05  3.96  4.10  3.95  4.04  71019200     3.51
##  5 AAPL   2000-05-08  4.00  4.06  3.93  3.93  46225200     3.41
##  6 AAPL   2000-05-09  3.94  3.97  3.75  3.77  81785200     3.27
##  7 AAPL   2000-05-10  3.72  3.75  3.53  3.55 133772800     3.08
##  8 AAPL   2000-05-11  3.62  3.72  3.54  3.67 124936000     3.19
##  9 AAPL   2000-05-12  3.79  3.95  3.74  3.84  76728400     3.34
## 10 AAPL   2000-05-15  3.86  3.86  3.58  3.61 169733200     3.13
## # … with 15,086 more rows

Q2 Calculate monthly returns.

## # A tibble: 723 x 3
## # Groups:   symbol [3]
##    symbol date            Ra
##    <chr>  <date>       <dbl>
##  1 AAPL   2000-05-31 -0.287 
##  2 AAPL   2000-06-30  0.247 
##  3 AAPL   2000-07-31 -0.0298
##  4 AAPL   2000-08-31  0.199 
##  5 AAPL   2000-09-29 -0.577 
##  6 AAPL   2000-10-31 -0.240 
##  7 AAPL   2000-11-30 -0.157 
##  8 AAPL   2000-12-29 -0.0985
##  9 AAPL   2001-01-31  0.454 
## 10 AAPL   2001-02-28 -0.156 
## # … with 713 more rows

Q3 Import baseline prices and calculate its monthly return.

Hint: Use NASDAQ Compsite Index as baseline.

## # A tibble: 241 x 2
##    date            Rb
##    <date>       <dbl>
##  1 2000-05-31 -0.102 
##  2 2000-06-30  0.166 
##  3 2000-07-31 -0.0502
##  4 2000-08-31  0.117 
##  5 2000-09-29 -0.127 
##  6 2000-10-31 -0.0825
##  7 2000-11-30 -0.229 
##  8 2000-12-29 -0.0490
##  9 2001-01-31  0.122 
## 10 2001-02-28 -0.224 
## # … with 231 more rows

Q4 Merge the two sets of monthly returns.

## # A tibble: 723 x 4
## # Groups:   symbol [3]
##    symbol date            Ra      Rb
##    <chr>  <date>       <dbl>   <dbl>
##  1 AAPL   2000-05-31 -0.287  -0.102 
##  2 AAPL   2000-06-30  0.247   0.166 
##  3 AAPL   2000-07-31 -0.0298 -0.0502
##  4 AAPL   2000-08-31  0.199   0.117 
##  5 AAPL   2000-09-29 -0.577  -0.127 
##  6 AAPL   2000-10-31 -0.240  -0.0825
##  7 AAPL   2000-11-30 -0.157  -0.229 
##  8 AAPL   2000-12-29 -0.0985 -0.0490
##  9 AAPL   2001-01-31  0.454   0.122 
## 10 AAPL   2001-02-28 -0.156  -0.224 
## # … with 713 more rows

Q5 Calculate performance metrics, CAPM measures.

## # A tibble: 3 x 13
## # Groups:   symbol [3]
##   symbol ActivePremium  Alpha AnnualizedAlpha  Beta `Beta-` `Beta+` Correlation
##   <chr>          <dbl>  <dbl>           <dbl> <dbl>   <dbl>   <dbl>       <dbl>
## 1 AAPL          0.201  0.0191          0.254  1.19    1.09     1.31       0.638
## 2 MSFT          0.0659 0.0069          0.0861 0.871   0.595    1.00       0.682
## 3 AMZN          0.161  0.0172          0.227  1.35    1.35     1.52       0.620
## # … with 5 more variables: `Correlationp-value` <dbl>, InformationRatio <dbl>,
## #   `R-squared` <dbl>, TrackingError <dbl>, TreynorRatio <dbl>

Q6 Interpet the alpha.

All 3 stocks, AAPL, AMZN, and MSFT, are expecting returns in excess to the benchmark.

Q7 Interpret the beta.

Beta is a measure of a stock’s sensativity relative to the market. AAPL and AMZN have a beta greater than 1, making them more sensative to changes in the market. MSFT has a beta less than 1, making it less sensative, a defensive stock.

Q8 Hide the messages and the code, but display results of the code from the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.