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,025 x 8
## # Groups:   symbol [3]
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 AAPL   1990-04-30  1.40  1.42  1.39  1.41 34098400     1.14
##  2 AAPL   1990-05-01  1.42  1.43  1.41  1.42 40902400     1.15
##  3 AAPL   1990-05-02  1.42  1.43  1.40  1.42 33857600     1.15
##  4 AAPL   1990-05-03  1.42  1.44  1.42  1.43 41577200     1.16
##  5 AAPL   1990-05-04  1.43  1.46  1.40  1.43 42383600     1.16
##  6 AAPL   1990-05-07  1.42  1.49  1.42  1.48 33997600     1.21
##  7 AAPL   1990-05-08  1.46  1.5   1.46  1.49 28114800     1.21
##  8 AAPL   1990-05-09  1.49  1.5   1.47  1.50 24309600     1.22
##  9 AAPL   1990-05-10  1.49  1.49  1.45  1.48 44760800     1.20
## 10 AAPL   1990-05-11  1.48  1.53  1.46  1.52 53810400     1.24
## # … with 16,015 more rows
## # A tibble: 766 x 3
## # Groups:   symbol [3]
##    symbol date            Ra
##    <chr>  <date>       <dbl>
##  1 AAPL   1990-04-30  0     
##  2 AAPL   1990-05-31  0.0505
##  3 AAPL   1990-06-29  0.0848
##  4 AAPL   1990-07-31 -0.0615
##  5 AAPL   1990-08-31 -0.116 
##  6 AAPL   1990-09-28 -0.216 
##  7 AAPL   1990-10-31  0.0603
##  8 AAPL   1990-11-30  0.199 
##  9 AAPL   1990-12-31  0.170 
## 10 AAPL   1991-01-31  0.291 
## # … with 756 more rows
## # A tibble: 361 x 2
##    date             Rb
##    <date>        <dbl>
##  1 1990-04-30  0      
##  2 1990-05-31  0.0926 
##  3 1990-06-29  0.00719
##  4 1990-07-31 -0.0521 
##  5 1990-08-31 -0.130  
##  6 1990-09-28 -0.0963 
##  7 1990-10-31 -0.0427 
##  8 1990-11-30  0.0888 
##  9 1990-12-31  0.0409 
## 10 1991-01-31  0.108  
## # … with 351 more rows
## # A tibble: 766 x 4
## # Groups:   symbol [3]
##    symbol date            Ra       Rb
##    <chr>  <date>       <dbl>    <dbl>
##  1 AAPL   1990-04-30  0       0      
##  2 AAPL   1990-05-31  0.0505  0.0926 
##  3 AAPL   1990-06-29  0.0848  0.00719
##  4 AAPL   1990-07-31 -0.0615 -0.0521 
##  5 AAPL   1990-08-31 -0.116  -0.130  
##  6 AAPL   1990-09-28 -0.216  -0.0963 
##  7 AAPL   1990-10-31  0.0603 -0.0427 
##  8 AAPL   1990-11-30  0.199   0.0888 
##  9 AAPL   1990-12-31  0.170   0.0409 
## 10 AAPL   1991-01-31  0.291   0.108  
## # … with 756 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.0948 0.0122           0.156  1.08    1.04   1.11        0.543
## 2 GOOG          0.129  0.0116           0.148  1.03    1.06   0.925       0.564
## 3 NFLX          0.286  0.0305           0.434  1.15    1.15   0.746       0.351
## # … 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,093 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-01  4.46  4.47  4.35  4.44  56548800     3.85
##  2 AAPL   2000-05-02  4.40  4.51  4.20  4.21  59108000     3.65
##  3 AAPL   2000-05-03  4.25  4.33  3.99  4.11 122449600     3.57
##  4 AAPL   2000-05-04  4.11  4.12  3.95  3.95  99878800     3.43
##  5 AAPL   2000-05-05  3.96  4.10  3.95  4.04  71019200     3.51
##  6 AAPL   2000-05-08  4.00  4.06  3.93  3.93  46225200     3.41
##  7 AAPL   2000-05-09  3.94  3.97  3.75  3.77  81785200     3.27
##  8 AAPL   2000-05-10  3.72  3.75  3.53  3.55 133772800     3.08
##  9 AAPL   2000-05-11  3.62  3.72  3.54  3.67 124936000     3.19
## 10 AAPL   2000-05-12  3.79  3.95  3.74  3.84  76728400     3.34
## # … with 15,083 more rows

Q2 Calculate monthly returns.

## # A tibble: 720 x 3
## # Groups:   symbol [3]
##    symbol date            Ra
##    <chr>  <date>       <dbl>
##  1 AAPL   2000-05-31 -0.324 
##  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 710 more rows

Q3 Import baseline prices and calculate its monthly return.

Hint: Use NASDAQ Compsite Index as baseline.

## # A tibble: 240 x 2
##    date            Rb
##    <date>       <dbl>
##  1 2000-05-31 -0.141 
##  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 230 more rows

Q4 Merge the two sets of monthly returns.

## # A tibble: 720 x 4
## # Groups:   symbol [3]
##    symbol date            Ra      Rb
##    <chr>  <date>       <dbl>   <dbl>
##  1 AAPL   2000-05-31 -0.324  -0.141 
##  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 710 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.199  0.019           0.253  1.19    1.12    1.29        0.641
## 2 MSFT          0.0648 0.0068          0.0851 0.871   0.608   0.992       0.683
## 3 AMZN          0.160  0.0172          0.227  1.34    1.36    1.48        0.619
## # … with 5 more variables: `Correlationp-value` <dbl>, InformationRatio <dbl>,
## #   `R-squared` <dbl>, TrackingError <dbl>, TreynorRatio <dbl>

Q6 Interpet the alpha.

Apple performed the best according to the Alpha value or the Y-Intercept. They had a alpha of 0.0190 or 1.9% meaning that they performed 1.9% better than the market value. All of these companies performed better than the market: Microsoft by .68% and Amazon by 1.72%. In terms of returns all of these stocks outperformed the market and would be a good investment.

Q7 Interpret the beta.

Companies that have a Beta less than 1 are generally less risky and less affected by market movements so microsoft according to the Beta value is the least risky out at a Beta value of 0.8706. Apple has a Beta of 1.1932 and Amazon has a Beta of 1.3403. If you are less of a risk taker the best company to invest in would be Microsoft and Amazon would be the best company if you are willing to take more risk.

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.