The Fama-French Model

Import the data

# import install.packages('ggplot2')
rm(list = ls())
require(ggplot2)
## Loading required package: ggplot2
## Warning: there is no package called 'ggplot2'
# Fama french factor returns source
# http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
# Downloaded September 2013 This file was created by CMPT_ME_BEME_RETS using
# the 201308 CRSP database. The 1-month TBill return is from Ibbotson and
# Associates, Inc.
data <- read.table("data.txt", comment.char = "%")
colnames(data) = c("Date", "MktRF", "SMB", "HML", "RF")
head(data)
##     Date MktRF   SMB   HML   RF
## 1 192607  2.65 -2.39 -2.57 0.22
## 2 192608  2.59 -1.27  4.58 0.25
## 3 192609  0.37 -1.25 -0.09 0.23
## 4 192610 -3.45 -0.02  1.02 0.32
## 5 192611  2.43 -0.24 -0.63 0.31
## 6 192612  2.74 -0.12  0.16 0.28
FamaDataRaw = ts(data[2:5], frequency = 12, start = c(1926, 7))
# Fama french 25 size and book/market portoflio returns source
# http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
# Downloaded September 2013 Average Value Weighted Returns -- Monthly
port25 <- read.table("portfolio25.txt", comment.char = "%")
colnames(port25) = c("Date", 1:25)
head(port25)
##     Date     1      2     3     4     5     6     7     8     9    10
## 1 192607  5.59 -10.14 -0.50 -1.32 -0.64  1.84  4.97  2.42 -0.79  2.05
## 2 192608 -1.72  -4.29  3.10  0.79  4.82  2.40 -2.97  3.02  2.41  7.19
## 3 192609 -5.08  -2.48 -5.64  2.50  0.75 -2.44 -1.51  1.15 -1.47 -2.14
## 4 192610 -9.40  -6.62 -4.89 -0.23 -3.06 -4.02 -3.90 -7.02 -5.13 -0.56
## 5 192611  5.88   5.32  2.55 -3.58  1.40  2.54 -2.27  4.03  2.62  1.41
## 6 192612 14.62   0.73 -0.84  5.32  2.15  3.23  4.02  2.81  0.95  3.45
##      11    12    13    14    15    16    17    18    19    20    21    22
## 1  1.56  2.70 -0.98  3.43 -2.01  2.18  1.10  1.16  0.57  2.56  3.37  6.08
## 2 -1.05  1.59  2.90  4.82  8.49  0.83  3.95  1.86  2.10  4.47  1.15  4.10
## 3 -0.45  1.11 -2.57  1.86 -3.31  1.45 -0.74 -1.62  1.57  2.18 -1.31  3.66
## 4 -4.81 -2.11 -0.11 -1.96 -3.21 -2.16 -1.76 -2.08 -2.91 -5.21 -2.84 -3.14
## 5  1.82  4.62  2.74  3.82  3.75  3.63  2.31  3.77  4.94  1.78  4.29  2.61
## 6 -1.32  2.26 -1.01  3.11  0.62  2.68  2.36  2.21  2.70  1.80  1.50  3.48
##      23    24    25
## 1  2.00  2.93  0.56
## 2  1.81  5.64  7.76
## 3 -0.23 -0.30 -2.43
## 4 -2.21 -4.59 -5.81
## 5  1.47  3.55  2.56
## 6  2.07  5.75  2.41
tsport25Raw = ts(port25[2:26], frequency = 12, start = c(1926, 7))

Use the sample from 196301 to the end of the sample. In this way you can see how well FF's results hold up with 20 more years of data. Start by replicating Table 1A of mean returns. You should get about the same pattern FF did. Here is my table so you know if you've got to this point ok.

constantStart = 1963
dStart = c(constantStart, 1)
dEnd = c(2013, 8)
FamaData = window(FamaDataRaw, start = dStart, end = dEnd, frequency = 12)
tsport25 = window(tsport25Raw, start = dStart, end = dEnd, frequency = 12)

Adjust for excess return

window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##              1     2     3     4     5     6     7     8     9    10    11
## Jan 1963 13.02 11.44  9.39 10.96 11.13  7.63  5.81  7.56  8.72 11.26  6.37
## Feb 1963 -3.25 -3.49 -0.74 -0.83  2.78 -4.02 -1.89 -2.43 -1.68 -0.36 -3.76
## Mar 1963  4.98 -1.47 -0.15  1.24  2.61 -0.16  1.18  1.21  2.93  1.46 -0.05
## Apr 1963  4.80  1.50  1.88  3.61  2.78  2.33  5.32  0.53  4.37  6.09  3.56
## May 1963  3.39  1.68  2.72  4.12  7.92  2.09  2.73  0.92  5.00  4.80  2.35
## Jun 1963  3.77 -1.17 -1.35 -2.46 -1.09 -0.03 -1.74 -1.97 -1.99 -1.70 -1.30
## Jul 1963  0.85  0.24  0.56 -0.02 -1.22 -1.87  0.29 -0.84 -1.90 -1.19 -1.84
## Aug 1963  3.80  2.15  1.32  2.29  4.73  5.40  4.65  4.36  4.33  8.23  5.36
## Sep 1963 -2.70  0.26 -1.09 -1.59 -0.38 -3.92 -1.57 -0.64 -1.13 -2.91 -4.65
## Oct 1963  1.36 -0.63  1.24  0.05  2.37  1.19  4.30  2.34  2.26  3.93  2.26
## Nov 1963 -3.11 -4.32 -1.60 -1.00 -1.11 -4.18 -1.76 -0.71 -0.09 -0.11 -2.92
## Dec 1963 -2.94 -0.55 -0.90 -1.75 -0.97 -0.68 -0.91  1.15  0.97  0.12  0.60
##             12    13    14    15    16    17    18    19    20    21    22
## Jan 1963  5.71  4.75  8.74  9.33  5.40  4.89  5.87  9.71  6.31  5.27  4.09
## Feb 1963 -1.34 -0.57 -2.24  0.89 -3.07 -1.33 -0.91 -0.92 -0.59 -3.28 -1.61
## Mar 1963  1.40  1.37  3.54  1.73  2.03  1.72  2.79  3.48  3.72  3.73  2.83
## Apr 1963  4.15  3.02  3.13  5.11  4.29  3.33  4.97  7.25  4.44  4.86  4.14
## May 1963  2.13  2.44  5.22  6.04  1.57  1.57  1.90  4.18  3.69  3.22 -0.36
## Jun 1963 -0.65 -2.42 -2.78 -1.05 -1.46 -1.38 -2.52 -2.93  1.26 -3.23 -0.94
## Jul 1963 -1.87 -0.81 -2.21 -1.80 -0.93 -1.63 -2.07 -1.67 -1.86  0.14  0.46
## Aug 1963  4.62  5.63  4.72  5.15  5.59  4.81  6.12  7.56  5.35  5.77  4.22
## Sep 1963 -1.52 -0.69 -0.10 -1.82 -2.67 -1.95 -2.00 -3.58 -1.99 -1.37 -0.77
## Oct 1963  0.50  2.70  2.16  1.07 -0.24  0.93  2.30  5.34  0.61  5.33  1.73
## Nov 1963 -1.58 -0.91 -0.90 -1.21 -0.91 -0.86 -0.51  1.15  3.54 -1.26  0.98
## Dec 1963  1.17  1.52  1.52  0.47 -0.17  1.27  1.63  3.14  6.15  2.62  2.30
##             23    24    25
## Jan 1963  3.46  6.51  6.40
## Feb 1963 -2.05 -1.41 -0.94
## Mar 1963  4.57  4.82  5.63
## Apr 1963  5.98  4.05  8.00
## May 1963  1.82  2.30  4.32
## Jun 1963 -0.74 -2.00  0.36
## Jul 1963  1.23 -0.45 -1.11
## Aug 1963  4.77  8.16  6.25
## Sep 1963 -0.98 -0.12 -3.82
## Oct 1963 -0.26  2.36  0.48
## Nov 1963 -1.55 -2.05  1.37
## Dec 1963  2.28  2.38  2.37
for (i in 1:25) {
    tsport25[, i] = tsport25[, i] - FamaData[, "RF"]
}
window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##              1     2     3     4     5     6     7     8     9    10    11
## Jan 1963 12.77 11.19  9.14 10.71 10.88  7.38  5.56  7.31  8.47 11.01  6.12
## Feb 1963 -3.48 -3.72 -0.97 -1.06  2.55 -4.25 -2.12 -2.66 -1.91 -0.59 -3.99
## Mar 1963  4.75 -1.70 -0.38  1.01  2.38 -0.39  0.95  0.98  2.70  1.23 -0.28
## Apr 1963  4.55  1.25  1.63  3.36  2.53  2.08  5.07  0.28  4.12  5.84  3.31
## May 1963  3.15  1.44  2.48  3.88  7.68  1.85  2.49  0.68  4.76  4.56  2.11
## Jun 1963  3.54 -1.40 -1.58 -2.69 -1.32 -0.26 -1.97 -2.20 -2.22 -1.93 -1.53
## Jul 1963  0.58 -0.03  0.29 -0.29 -1.49 -2.14  0.02 -1.11 -2.17 -1.46 -2.11
## Aug 1963  3.55  1.90  1.07  2.04  4.48  5.15  4.40  4.11  4.08  7.98  5.11
## Sep 1963 -2.97 -0.01 -1.36 -1.86 -0.65 -4.19 -1.84 -0.91 -1.40 -3.18 -4.92
## Oct 1963  1.07 -0.92  0.95 -0.24  2.08  0.90  4.01  2.05  1.97  3.64  1.97
## Nov 1963 -3.38 -4.59 -1.87 -1.27 -1.38 -4.45 -2.03 -0.98 -0.36 -0.38 -3.19
## Dec 1963 -3.23 -0.84 -1.19 -2.04 -1.26 -0.97 -1.20  0.86  0.68 -0.17  0.31
##             12    13    14    15    16    17    18    19    20    21    22
## Jan 1963  5.46  4.50  8.49  9.08  5.15  4.64  5.62  9.46  6.06  5.02  3.84
## Feb 1963 -1.57 -0.80 -2.47  0.66 -3.30 -1.56 -1.14 -1.15 -0.82 -3.51 -1.84
## Mar 1963  1.17  1.14  3.31  1.50  1.80  1.49  2.56  3.25  3.49  3.50  2.60
## Apr 1963  3.90  2.77  2.88  4.86  4.04  3.08  4.72  7.00  4.19  4.61  3.89
## May 1963  1.89  2.20  4.98  5.80  1.33  1.33  1.66  3.94  3.45  2.98 -0.60
## Jun 1963 -0.88 -2.65 -3.01 -1.28 -1.69 -1.61 -2.75 -3.16  1.03 -3.46 -1.17
## Jul 1963 -2.14 -1.08 -2.48 -2.07 -1.20 -1.90 -2.34 -1.94 -2.13 -0.13  0.19
## Aug 1963  4.37  5.38  4.47  4.90  5.34  4.56  5.87  7.31  5.10  5.52  3.97
## Sep 1963 -1.79 -0.96 -0.37 -2.09 -2.94 -2.22 -2.27 -3.85 -2.26 -1.64 -1.04
## Oct 1963  0.21  2.41  1.87  0.78 -0.53  0.64  2.01  5.05  0.32  5.04  1.44
## Nov 1963 -1.85 -1.18 -1.17 -1.48 -1.18 -1.13 -0.78  0.88  3.27 -1.53  0.71
## Dec 1963  0.88  1.23  1.23  0.18 -0.46  0.98  1.34  2.85  5.86  2.33  2.01
##             23    24    25
## Jan 1963  3.21  6.26  6.15
## Feb 1963 -2.28 -1.64 -1.17
## Mar 1963  4.34  4.59  5.40
## Apr 1963  5.73  3.80  7.75
## May 1963  1.58  2.06  4.08
## Jun 1963 -0.97 -2.23  0.13
## Jul 1963  0.96 -0.72 -1.38
## Aug 1963  4.52  7.91  6.00
## Sep 1963 -1.25 -0.39 -4.09
## Oct 1963 -0.55  2.07  0.19
## Nov 1963 -1.82 -2.32  1.10
## Dec 1963  1.99  2.09  2.08

Check

format(colMeans(tsport25), digit = 2)
##      1      2      3      4      5      6      7      8      9     10 
## "0.27" "0.79" "0.83" "1.01" "1.16" "0.46" "0.71" "0.91" "0.94" "1.02" 
##     11     12     13     14     15     16     17     18     19     20 
## "0.48" "0.77" "0.77" "0.87" "1.08" "0.59" "0.56" "0.70" "0.85" "0.86" 
##     21     22     23     24     25 
## "0.45" "0.50" "0.47" "0.56" "0.63"

Run a lot of Regression

model = lm(tsport25 ~ FamaData[, "MktRF"])
alphas = coef(model)[1, ]
betas = coef(model)[2, ]
format(betas, digit = 2)
##      1      2      3      4      5      6      7      8      9     10 
## "1.43" "1.23" "1.10" "1.02" "1.08" "1.40" "1.17" "1.06" "1.01" "1.11" 
##     11     12     13     14     15     16     17     18     19     20 
## "1.33" "1.12" "1.00" "0.96" "1.03" "1.22" "1.08" "1.03" "0.95" "1.04" 
##     21     22     23     24     25 
## "0.99" "0.93" "0.87" "0.83" "0.89"

Question 1 and 2

# print betas
print(noquote(format(betas[1:5], digit = 3)))
##    1    2    3    4    5 
## 1.43 1.23 1.10 1.02 1.08
# print alphas
print(noquote(format(alphas[1:5], digit = 3)))
##      1      2      3      4      5 
## -0.430  0.183  0.292  0.508  0.628

Question 3

x = betas
y = colMeans(fitted(model))
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")

plot of chunk plot

# across Size
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) + 5 * i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot

# Across b/m
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) * 5 - i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot

# summary(model)

Question 5

Redo the previous result with different window

constantStart = 1932
dStart = c(constantStart, 1)
dEnd = c(1962, 12)
FamaData = window(FamaDataRaw, start = dStart, end = dEnd, frequency = 12)
tsport25 = window(tsport25Raw, start = dStart, end = dEnd, frequency = 12)

Adjust for excess return

window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##               1      2      3      4      5      6      7      8      9
## Jan 1932   6.22  -5.99  12.06  11.06   8.74  -1.55  -1.35   5.95  12.94
## Feb 1932 -12.85  -0.02   5.64  -2.11   4.11   6.21  -0.64  -2.53  -6.23
## Mar 1932 -23.06  -3.91  -8.03  -9.33 -11.60 -16.84 -13.59  -9.60  -6.74
## Apr 1932 -40.77 -16.83 -24.42 -18.96 -16.25 -17.76 -10.25 -16.53 -15.34
## May 1932 -12.94 -35.24  -3.62  -7.49  -9.37 -10.31 -20.82 -21.51 -18.50
## Jun 1932  35.81 -16.99   4.14  -2.13  -3.89  -9.44  -1.55  -5.35  15.43
## Jul 1932 147.50  16.67  28.24  42.41  54.64  33.80  32.65  44.21  47.13
## Aug 1932  49.49 128.57  75.16  82.98  98.86  27.74  64.51  59.33  64.91
## Sep 1932 -27.03  -6.25  -0.11  -7.61 -16.36   1.04  -9.07  -7.58  -7.82
## Oct 1932  -9.26  -6.67 -21.18 -18.68 -20.65 -10.76 -25.79 -19.18 -23.27
## Nov 1932 -26.53 -21.43 -11.22 -12.81  -5.75  -3.05  -7.06  -6.73  -9.82
## Dec 1932   6.94 -18.18 -14.44 -11.57 -15.53 -15.66 -10.57  -4.28  -9.64
##              10     11     12     13     14     15     16     17     18
## Jan 1932  15.52  -1.55   3.06   2.61  -0.01   7.79  -2.95  -1.70   0.00
## Feb 1932  -0.99   2.27   2.05   3.45   0.70  -2.67   5.12   2.53  -0.99
## Mar 1932 -12.95  -9.14 -12.72 -14.44 -10.05 -13.98 -10.18 -11.00 -12.71
## Apr 1932 -18.21 -22.61 -14.16 -15.37 -13.38 -23.69 -13.28 -19.09 -15.66
## May 1932 -17.89 -25.73 -22.57 -32.33 -21.68 -31.77 -21.17 -20.18 -21.31
## Jun 1932   5.65   7.05   4.53   8.25   4.68   5.28   1.38   3.95  -4.83
## Jul 1932  69.81  34.99  23.97  41.55  44.99  76.91  28.64  35.76  32.73
## Aug 1932  90.81  61.75  41.89  46.45  55.76  73.23  26.96  47.22  59.73
## Sep 1932 -12.37  -7.63  -7.19  -1.87  -8.59 -11.62   1.63  -5.52  -8.24
## Oct 1932 -22.78 -15.45 -17.33 -22.31 -21.95 -25.87  -9.66 -18.32 -17.20
## Nov 1932 -17.19  -3.47  -2.90  -8.12 -10.34 -15.92   2.04  -5.11  -8.04
## Dec 1932  -7.21  -4.88   0.27   0.98  -3.16  -6.09   4.55  -0.08   2.11
##              19     20     21     22     23     24     25
## Jan 1932   2.76   7.51  -3.57  -1.42   2.80  11.56   7.89
## Feb 1932   1.01   2.40   7.06   5.13   4.06  -3.75  14.63
## Mar 1932 -12.18 -11.82 -10.67 -10.19 -13.47 -23.32   2.13
## Apr 1932 -13.96 -20.07 -17.02 -22.65 -18.89 -22.76 -22.92
## May 1932 -18.24 -33.06 -21.18 -15.32 -30.71 -36.42 -10.81
## Jun 1932   8.99   7.59  -2.56  -2.12   4.53   8.94  21.21
## Jul 1932  71.42  80.31  28.56  27.93  50.08  58.57  56.82
## Aug 1932  68.96  86.43  30.83  32.22  47.13  58.28  25.62
## Sep 1932  -6.36  -8.76  -0.16  -3.78  -8.49  -0.73  -8.68
## Oct 1932 -21.28 -25.83 -11.84  -9.05 -15.22 -20.87 -13.93
## Nov 1932 -15.30 -19.95  -3.24  -1.61 -10.34  -8.60 -15.08
## Dec 1932  -0.61 -10.10   8.17   5.91   1.46  -7.22  -3.90
for (i in 1:25) {
    tsport25[, i] = tsport25[, i] - FamaData[, "RF"]
}
window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##               1      2      3      4      5      6      7      8      9
## Jan 1932   5.99  -6.22  11.83  10.83   8.51  -1.78  -1.58   5.72  12.71
## Feb 1932 -13.08  -0.25   5.41  -2.34   3.88   5.98  -0.87  -2.76  -6.46
## Mar 1932 -23.22  -4.07  -8.19  -9.49 -11.76 -17.00 -13.75  -9.76  -6.90
## Apr 1932 -40.88 -16.94 -24.53 -19.07 -16.36 -17.87 -10.36 -16.64 -15.45
## May 1932 -13.00 -35.30  -3.68  -7.55  -9.43 -10.37 -20.88 -21.57 -18.56
## Jun 1932  35.79 -17.01   4.12  -2.15  -3.91  -9.46  -1.57  -5.37  15.41
## Jul 1932 147.47  16.64  28.21  42.38  54.61  33.77  32.62  44.18  47.10
## Aug 1932  49.46 128.54  75.13  82.95  98.83  27.71  64.48  59.30  64.88
## Sep 1932 -27.06  -6.28  -0.14  -7.64 -16.39   1.01  -9.10  -7.61  -7.85
## Oct 1932  -9.28  -6.69 -21.20 -18.70 -20.67 -10.78 -25.81 -19.20 -23.29
## Nov 1932 -26.55 -21.45 -11.24 -12.83  -5.77  -3.07  -7.08  -6.75  -9.84
## Dec 1932   6.93 -18.19 -14.45 -11.58 -15.54 -15.67 -10.58  -4.29  -9.65
##              10     11     12     13     14     15     16     17     18
## Jan 1932  15.29  -1.78   2.83   2.38  -0.24   7.56  -3.18  -1.93  -0.23
## Feb 1932  -1.22   2.04   1.82   3.22   0.47  -2.90   4.89   2.30  -1.22
## Mar 1932 -13.11  -9.30 -12.88 -14.60 -10.21 -14.14 -10.34 -11.16 -12.87
## Apr 1932 -18.32 -22.72 -14.27 -15.48 -13.49 -23.80 -13.39 -19.20 -15.77
## May 1932 -17.95 -25.79 -22.63 -32.39 -21.74 -31.83 -21.23 -20.24 -21.37
## Jun 1932   5.63   7.03   4.51   8.23   4.66   5.26   1.36   3.93  -4.85
## Jul 1932  69.78  34.96  23.94  41.52  44.96  76.88  28.61  35.73  32.70
## Aug 1932  90.78  61.72  41.86  46.42  55.73  73.20  26.93  47.19  59.70
## Sep 1932 -12.40  -7.66  -7.22  -1.90  -8.62 -11.65   1.60  -5.55  -8.27
## Oct 1932 -22.80 -15.47 -17.35 -22.33 -21.97 -25.89  -9.68 -18.34 -17.22
## Nov 1932 -17.21  -3.49  -2.92  -8.14 -10.36 -15.94   2.02  -5.13  -8.06
## Dec 1932  -7.22  -4.89   0.26   0.97  -3.17  -6.10   4.54  -0.09   2.10
##              19     20     21     22     23     24     25
## Jan 1932   2.53   7.28  -3.80  -1.65   2.57  11.33   7.66
## Feb 1932   0.78   2.17   6.83   4.90   3.83  -3.98  14.40
## Mar 1932 -12.34 -11.98 -10.83 -10.35 -13.63 -23.48   1.97
## Apr 1932 -14.07 -20.18 -17.13 -22.76 -19.00 -22.87 -23.03
## May 1932 -18.30 -33.12 -21.24 -15.38 -30.77 -36.48 -10.87
## Jun 1932   8.97   7.57  -2.58  -2.14   4.51   8.92  21.19
## Jul 1932  71.39  80.28  28.53  27.90  50.05  58.54  56.79
## Aug 1932  68.93  86.40  30.80  32.19  47.10  58.25  25.59
## Sep 1932  -6.39  -8.79  -0.19  -3.81  -8.52  -0.76  -8.71
## Oct 1932 -21.30 -25.85 -11.86  -9.07 -15.24 -20.89 -13.95
## Nov 1932 -15.32 -19.97  -3.26  -1.63 -10.36  -8.62 -15.10
## Dec 1932  -0.62 -10.11   8.16   5.90   1.45  -7.23  -3.91

Check

format(colMeans(tsport25), digits = 2)
##      1      2      3      4      5      6      7      8      9     10 
## "1.51" "1.58" "1.87" "1.89" "2.23" "1.23" "1.65" "1.58" "1.74" "2.05" 
##     11     12     13     14     15     16     17     18     19     20 
## "1.41" "1.31" "1.51" "1.59" "1.68" "1.10" "1.28" "1.45" "1.47" "1.70" 
##     21     22     23     24     25 
## "0.98" "0.91" "1.28" "1.27" "1.58"

Run a lot of Regression

model = lm(tsport25 ~ FamaData[, "MktRF"])
alphas = coef(model)[1, ]
betas = coef(model)[2, ]
format(betas, digit = 2)
##      1      2      3      4      5      6      7      8      9     10 
## "1.80" "1.86" "1.64" "1.51" "1.67" "1.18" "1.37" "1.41" "1.44" "1.65" 
##     11     12     13     14     15     16     17     18     19     20 
## "1.30" "1.15" "1.31" "1.29" "1.70" "0.96" "1.15" "1.18" "1.39" "1.76" 
##     21     22     23     24     25 
## "0.94" "0.89" "1.06" "1.35" "1.37"
# print betas
print(noquote(format(betas[1:5], digit = 3)))
##    1    2    3    4    5 
## 1.80 1.86 1.64 1.51 1.67

Let's plot again

x = betas
y = colMeans(fitted(model))
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")

plot of chunk plot2

# across Size
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) + 5 * i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot2

# Across b/m
plot(x, y)
lines(c(0, 1), c(0, mean(FamaData[, "MktRF"])))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) * 5 - i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot2

# summary(model)

Quesition 7

constantStart = 1963
dStart = c(constantStart, 1)
dEnd = c(2013, 8)
FamaData = window(FamaDataRaw, start = dStart, end = dEnd, frequency = 12)
tsport25 = window(tsport25Raw, start = dStart, end = dEnd, frequency = 12)

Adjust for excess return

window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##              1     2     3     4     5     6     7     8     9    10    11
## Jan 1963 13.02 11.44  9.39 10.96 11.13  7.63  5.81  7.56  8.72 11.26  6.37
## Feb 1963 -3.25 -3.49 -0.74 -0.83  2.78 -4.02 -1.89 -2.43 -1.68 -0.36 -3.76
## Mar 1963  4.98 -1.47 -0.15  1.24  2.61 -0.16  1.18  1.21  2.93  1.46 -0.05
## Apr 1963  4.80  1.50  1.88  3.61  2.78  2.33  5.32  0.53  4.37  6.09  3.56
## May 1963  3.39  1.68  2.72  4.12  7.92  2.09  2.73  0.92  5.00  4.80  2.35
## Jun 1963  3.77 -1.17 -1.35 -2.46 -1.09 -0.03 -1.74 -1.97 -1.99 -1.70 -1.30
## Jul 1963  0.85  0.24  0.56 -0.02 -1.22 -1.87  0.29 -0.84 -1.90 -1.19 -1.84
## Aug 1963  3.80  2.15  1.32  2.29  4.73  5.40  4.65  4.36  4.33  8.23  5.36
## Sep 1963 -2.70  0.26 -1.09 -1.59 -0.38 -3.92 -1.57 -0.64 -1.13 -2.91 -4.65
## Oct 1963  1.36 -0.63  1.24  0.05  2.37  1.19  4.30  2.34  2.26  3.93  2.26
## Nov 1963 -3.11 -4.32 -1.60 -1.00 -1.11 -4.18 -1.76 -0.71 -0.09 -0.11 -2.92
## Dec 1963 -2.94 -0.55 -0.90 -1.75 -0.97 -0.68 -0.91  1.15  0.97  0.12  0.60
##             12    13    14    15    16    17    18    19    20    21    22
## Jan 1963  5.71  4.75  8.74  9.33  5.40  4.89  5.87  9.71  6.31  5.27  4.09
## Feb 1963 -1.34 -0.57 -2.24  0.89 -3.07 -1.33 -0.91 -0.92 -0.59 -3.28 -1.61
## Mar 1963  1.40  1.37  3.54  1.73  2.03  1.72  2.79  3.48  3.72  3.73  2.83
## Apr 1963  4.15  3.02  3.13  5.11  4.29  3.33  4.97  7.25  4.44  4.86  4.14
## May 1963  2.13  2.44  5.22  6.04  1.57  1.57  1.90  4.18  3.69  3.22 -0.36
## Jun 1963 -0.65 -2.42 -2.78 -1.05 -1.46 -1.38 -2.52 -2.93  1.26 -3.23 -0.94
## Jul 1963 -1.87 -0.81 -2.21 -1.80 -0.93 -1.63 -2.07 -1.67 -1.86  0.14  0.46
## Aug 1963  4.62  5.63  4.72  5.15  5.59  4.81  6.12  7.56  5.35  5.77  4.22
## Sep 1963 -1.52 -0.69 -0.10 -1.82 -2.67 -1.95 -2.00 -3.58 -1.99 -1.37 -0.77
## Oct 1963  0.50  2.70  2.16  1.07 -0.24  0.93  2.30  5.34  0.61  5.33  1.73
## Nov 1963 -1.58 -0.91 -0.90 -1.21 -0.91 -0.86 -0.51  1.15  3.54 -1.26  0.98
## Dec 1963  1.17  1.52  1.52  0.47 -0.17  1.27  1.63  3.14  6.15  2.62  2.30
##             23    24    25
## Jan 1963  3.46  6.51  6.40
## Feb 1963 -2.05 -1.41 -0.94
## Mar 1963  4.57  4.82  5.63
## Apr 1963  5.98  4.05  8.00
## May 1963  1.82  2.30  4.32
## Jun 1963 -0.74 -2.00  0.36
## Jul 1963  1.23 -0.45 -1.11
## Aug 1963  4.77  8.16  6.25
## Sep 1963 -0.98 -0.12 -3.82
## Oct 1963 -0.26  2.36  0.48
## Nov 1963 -1.55 -2.05  1.37
## Dec 1963  2.28  2.38  2.37
for (i in 1:25) {
    tsport25[, i] = tsport25[, i] - FamaData[, "RF"]
}
window(tsport25, start = c(constantStart, 1), end = c(constantStart, 12), frequency = 12)
##              1     2     3     4     5     6     7     8     9    10    11
## Jan 1963 12.77 11.19  9.14 10.71 10.88  7.38  5.56  7.31  8.47 11.01  6.12
## Feb 1963 -3.48 -3.72 -0.97 -1.06  2.55 -4.25 -2.12 -2.66 -1.91 -0.59 -3.99
## Mar 1963  4.75 -1.70 -0.38  1.01  2.38 -0.39  0.95  0.98  2.70  1.23 -0.28
## Apr 1963  4.55  1.25  1.63  3.36  2.53  2.08  5.07  0.28  4.12  5.84  3.31
## May 1963  3.15  1.44  2.48  3.88  7.68  1.85  2.49  0.68  4.76  4.56  2.11
## Jun 1963  3.54 -1.40 -1.58 -2.69 -1.32 -0.26 -1.97 -2.20 -2.22 -1.93 -1.53
## Jul 1963  0.58 -0.03  0.29 -0.29 -1.49 -2.14  0.02 -1.11 -2.17 -1.46 -2.11
## Aug 1963  3.55  1.90  1.07  2.04  4.48  5.15  4.40  4.11  4.08  7.98  5.11
## Sep 1963 -2.97 -0.01 -1.36 -1.86 -0.65 -4.19 -1.84 -0.91 -1.40 -3.18 -4.92
## Oct 1963  1.07 -0.92  0.95 -0.24  2.08  0.90  4.01  2.05  1.97  3.64  1.97
## Nov 1963 -3.38 -4.59 -1.87 -1.27 -1.38 -4.45 -2.03 -0.98 -0.36 -0.38 -3.19
## Dec 1963 -3.23 -0.84 -1.19 -2.04 -1.26 -0.97 -1.20  0.86  0.68 -0.17  0.31
##             12    13    14    15    16    17    18    19    20    21    22
## Jan 1963  5.46  4.50  8.49  9.08  5.15  4.64  5.62  9.46  6.06  5.02  3.84
## Feb 1963 -1.57 -0.80 -2.47  0.66 -3.30 -1.56 -1.14 -1.15 -0.82 -3.51 -1.84
## Mar 1963  1.17  1.14  3.31  1.50  1.80  1.49  2.56  3.25  3.49  3.50  2.60
## Apr 1963  3.90  2.77  2.88  4.86  4.04  3.08  4.72  7.00  4.19  4.61  3.89
## May 1963  1.89  2.20  4.98  5.80  1.33  1.33  1.66  3.94  3.45  2.98 -0.60
## Jun 1963 -0.88 -2.65 -3.01 -1.28 -1.69 -1.61 -2.75 -3.16  1.03 -3.46 -1.17
## Jul 1963 -2.14 -1.08 -2.48 -2.07 -1.20 -1.90 -2.34 -1.94 -2.13 -0.13  0.19
## Aug 1963  4.37  5.38  4.47  4.90  5.34  4.56  5.87  7.31  5.10  5.52  3.97
## Sep 1963 -1.79 -0.96 -0.37 -2.09 -2.94 -2.22 -2.27 -3.85 -2.26 -1.64 -1.04
## Oct 1963  0.21  2.41  1.87  0.78 -0.53  0.64  2.01  5.05  0.32  5.04  1.44
## Nov 1963 -1.85 -1.18 -1.17 -1.48 -1.18 -1.13 -0.78  0.88  3.27 -1.53  0.71
## Dec 1963  0.88  1.23  1.23  0.18 -0.46  0.98  1.34  2.85  5.86  2.33  2.01
##             23    24    25
## Jan 1963  3.21  6.26  6.15
## Feb 1963 -2.28 -1.64 -1.17
## Mar 1963  4.34  4.59  5.40
## Apr 1963  5.73  3.80  7.75
## May 1963  1.58  2.06  4.08
## Jun 1963 -0.97 -2.23  0.13
## Jul 1963  0.96 -0.72 -1.38
## Aug 1963  4.52  7.91  6.00
## Sep 1963 -1.25 -0.39 -4.09
## Oct 1963 -0.55  2.07  0.19
## Nov 1963 -1.82 -2.32  1.10
## Dec 1963  1.99  2.09  2.08

Run a lot of Regression

3 factors this time

model3 = lm(tsport25 ~ FamaData[, "MktRF"] + FamaData[, "HML"] + FamaData[, 
    "SMB"])
alphas3 = coef(model3)[1, ]
betas3 = coef(model3)[2, ]
h3 = coef(model3)[3, ]
s3 = coef(model3)[4, ]
# print h
print(noquote(format(h3[1:5], digit = 3)))
##      1      2      3      4      5 
## -0.306  0.037  0.279  0.453  0.695
# print alpha
print(noquote(format(alphas3[1:5], digit = 3)))
##        1        2        3        4        5 
## -0.48450 -0.02826 -0.00523  0.13468  0.12969

Question 9

x = betas3 * mean(FamaData[, "MktRF"]) + h3 * mean(FamaData[, "HML"]) + s3 * 
    mean(FamaData[, "SMB"])
y = colMeans(fitted(model3))
plot(x, y)
lines(c(0, 1.5), c(0, 1.5))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")

plot of chunk plot3

# across Size
plot(x, y)
lines(c(0, 1.5), c(0, 1.5))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) + 5 * i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot3

# Across b/m
plot(x, y)
lines(c(0, 1.5), c(0, 1.5))
text(x, y, 1:25, cex = 0.6, pos = 4, col = "red")
for (i in 0:4) {
    v = (1:5) * 5 - i
    # print(v)
    lines(x[v], y[v], col = i + 3)
}

plot of chunk plot3

# summary(model)

Question 10

\[ \begin{eqnarray*} r_{t+1} &=&b\times dp_{t}+\varepsilon _{t+1}^{r} \\ dp_{t+1} &=&\phi dp_{t}+\varepsilon _{t+1}^{dp} \end{eqnarray*} \] \[ (r_{t+1}+r_{t+2})=b(1+\phi )dp_{t}+\delta _{t+k} \] \[ R^{2}\approx \frac{b^{2}(1+\phi )^{2}\sigma ^{2}(dp)}{2\sigma ^{2}(r)} \]

N = 500
Year = 500
sigma = 0.5
phi = 0.05
x = matrix(nrow = Year, ncol = N)
x[1, ] = rnorm(N, 0, sigma)
winner = rep(0, Year)
loser = rep(0, Year)
wi = as.integer((N * 9/10) + 1):N
wi
##  [1] 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
## [18] 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
## [35] 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
li = 1:(N/10)
li
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## [24] 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
## [47] 47 48 49 50
for (i in 2:Year) {
    x[i, ] = x[i - 1, ] * phi + rnorm(N, 0, sigma)
    ThisYearRt <- t(rbind(x[i - 1, ], x[i, ]))
    sortedThisYearRt = ThisYearRt[order(x[i - 1, ]), ]
    winner[i] = mean(sortedThisYearRt[wi, 2])
    loser[i] = mean(sortedThisYearRt[li, 2])
}
winner = winner[2:Year]
loser = loser[2:Year]
mean(winner) * 100
## [1] 4.808
mean(loser) * 100
## [1] -4.121
sd(winner) * 100
## [1] 6.94
sd(loser) * 100
## [1] 6.642
mean(winner)/sd(winner)
## [1] 0.6928
mean(loser)/sd(loser)
## [1] -0.6204