setwd("C:/Users/Samantha/Desktop/Financial Econometrics")
Read files
library(readr)
package 㤼㸱readr㤼㸲 was built under R version 4.0.4
portfolios<-read_csv("C:/Users/Samantha/Desktop/Financial Econometrics/portfolios.CSV")
-- Column specification --------------------------------------------------------
cols(
.default = col_double()
)
i Use `spec()` for the full column specifications.
famafrench<-read_csv("C:/Users/Samantha/Desktop/Financial Econometrics/famafrench.CSV")
-- Column specification --------------------------------------------------------
cols(
YearMonth = col_double(),
`Mkt-RF` = col_double(),
SMB = col_double(),
HML = col_double(),
RF = col_double()
)
#Question 1: Drop columns we do not need
library (dplyr)
Attaching package: 㤼㸱dplyr㤼㸲
The following objects are masked from 㤼㸱package:stats㤼㸲:
filter, lag
The following objects are masked from 㤼㸱package:base㤼㸲:
intersect, setdiff, setequal, union
portfolios2<-select(portfolios,-"<= 0", -"Lo 30", -"Med 40", -"Hi 30", -"Lo 20", -"Qnt 2", -"Qnt 3", -"Qnt 4", -"Hi 20")
#Question 2: Combine tables using inner_join from dplyr in one table called factors
factors<-inner_join(portfolios2,famafrench,by="YearMonth")
#Question 3: Create the CAPM for the Lo 10 portfolio:
size.capm_Lo10 <- lm(factors$`Lo 10` ~ factors$`Mkt-RF`)
coef(size.capm_Lo10)
(Intercept) factors$`Mkt-RF`
0.6254334 0.9996396
summary(size.capm_Lo10)
Call:
lm(formula = factors$`Lo 10` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-16.9621 -2.7728 -0.2267 2.2589 26.6354
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.62543 0.23409 2.672 0.00788 **
factors$`Mkt-RF` 0.99964 0.05318 18.797 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.459 on 366 degrees of freedom
Multiple R-squared: 0.4912, Adjusted R-squared: 0.4898
F-statistic: 353.3 on 1 and 366 DF, p-value: < 2.2e-16
#QUestion 4: Estimate the CAPM for all 10 portfolios and summarize the resulting β0for the intercept as well as the resulting β1 for the MKT indicator. Make a similar summary for the goodness-of-fit of these 10 regression models. We run the regressions for the other remaining 9 portfolios.
Portfolio Dec 2
size.capm_Dec2<- lm(factors$`Dec 2` ~ factors$`Mkt-RF`)
coef(size.capm_Dec2)
(Intercept) factors$`Mkt-RF`
0.5516835 1.1165239
summary(size.capm_Dec2)
Call:
lm(formula = factors$`Dec 2` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-17.3812 -3.0229 -0.3127 2.3158 22.7726
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.55168 0.23100 2.388 0.0174 *
factors$`Mkt-RF` 1.11652 0.05248 21.276 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.4 on 366 degrees of freedom
Multiple R-squared: 0.5529, Adjusted R-squared: 0.5517
F-statistic: 452.7 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 3
size.capm_Dec3<- lm(factors$`Dec 3` ~ factors$`Mkt-RF`)
coef(size.capm_Dec3)
(Intercept) factors$`Mkt-RF`
0.5560827 1.0988465
summary(size.capm_Dec3)
Call:
lm(formula = factors$`Dec 3` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-16.6203 -2.5112 -0.0512 2.2058 15.2685
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.5561 0.1963 2.832 0.00488 **
factors$`Mkt-RF` 1.0989 0.0446 24.635 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.74 on 366 degrees of freedom
Multiple R-squared: 0.6238, Adjusted R-squared: 0.6228
F-statistic: 606.9 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 4
size.capm_Dec4<- lm(factors$`Dec 4` ~ factors$`Mkt-RF`)
coef(size.capm_Dec4)
(Intercept) factors$`Mkt-RF`
0.482102 1.071077
summary(size.capm_Dec4)
Call:
lm(formula = factors$`Dec 4` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-16.1767 -2.2133 -0.0375 2.0520 14.4658
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.48210 0.18221 2.646 0.0085 **
factors$`Mkt-RF` 1.07108 0.04139 25.875 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.471 on 366 degrees of freedom
Multiple R-squared: 0.6466, Adjusted R-squared: 0.6456
F-statistic: 669.5 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 5
size.capm_Dec5<- lm(factors$`Dec 5` ~ factors$`Mkt-RF`)
coef(size.capm_Dec5)
(Intercept) factors$`Mkt-RF`
0.5281752 1.0839636
summary(size.capm_Dec5)
Call:
lm(formula = factors$`Dec 5` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-16.4432 -1.9591 0.0891 1.9299 12.7642
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.52818 0.16715 3.16 0.00171 **
factors$`Mkt-RF` 1.08396 0.03797 28.55 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.184 on 366 degrees of freedom
Multiple R-squared: 0.6901, Adjusted R-squared: 0.6892
F-statistic: 814.9 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 6
size.capm_Dec6<- lm(factors$`Dec 6` ~ factors$`Mkt-RF`)
coef(size.capm_Dec6)
(Intercept) factors$`Mkt-RF`
0.5561633 1.0168632
summary(size.capm_Dec6)
Call:
lm(formula = factors$`Dec 6` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-13.7738 -1.7044 -0.0535 1.5698 12.1766
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.55616 0.14492 3.838 0.000146 ***
factors$`Mkt-RF` 1.01686 0.03292 30.887 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.76 on 366 degrees of freedom
Multiple R-squared: 0.7227, Adjusted R-squared: 0.722
F-statistic: 954 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 7
size.capm_Dec7<- lm(factors$`Dec 7` ~ factors$`Mkt-RF`)
coef(size.capm_Dec7)
(Intercept) factors$`Mkt-RF`
0.5726343 1.0209530
summary(size.capm_Dec7)
Call:
lm(formula = factors$`Dec 7` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-13.129 -1.349 -0.131 1.239 11.215
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.57263 0.13086 4.376 1.58e-05 ***
factors$`Mkt-RF` 1.02095 0.02973 34.344 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.492 on 366 degrees of freedom
Multiple R-squared: 0.7632, Adjusted R-squared: 0.7625
F-statistic: 1180 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 8
size.capm_Dec8<- lm(factors$`Dec 8` ~ factors$`Mkt-RF`)
coef(size.capm_Dec8)
(Intercept) factors$`Mkt-RF`
0.5689677 1.0051850
summary(size.capm_Dec8)
Call:
lm(formula = factors$`Dec 8` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-12.8374 -1.2526 0.0201 1.1779 12.7003
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.5690 0.1255 4.535 7.83e-06 ***
factors$`Mkt-RF` 1.0052 0.0285 35.266 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.39 on 366 degrees of freedom
Multiple R-squared: 0.7726, Adjusted R-squared: 0.772
F-statistic: 1244 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Dec 9
size.capm_Dec9<- lm(factors$`Dec 9` ~ factors$`Mkt-RF`)
coef(size.capm_Dec9)
(Intercept) factors$`Mkt-RF`
0.5635456 0.9190272
summary(size.capm_Dec9)
Call:
lm(formula = factors$`Dec 9` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-11.5165 -1.1190 -0.0242 1.0569 12.5852
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.56355 0.10964 5.14 4.48e-07 ***
factors$`Mkt-RF` 0.91903 0.02491 36.90 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.088 on 366 degrees of freedom
Multiple R-squared: 0.7881, Adjusted R-squared: 0.7876
F-statistic: 1362 on 1 and 366 DF, p-value: < 2.2e-16
Portfolio Hi 10
size.capm_Hi10<- lm(factors$`Hi 10` ~ factors$`Mkt-RF`)
coef(size.capm_Hi10)
(Intercept) factors$`Mkt-RF`
0.4518659 0.8501523
summary(size.capm_Hi10)
Call:
lm(formula = factors$`Hi 10` ~ factors$`Mkt-RF`)
Residuals:
Min 1Q Median 3Q Max
-7.8808 -1.0944 -0.0697 1.0180 8.3507
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.45187 0.10270 4.40 1.42e-05 ***
factors$`Mkt-RF` 0.85015 0.02333 36.44 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.956 on 366 degrees of freedom
Multiple R-squared: 0.7839, Adjusted R-squared: 0.7833
F-statistic: 1328 on 1 and 366 DF, p-value: < 2.2e-16