rm(list=ls())

Load Data

library(readr)
FB<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/FB (1).csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_integer()
## )
AAPL<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/AAPL.csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_integer()
## )
AMZN<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/AMZN.csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_integer()
## )
NFLX<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/NFLX.csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_integer()
## )
GOOG<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/GOOG.csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_integer()
## )
SP500<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/SP500.csv")
## Parsed with column specification:
## cols(
##   Date = col_date(format = ""),
##   Open = col_double(),
##   High = col_double(),
##   Low = col_double(),
##   Close = col_double(),
##   `Adj Close` = col_double(),
##   Volume = col_double()
## )
Factors<-read_csv("~/Dropbox/Boston College/Financial Econ/PS4/North_America_3_Factors_Daily.csv")
## Parsed with column specification:
## cols(
##   Date = col_integer(),
##   `Mkt-RF` = col_double(),
##   SMB = col_double(),
##   HML = col_double(),
##   RF = col_double()
## )

Returns

n <- nrow(FB)
FB.Return<-((FB$`Adj Close`[2:n] - FB$`Adj Close`[1:(n-1)])/FB$`Adj Close`[1:(n-1)])
AAPL.Return<-((AAPL$`Adj Close`[2:n] - AAPL$`Adj Close`[1:(n-1)])/AAPL$`Adj Close`[1:(n-1)])
AMZN.Return<-((AMZN$`Adj Close`[2:n] - AMZN$`Adj Close`[1:(n-1)])/AMZN$`Adj Close`[1:(n-1)])
NFLX.Return<-((NFLX$`Adj Close`[2:n] - NFLX$`Adj Close`[1:(n-1)])/NFLX$`Adj Close`[1:(n-1)])
GOOG.Return<-((GOOG$`Adj Close`[2:n] - GOOG$`Adj Close`[1:(n-1)])/GOOG$`Adj Close`[1:(n-1)])
FB.lm<-lm(FB.Return~Factors$`Mkt-RF`[1:754])
AAPL.lm<-lm(AAPL.Return~Factors$`Mkt-RF`[1:754])
AMZN.lm<-lm(AMZN.Return~Factors$`Mkt-RF`[1:754])
NFLX.lm<-lm(NFLX.Return~Factors$`Mkt-RF`[1:754])
GOOG.lm<-lm(GOOG.Return~Factors$`Mkt-RF`[1:754])
summary(FB.lm)
## 
## Call:
## lm(formula = FB.Return ~ Factors$`Mkt-RF`[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.069311 -0.006892 -0.000122  0.008693  0.151178 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              0.0010755  0.0005832   1.844   0.0655 .
## Factors$`Mkt-RF`[1:754] -0.0013461  0.0007330  -1.836   0.0667 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01599 on 752 degrees of freedom
## Multiple R-squared:  0.004465,   Adjusted R-squared:  0.003141 
## F-statistic: 3.373 on 1 and 752 DF,  p-value: 0.06669
summary(AAPL.lm)
## 
## Call:
## lm(formula = AAPL.Return ~ Factors$`Mkt-RF`[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.063897 -0.006433 -0.000300  0.007418  0.066637 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              0.0006396  0.0005227   1.224   0.2214  
## Factors$`Mkt-RF`[1:754] -0.0015117  0.0006569  -2.301   0.0217 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01433 on 752 degrees of freedom
## Multiple R-squared:  0.006993,   Adjusted R-squared:  0.005672 
## F-statistic: 5.296 on 1 and 752 DF,  p-value: 0.02165
summary(AMZN.lm)
## 
## Call:
## lm(formula = AMZN.Return ~ Factors$`Mkt-RF`[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.078300 -0.007842 -0.000409  0.008066  0.140174 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              0.0020541  0.0006448   3.186   0.0015 **
## Factors$`Mkt-RF`[1:754] -0.0020830  0.0008104  -2.570   0.0103 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01768 on 752 degrees of freedom
## Multiple R-squared:  0.008709,   Adjusted R-squared:  0.007391 
## F-statistic: 6.607 on 1 and 752 DF,  p-value: 0.01035
summary(NFLX.lm)
## 
## Call:
## lm(formula = NFLX.Return ~ Factors$`Mkt-RF`[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.133152 -0.011796 -0.002251  0.011539  0.189059 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              0.0025728  0.0009719   2.647  0.00829 **
## Factors$`Mkt-RF`[1:754] -0.0019866  0.0012215  -1.626  0.10430   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02665 on 752 degrees of freedom
## Multiple R-squared:  0.003505,   Adjusted R-squared:  0.00218 
## F-statistic: 2.645 on 1 and 752 DF,  p-value: 0.1043
summary(GOOG.lm)
## 
## Call:
## lm(formula = GOOG.Return ~ Factors$`Mkt-RF`[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.055688 -0.005841 -0.000125  0.006685  0.160804 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              0.0010182  0.0005344   1.905   0.0571 .
## Factors$`Mkt-RF`[1:754] -0.0012126  0.0006716  -1.806   0.0714 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01465 on 752 degrees of freedom
## Multiple R-squared:  0.004316,   Adjusted R-squared:  0.002992 
## F-statistic:  3.26 on 1 and 752 DF,  p-value: 0.0714
FB.lm<-lm(FB.Return~Factors$`Mkt-RF`[1:754]+Factors$SMB[1:754]+Factors$HML[1:754])
AAPL.lm<-lm(AAPL.Return~Factors$`Mkt-RF`[1:754]+Factors$SMB[1:754]+Factors$HML[1:754])
AMZN.lm<-lm(AMZN.Return~Factors$`Mkt-RF`[1:754]+Factors$SMB[1:754]+Factors$HML[1:754])
NFLX.lm<-lm(NFLX.Return~Factors$`Mkt-RF`[1:754]+Factors$SMB[1:754]+Factors$HML[1:754])
GOOG.lm<-lm(GOOG.Return~Factors$`Mkt-RF`[1:754]+Factors$SMB[1:754]+Factors$HML[1:754])
summary(FB.lm)
## 
## Call:
## lm(formula = FB.Return ~ Factors$`Mkt-RF`[1:754] + Factors$SMB[1:754] + 
##     Factors$HML[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.069045 -0.006874 -0.000077  0.008656  0.151669 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              0.0010638  0.0005842   1.821   0.0690 .
## Factors$`Mkt-RF`[1:754] -0.0012427  0.0007513  -1.654   0.0985 .
## Factors$SMB[1:754]      -0.0008194  0.0013224  -0.620   0.5357  
## Factors$HML[1:754]       0.0001291  0.0011060   0.117   0.9071  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01601 on 750 degrees of freedom
## Multiple R-squared:  0.005009,   Adjusted R-squared:  0.001029 
## F-statistic: 1.259 on 3 and 750 DF,  p-value: 0.2875
summary(AAPL.lm)
## 
## Call:
## lm(formula = AAPL.Return ~ Factors$`Mkt-RF`[1:754] + Factors$SMB[1:754] + 
##     Factors$HML[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.063712 -0.006490 -0.000365  0.007611  0.066543 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              6.459e-04  5.234e-04   1.234   0.2175  
## Factors$`Mkt-RF`[1:754] -1.489e-03  6.731e-04  -2.213   0.0272 *
## Factors$SMB[1:754]       6.794e-05  1.185e-03   0.057   0.9543  
## Factors$HML[1:754]       1.033e-03  9.908e-04   1.043   0.2973  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01434 on 750 degrees of freedom
## Multiple R-squared:  0.008431,   Adjusted R-squared:  0.004465 
## F-statistic: 2.126 on 3 and 750 DF,  p-value: 0.09558
summary(AMZN.lm)
## 
## Call:
## lm(formula = AMZN.Return ~ Factors$`Mkt-RF`[1:754] + Factors$SMB[1:754] + 
##     Factors$HML[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.078426 -0.007860 -0.000555  0.008172  0.139546 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              0.0020311  0.0006456   3.146  0.00172 **
## Factors$`Mkt-RF`[1:754] -0.0019114  0.0008303  -2.302  0.02161 * 
## Factors$SMB[1:754]      -0.0014595  0.0014615  -0.999  0.31828   
## Factors$HML[1:754]      -0.0001940  0.0012223  -0.159  0.87391   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01769 on 750 degrees of freedom
## Multiple R-squared:  0.01004,    Adjusted R-squared:  0.006076 
## F-statistic: 2.534 on 3 and 750 DF,  p-value: 0.05579
summary(NFLX.lm)
## 
## Call:
## lm(formula = NFLX.Return ~ Factors$`Mkt-RF`[1:754] + Factors$SMB[1:754] + 
##     Factors$HML[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.131829 -0.012469 -0.002053  0.011543  0.186269 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              0.002606   0.000973   2.678  0.00757 **
## Factors$`Mkt-RF`[1:754] -0.002130   0.001251  -1.702  0.08910 . 
## Factors$SMB[1:754]       0.001599   0.002203   0.726  0.46803   
## Factors$HML[1:754]       0.001712   0.001842   0.929  0.35308   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02666 on 750 degrees of freedom
## Multiple R-squared:  0.005228,   Adjusted R-squared:  0.001249 
## F-statistic: 1.314 on 3 and 750 DF,  p-value: 0.2687
summary(GOOG.lm)
## 
## Call:
## lm(formula = GOOG.Return ~ Factors$`Mkt-RF`[1:754] + Factors$SMB[1:754] + 
##     Factors$HML[1:754])
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.055716 -0.005836 -0.000142  0.006704  0.160695 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)              0.0010204  0.0005354   1.906   0.0571 .
## Factors$`Mkt-RF`[1:754] -0.0012399  0.0006886  -1.801   0.0722 .
## Factors$SMB[1:754]       0.0001923  0.0012120   0.159   0.8740  
## Factors$HML[1:754]      -0.0001335  0.0010137  -0.132   0.8953  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01467 on 750 degrees of freedom
## Multiple R-squared:  0.004377,   Adjusted R-squared:  0.0003945 
## F-statistic: 1.099 on 3 and 750 DF,  p-value: 0.3487

Time Series

library(tseries)
## Warning: package 'tseries' was built under R version 3.4.3
library(forecast)
## Warning: package 'forecast' was built under R version 3.4.4
FB.ts<-ts(FB$`Adj Close`,frequency=250,start=c(2015,63))
AAPL.ts<-ts(AAPL$`Adj Close`,frequency=250,start=c(2015,63))
AMZN.ts<-ts(AMZN$`Adj Close`,frequency=250,start=c(2015,63))
NFLX.ts<-ts(NFLX$`Adj Close`,frequency=250,start=c(2015,63))
GOOG.ts<-ts(GOOG$`Adj Close`,frequency=250,start=c(2015,63))
plot(FB.ts)

plot(AAPL.ts)

plot(AMZN.ts)

plot(NFLX.ts)

plot(GOOG.ts)

Serial Correlation

library(car)
## Warning: package 'car' was built under R version 3.4.3
dwt(FB.lm)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.03520159      1.919896   0.244
##  Alternative hypothesis: rho != 0
dwt(AAPL.lm)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.03436105      1.930637   0.326
##  Alternative hypothesis: rho != 0
dwt(AMZN.lm)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.01843292      1.962736   0.592
##  Alternative hypothesis: rho != 0
dwt(NFLX.lm)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.01677708      1.964642    0.64
##  Alternative hypothesis: rho != 0
dwt(GOOG.lm)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.07235056      1.849815   0.034
##  Alternative hypothesis: rho != 0

(I used the estimate of the factor from the lm function for beta, which I know may be wrong)

  1. Betas: FB= -.0013 AAPL= -.0015 AMZN= -.002 NFLX= -.002 GOOG= -.0012 The risk premium was significant in all five models

  2. Betas: FB= -.0012 AAPL= -.0015 AMZN= -.0019 NFLX= -.0021 GOOG= -.0012 In the AAPL formula, the market risk premium was not significant with a p-value of less than 0.01. The rest of the factors in the other four models were significant.

  3. The importance of using HML and SMB is that it compares the returns of a certain stock to the outperformance of small versus big companies (SMB) and the outperformance of high value companies versus growth portfolios (HML). Both of these factors tend to outperform the market index and they are a good way to see the comparison between these outperformers and the asset at hand.

  4. The first model is basically a CAPM model of each stock, which sets the return of the stock equal to the risk free rate plus the Beta of the stock(multiplied by the market risk premium). The second approach is similar but also includes the HML and SMB factors which I explained in part (c). I think the three factor model is a better indicator of performance since it takes into account two more factors that tell performance related to the market.

  5. All of these stocks are good investments and great companies. Based on my data, I would invest in all of them but Facebook due to higher volatility as of late compared to the market. The other four stocks are all on the rise and have a volitality very similar to that of the market.