-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathfactor.html
1566 lines (1550 loc) · 179 KB
/
factor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Chapter 3 Factor investing and asset pricing anomalies | Machine Learning for Factor Investing</title>
<meta name="author" content="Guillaume Coqueret and Tony Guida">
<meta name="generator" content="bookdown 0.32 with bs4_book()">
<meta property="og:title" content="Chapter 3 Factor investing and asset pricing anomalies | Machine Learning for Factor Investing">
<meta property="og:type" content="book">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Chapter 3 Factor investing and asset pricing anomalies | Machine Learning for Factor Investing">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.4.2/transition.js"></script><script src="libs/bs3compat-0.4.2/tabs.js"></script><script src="libs/bs3compat-0.4.2/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="libs/kePrint-0.0.1/kePrint.js"></script><link href="libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><style type="text/css">
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
</style>
<style type="text/css">
/* Used with Pandoc 2.11+ new --citeproc when CSL is used */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.hanging div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}
</style>
<meta name="description" content=".container-fluid main { max-width: 60rem; } Asset pricing anomalies are the foundations of factor investing. In this chapter our aim is twofold: present simple ideas and concepts: basic factor...">
<meta property="og:description" content=".container-fluid main { max-width: 60rem; } Asset pricing anomalies are the foundations of factor investing. In this chapter our aim is twofold: present simple ideas and concepts: basic factor...">
<meta name="twitter:description" content=".container-fluid main { max-width: 60rem; } Asset pricing anomalies are the foundations of factor investing. In this chapter our aim is twofold: present simple ideas and concepts: basic factor...">
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container-fluid">
<div class="row">
<header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
<div class="d-flex align-items-start justify-content-between">
<h1>
<a href="index.html" title="">Machine Learning for Factor Investing</a>
</h1>
<button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
</div>
<div id="main-nav" class="collapse-lg">
<form role="search">
<input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>
<nav aria-label="Table of contents"><h2>Table of contents</h2>
<ul class="book-toc list-unstyled">
<li><a class="" href="index.html">Preface</a></li>
<li class="book-part">Introduction</li>
<li><a class="" href="notdata.html"><span class="header-section-number">1</span> Notations and data</a></li>
<li><a class="" href="intro.html"><span class="header-section-number">2</span> Introduction</a></li>
<li><a class="active" href="factor.html"><span class="header-section-number">3</span> Factor investing and asset pricing anomalies</a></li>
<li><a class="" href="Data.html"><span class="header-section-number">4</span> Data preprocessing</a></li>
<li class="book-part">Common supervised algorithms</li>
<li><a class="" href="lasso.html"><span class="header-section-number">5</span> Penalized regressions and sparse hedging for minimum variance portfolios</a></li>
<li><a class="" href="trees.html"><span class="header-section-number">6</span> Tree-based methods</a></li>
<li><a class="" href="NN.html"><span class="header-section-number">7</span> Neural networks</a></li>
<li><a class="" href="svm.html"><span class="header-section-number">8</span> Support vector machines</a></li>
<li><a class="" href="bayes.html"><span class="header-section-number">9</span> Bayesian methods</a></li>
<li class="book-part">From predictions to portfolios</li>
<li><a class="" href="valtune.html"><span class="header-section-number">10</span> Validating and tuning</a></li>
<li><a class="" href="ensemble.html"><span class="header-section-number">11</span> Ensemble models</a></li>
<li><a class="" href="backtest.html"><span class="header-section-number">12</span> Portfolio backtesting</a></li>
<li class="book-part">Further important topics</li>
<li><a class="" href="interp.html"><span class="header-section-number">13</span> Interpretability</a></li>
<li><a class="" href="causality.html"><span class="header-section-number">14</span> Two key concepts: causality and non-stationarity</a></li>
<li><a class="" href="unsup.html"><span class="header-section-number">15</span> Unsupervised learning</a></li>
<li><a class="" href="RL.html"><span class="header-section-number">16</span> Reinforcement learning</a></li>
<li class="book-part">Appendix</li>
<li><a class="" href="data-description.html"><span class="header-section-number">17</span> Data description</a></li>
<li><a class="" href="python.html"><span class="header-section-number">18</span> Python notebooks</a></li>
<li><a class="" href="solutions-to-exercises.html"><span class="header-section-number">19</span> Solutions to exercises</a></li>
</ul>
<div class="book-extra">
</div>
</nav>
</div>
</header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="factor" class="section level1" number="3">
<h1>
<span class="header-section-number">3</span> Factor investing and asset pricing anomalies<a class="anchor" aria-label="anchor" href="#factor"><i class="fas fa-link"></i></a>
</h1>
<style>
.container-fluid main {
max-width: 60rem;
}
</style>
<p>Asset pricing anomalies are the foundations of <strong>factor investing</strong>. In this chapter our aim is twofold:</p>
<ul>
<li>present simple ideas and concepts: basic factor models and common empirical facts (time-varying nature of returns and risk premia);<br>
</li>
<li>provide the reader with lists of articles that go much deeper to stimulate and satisfy curiosity.</li>
</ul>
<p>The purpose of this chapter is not to provide a full treatment of the many topics related to factor investing. Rather, it is intended to give a broad overview and cover the essential themes so that the reader is guided towards the relevant references. As such, it can serve as a short, non-exhaustive, review of the literature. The subject of factor modelling in finance is incredibly vast and the number of papers dedicated to it is substantial and still rapidly increasing.</p>
<p>The universe of peer-reviewed financial journals can be split in two. The first kind is the <strong>academic</strong> journals. Their articles are mostly written by professors, and the audience consists mostly of scholars. The articles are long and often technical. Prominent examples are the <em>Journal of Finance</em>, the <em>Review of Financial Studies</em> and the <em>Journal of Financial Economics</em>. The second type is more <strong>practitioner</strong>-orientated. The papers are shorter, easier to read, and target finance professionals predominantly. Two emblematic examples are the <em>Journal of Portfolio Management</em> and the <em>Financial Analysts Journal</em>. This chapter reviews and mentions articles published essentially in the first family of journals.</p>
<p>Beyond academic articles, several monographs are already dedicated to the topic of style allocation (a synonym of factor investing used for instance in theoretical articles (<span class="citation">Barberis and Shleifer (<a href="solutions-to-exercises.html#ref-barberis2003style">2003</a>)</span>) or practitioner papers (<span class="citation">Clifford Asness et al. (<a href="solutions-to-exercises.html#ref-asness2015investing">2015</a>)</span>)). To cite but a few, we mention:</p>
<ul>
<li>
<span class="citation">Ilmanen (<a href="solutions-to-exercises.html#ref-ilmanen2011expected">2011</a>)</span>: an exhaustive excursion into risk premia, across many asset classes, with a large spectrum of descriptive statistics (across factors and periods),<br>
</li>
<li>
<span class="citation">Ang (<a href="solutions-to-exercises.html#ref-ang2014asset">2014</a>)</span>: covers factor investing with a strong focus on the money management industry,<br>
</li>
<li>
<span class="citation">Bali, Engle, and Murray (<a href="solutions-to-exercises.html#ref-bali2016empirical">2016</a>)</span>: very complete book on the cross-section of signals with statistical analyses (univariate metrics, correlations, persistence, etc.),<br>
</li>
<li>
<span class="citation">Jurczenko (<a href="solutions-to-exercises.html#ref-jurczenko2017factor">2017</a>)</span>: a tour on various topics given by field experts (factor purity, predictability, selection versus weighting, factor timing, etc.).</li>
</ul>
<p>Finally, we mention a few wide-scope papers on this topic: <span class="citation">Goyal (<a href="solutions-to-exercises.html#ref-goyal2012empirical">2012</a>)</span>, <span class="citation">Cazalet and Roncalli (<a href="solutions-to-exercises.html#ref-cazalet2014facts">2014</a>)</span> and <span class="citation">Baz et al. (<a href="solutions-to-exercises.html#ref-baz2015dissecting">2015</a>)</span>.</p>
<div id="introduction" class="section level2" number="3.1">
<h2>
<span class="header-section-number">3.1</span> Introduction<a class="anchor" aria-label="anchor" href="#introduction"><i class="fas fa-link"></i></a>
</h2>
<p>The topic of factor investing, though a decades-old academic theme, has gained traction concurrently with the rise of equity traded funds (ETFs) as vectors of investment. Both have gathered momentum in the 2010 decade. Not so surprisingly, the feedback loop between practical financial engineering and academic research has stimulated both sides in a mutually beneficial manner. Practitioners rely on key scholarly findings (e.g., asset pricing anomalies) while researchers dig deeper into pragmatic topics (e.g., factor exposure or transaction costs). Recently, researchers have also tried to quantify and qualify the impact of factor indices on financial markets. For instance, <span class="citation">Krkoska and Schenk-Hoppé (<a href="solutions-to-exercises.html#ref-krkoska2019herding">2019</a>)</span> analyze herding behaviors while <span class="citation">Cong and Xu (<a href="solutions-to-exercises.html#ref-cong2019rise">2019</a>)</span> show that the introduction of composite securities increases volatility and cross-asset correlations.</p>
<p>The core aim of factor models is to understand the <strong>drivers of asset prices</strong>. Broadly speaking, the rationale behind factor investing is that the financial performance of firms depends on factors, whether they be latent and unobservable, or related to intrinsic characteristics (like accounting ratios for instance). Indeed, as <span class="citation">Cochrane (<a href="solutions-to-exercises.html#ref-cochrane2011presidential">2011</a>)</span> frames it, the first essential question is <em>which characteristics really provide independent information about average returns?</em> Answering this question helps understand the cross-section of returns and may open the door to their prediction.</p>
<p>Theoretically, linear factor models can be viewed as special cases of the arbitrage pricing theory (APT) of <span class="citation">Ross (<a href="solutions-to-exercises.html#ref-ross1976arbitrage">1976</a>)</span>, which assumes that the return of an asset <span class="math inline">\(n\)</span> can be modelled as a linear combination of underlying factors <span class="math inline">\(f_k\)</span>:
<span class="math display" id="eq:apt">\[\begin{equation}
\tag{3.1}
r_{t,n}= \alpha_n+\sum_{k=1}^K\beta_{n,k}f_{t,k}+\epsilon_{t,n},
\end{equation}\]</span></p>
<p>where the usual econometric constraints on linear models hold: <span class="math inline">\(\mathbb{E}[\epsilon_{t,n}]=0\)</span>, <span class="math inline">\(\text{cov}(\epsilon_{t,n},\epsilon_{t,m})=0\)</span> for <span class="math inline">\(n\neq m\)</span> and <span class="math inline">\(\text{cov}(\textbf{f}_n,\boldsymbol{\epsilon}_n)=0\)</span>. If such factors do exist, then they are in contradiction with the cornerstone model in asset pricing: the capital asset pricing model (CAPM) of <span class="citation">Sharpe (<a href="solutions-to-exercises.html#ref-sharpe1964capital">1964</a>)</span>, <span class="citation">Lintner (<a href="solutions-to-exercises.html#ref-lintner1965valuation">1965</a>)</span> and <span class="citation">Mossin (<a href="solutions-to-exercises.html#ref-mossin1966equilibrium">1966</a>)</span>. Indeed, according to the CAPM, the only driver of returns is the market portfolio. This explains why factors are also called ‘anomalies’. In <span class="citation">Pesaran and Smith (<a href="solutions-to-exercises.html#ref-pesaran2021factor">2021</a>)</span>, the authors define the strength of factors using the sum of squared <span class="math inline">\(\beta_{n,k}\)</span> (across firms).</p>
<p>Empirical evidence of asset pricing anomalies has accumulated since the dual publication of <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1992cross">1992</a>)</span> and <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1993common">1993</a>)</span>. This seminal work has paved the way for a blossoming stream of literature that has its meta-studies (e.g., <span class="citation">Green, Hand, and Zhang (<a href="solutions-to-exercises.html#ref-green2013supraview">2013</a>)</span>, <span class="citation">C. R. Harvey, Liu, and Zhu (<a href="solutions-to-exercises.html#ref-harvey2016and">2016</a>)</span> and <span class="citation">McLean and Pontiff (<a href="solutions-to-exercises.html#ref-mclean2016does">2016</a>)</span>). The regression <a href="factor.html#eq:apt">(3.1)</a> can be evaluated once (unconditionally) or sequentially over different time frames. In the latter case, the parameters (coefficient estimates) change and the models are thus called <em>conditional</em> (we refer to <span class="citation">Ang and Kristensen (<a href="solutions-to-exercises.html#ref-ang2012testing">2012</a>)</span> and to <span class="citation">Cooper and Maio (<a href="solutions-to-exercises.html#ref-cooper2018new">2019</a>)</span> for recent results on this topic as well as for a detailed review on the related research). Conditional models are more flexible because they acknowledge that the drivers of asset prices may not be constant, which seems like a reasonable postulate.</p>
</div>
<div id="detecting-anomalies" class="section level2" number="3.2">
<h2>
<span class="header-section-number">3.2</span> Detecting anomalies<a class="anchor" aria-label="anchor" href="#detecting-anomalies"><i class="fas fa-link"></i></a>
</h2>
<div id="challenges" class="section level3" number="3.2.1">
<h3>
<span class="header-section-number">3.2.1</span> Challenges<a class="anchor" aria-label="anchor" href="#challenges"><i class="fas fa-link"></i></a>
</h3>
<p>Obviously, a crucial step is to be able to identify an anomaly and the complexity of this task should not be underestimated. Given the publication bias towards positive results (see, e.g., <span class="citation">C. R. Harvey (<a href="solutions-to-exercises.html#ref-harvey2017presidential">2017</a>)</span> in financial economics), researchers are often tempted to report partial results that are sometimes invalidated by further studies. The need for replication is therefore high and many findings have no tomorrow (<span class="citation">Linnainmaa and Roberts (<a href="solutions-to-exercises.html#ref-linnainmaa2018history">2018</a>)</span>, <span class="citation">Johannesson, Ohlson, and Zhai (<a href="solutions-to-exercises.html#ref-johannesson2020explanatory">2020</a>)</span>, <span class="citation">Cakici and Zaremba (<a href="solutions-to-exercises.html#ref-cakici2021size">2021</a>)</span>), especially if transaction costs are taken into account (<span class="citation">Patton and Weller (<a href="solutions-to-exercises.html#ref-patton2020you">2020</a>)</span>, <span class="citation">A. Y. Chen and Velikov (<a href="solutions-to-exercises.html#ref-chen2020zeroing">2020</a>)</span>). Nevertheless, as is demonstrated by <span class="citation">A. Y. Chen (<a href="solutions-to-exercises.html#ref-chen2019limits">2019</a>)</span>, <span class="math inline">\(p\)</span>-hacking alone cannot account for all the anomalies documented in the literature. One way to reduce the risk of spurious detection is to increase the hurdles (often, the <span class="math inline">\(t\)</span>-statistics) but the debate is still ongoing (<span class="citation">C. R. Harvey, Liu, and Zhu (<a href="solutions-to-exercises.html#ref-harvey2016and">2016</a>)</span>, <span class="citation">A. Y. Chen (<a href="solutions-to-exercises.html#ref-chen2020t">2020a</a>)</span>, <span class="citation">C. R. Harvey and Liu (<a href="solutions-to-exercises.html#ref-harvey2021uncovering">2021</a>)</span>), or to resort to multiple testing (<span class="citation">C. R. Harvey, Liu, and Saretto (<a href="solutions-to-exercises.html#ref-harvey2019evaluation">2020</a>)</span>, <span class="citation">Vincent, Hsu, and Lin (<a href="solutions-to-exercises.html#ref-vincent2020investment">2020</a>)</span>). Nevertheless, the large sample sizes used in finance may mechanically lead to very low <span class="math inline">\(p\)</span>-values and we refer to <span class="citation">Michaelides (<a href="solutions-to-exercises.html#ref-michaelides2020large">2020</a>)</span> for a discussion on this topic.</p>
<p>Some researchers document fading anomalies because of publication: once the anomaly becomes public, agents invest in it, which pushes prices up and the anomaly disappears. <span class="citation">McLean and Pontiff (<a href="solutions-to-exercises.html#ref-mclean2016does">2016</a>)</span> and <span class="citation">Shanaev and Ghimire (<a href="solutions-to-exercises.html#ref-shanaev2020efficient">2020</a>)</span> document this effect in the US but <span class="citation">H. Jacobs and Müller (<a href="solutions-to-exercises.html#ref-jacobs2019anomalies">2020</a>)</span> find that all other countries experience sustained post-publication factor returns (see also <span class="citation">Zaremba, Umutlu, and Maydubura (<a href="solutions-to-exercises.html#ref-zaremba2020have">2020</a>)</span>). With a different methodology, <span class="citation">A. Y. Chen and Zimmermann (<a href="solutions-to-exercises.html#ref-chen2020publication">2020</a>)</span> introduce a publication bias adjustment for returns and the authors note that this (negative) adjustment is in fact rather small. Likewise, <span class="citation">A. Y. Chen (<a href="solutions-to-exercises.html#ref-chen2020limits">2020b</a>)</span> finds that <span class="math inline">\(p\)</span>-hacking cannot be responsible for all the anomalies reported in the literature.
<span class="citation">Penasse (<a href="solutions-to-exercises.html#ref-penasse2018understanding">2022</a>)</span> recommends the notion of <em>alpha decay</em> to study the persistence or attenuation of anomalies (see also <span class="citation">Falck, Rej, and Thesmar (<a href="solutions-to-exercises.html#ref-falck2021and">2021</a>)</span> on this matter). <span class="citation">Horenstein (<a href="solutions-to-exercises.html#ref-horenstein2020unintended">2020</a>)</span> even builds a model in which agents invest according to anomalies reporting in academic research.</p>
<p>The destruction of factor premia may be due to herding (<span class="citation">Krkoska and Schenk-Hoppé (<a href="solutions-to-exercises.html#ref-krkoska2019herding">2019</a>)</span>, <span class="citation">Volpati et al. (<a href="solutions-to-exercises.html#ref-volpati2020zooming">2020</a>)</span>) and could be accelerated by the democratization of so-called smart-beta products (ETFs notably) that allow investors to directly invest in particular styles (value, low volatility, etc.) - see <span class="citation">S. Huang, Song, and Xiang (<a href="solutions-to-exercises.html#ref-huang2020smart">2020</a>)</span>. For a theoretical perspective on the attractiveness of factor investing, we refer to <span class="citation">Jin (<a href="solutions-to-exercises.html#ref-jin2019drivers">2019</a>)</span> and for its impact on the active fund industry, to <span class="citation">Densmore (<a href="solutions-to-exercises.html#ref-densmore2021growth">2021</a>)</span>. For an empirical study that links crowding to factor returns we point to <span class="citation">Kang, Rouwenhorst, and Tang (<a href="solutions-to-exercises.html#ref-kang2021crowding">2021</a>)</span>. <span class="citation">D. H. Bailey and Lopez de Prado (<a href="solutions-to-exercises.html#ref-bailey2021finance">2021</a>)</span> (via <span class="citation">Brightman, Li, and Liu (<a href="solutions-to-exercises.html#ref-brightman2015chasing">2015</a>)</span>) recall that before their launch, ETFs report a 5% excess return, while they experience a 0% return on average posterior to their launch.</p>
<p>On the other hand, <span class="citation">DeMiguel, Martin Utrera, and Uppal (<a href="solutions-to-exercises.html#ref-demiguel2019crowding">2019</a>)</span> argue that the price impact of crowding in the smart-beta universe is mitigated by trading diversification stemming from external institutions that trade according to strategies outside this space (e.g., high frequency traders betting via order-book algorithms).</p>
<p>The remainder of this subsection was inspired from <span class="citation">Baker, Luo, and Taliaferro (<a href="solutions-to-exercises.html#ref-baker2017detecting">2017</a>)</span> and <span class="citation">C. Harvey and Liu (<a href="solutions-to-exercises.html#ref-harvey2017lucky">2019</a>)</span>.</p>
</div>
<div id="simple-portfolio-sorts" class="section level3" number="3.2.2">
<h3>
<span class="header-section-number">3.2.2</span> Simple portfolio sorts <a class="anchor" aria-label="anchor" href="#simple-portfolio-sorts"><i class="fas fa-link"></i></a>
</h3>
<p>This is the most common procedure and the one used in <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1992cross">1992</a>)</span>. The idea is simple. On one date,</p>
<ol style="list-style-type: decimal">
<li>rank firms according to a particular criterion (e.g., size, book-to-market ratio);<br>
</li>
<li>form <span class="math inline">\(J\ge 2\)</span> portfolios (i.e., homogeneous groups) consisting of the same number of stocks according to the ranking (usually, <span class="math inline">\(J=2\)</span>, <span class="math inline">\(J=3\)</span>, <span class="math inline">\(J=5\)</span> or <span class="math inline">\(J=10\)</span> portfolios are built, based on the median, terciles, quintiles or deciles of the criterion);<br>
</li>
<li>the weight of stocks inside the portfolio is either uniform (equal weights), or proportional to market capitalization;<br>
</li>
<li>at a future date (usually one month), report the returns of the portfolios.<br>
Then, iterate the procedure until the chronological end of the sample is reached.</li>
</ol>
<p>The outcome is a time series of portfolio returns <span class="math inline">\(r_t^j\)</span> for each grouping <span class="math inline">\(j\)</span>. An anomaly is identified if the <span class="math inline">\(t\)</span>-test between the first (<span class="math inline">\(j=1\)</span>) and the last group (<span class="math inline">\(j=J\)</span>) unveils a significant difference in average returns. More robust tests are described in <span class="citation">Cattaneo et al. (<a href="solutions-to-exercises.html#ref-cattaneo2019characteristic">2020</a>)</span>. A strong limitation of this approach is that the sorting criterion could have a non-monotonic impact on returns and a test based on the two extreme portfolios would not detect it. Several articles address this concern: <span class="citation">Patton and Timmermann (<a href="solutions-to-exercises.html#ref-patton2010monotonicity">2010</a>)</span> and <span class="citation">Romano and Wolf (<a href="solutions-to-exercises.html#ref-romano2013testing">2013</a>)</span> for instance. Another concern is that these sorted portfolios may capture not only the priced risk associated to the characteristic, but also some unpriced risk. <span class="citation">K. Daniel et al. (<a href="solutions-to-exercises.html#ref-daniel2020cross">2020</a>)</span> show that it is possible to disentangle the two and make the most of altered sorted portfolios.</p>
<p>Instead of focusing on only one criterion, it is possible to group asset according to more characteristics. The original paper <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1992cross">1992</a>)</span> also combines market capitalization with book-to-market ratios. Each characteristic is divided into 10 buckets, which makes 100 portfolios in total. Beyond data availability, there is no upper bound on the number of features that can be included in the sorting process. In fact, some authors investigate more complex sorting algorithms that can manage a potentially large number of characteristics (see e.g., <span class="citation">Feng, Polson, and Xu (<a href="solutions-to-exercises.html#ref-feng2019deep">2019</a>)</span> and <span class="citation">Bryzgalova, Pelger, and Zhu (<a href="solutions-to-exercises.html#ref-bryzgalova2019forest">2019</a>)</span>).</p>
<p>Finally, we refer to <span class="citation">Olivier Ledoit, Wolf, and Zhao (<a href="solutions-to-exercises.html#ref-ledoit2018efficient">2020</a>)</span> for refinements that take into account the covariance structure of asset returns and to <span class="citation">Cattaneo et al. (<a href="solutions-to-exercises.html#ref-cattaneo2019characteristic">2020</a>)</span> for a theoretical study on the statistical properties of the sorting procedure (including theoretical links with regression-based approaches). Notably, the latter paper discusses the optimal number of portfolios and suggests that it is probably larger than the usual 10 often used in the literature.</p>
<p>In the code and Figure <a href="factor.html#fig:factportsort">3.1</a> below, we compute size portfolios (equally weighted: above versus below the median capitalization). According to the size anomaly, the firms with below median market cap should earn higher returns on average. This is verified whenever the orange bar in the plot is above the blue one (it happens most of the time).</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">data_ml</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">date</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> </span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>large <span class="op">=</span> <span class="va">Mkt_Cap_12M_Usd</span> <span class="op">></span> <span class="fu"><a href="https://rdrr.io/r/stats/median.html">median</a></span><span class="op">(</span><span class="va">Mkt_Cap_12M_Usd</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Creates the cap sort</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">ungroup</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Ungroup</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>year <span class="op">=</span> <span class="fu">lubridate</span><span class="fu">::</span><span class="fu"><a href="https://lubridate.tidyverse.org/reference/year.html">year</a></span><span class="op">(</span><span class="va">date</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Creates a year variable</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">year</span>, <span class="va">large</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Analyze by year & cap</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarize</a></span><span class="op">(</span>avg_return <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">R1M_Usd</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Compute average return</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">year</span>, y <span class="op">=</span> <span class="va">avg_return</span>, fill <span class="op">=</span> <span class="va">large</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="co"># Plot!</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html">geom_col</a></span><span class="op">(</span>position <span class="op">=</span> <span class="st">"dodge"</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html">theme_light</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="co"># Bars side-to-side</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html">theme</a></span><span class="op">(</span>legend.position <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">0.8</span>, <span class="fl">0.2</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="co"># Legend location</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/coord_fixed.html">coord_fixed</a></span><span class="op">(</span><span class="fl">124</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html">theme</a></span><span class="op">(</span>legend.title<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html">element_blank</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="co"># x/y aspect ratio</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html">scale_fill_manual</a></span><span class="op">(</span>values<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"#F87E1F"</span>, <span class="st">"#0570EA"</span><span class="op">)</span>, name <span class="op">=</span> <span class="st">""</span>, <span class="co"># Colors</span></span>
<span> labels<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Small"</span>, <span class="st">"Large"</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html">ylab</a></span><span class="op">(</span><span class="st">"Average returns"</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme.html">theme</a></span><span class="op">(</span>legend.text<span class="op">=</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/element.html">element_text</a></span><span class="op">(</span>size<span class="op">=</span><span class="fl">9</span><span class="op">)</span><span class="op">)</span> </span></code></pre></div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:factportsort"></span>
<img src="ML_factor_files/figure-html/factportsort-1.png" alt="The size factor: average returns of small versus large firms." width="700px"><p class="caption">
FIGURE 3.1: The size factor: average returns of small versus large firms.
</p>
</div>
<p></p>
</div>
<div id="factors" class="section level3" number="3.2.3">
<h3>
<span class="header-section-number">3.2.3</span> Factors<a class="anchor" aria-label="anchor" href="#factors"><i class="fas fa-link"></i></a>
</h3>
<p>The construction of so-called factors follows the same lines as above. Portfolios are based on one characteristic and the factor is a long-short ensemble of one extreme portfolio minus the opposite extreme (small minus large for the size factor or high book-to-market ratio minus low book-to-market ratio for the value factor). Sometimes, subtleties include forming bivariate sorts and aggregating several portfolios together, as in the original contribution of <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1993common">1993</a>)</span>. The most common factors are listed below, along with a few references. We refer to the books listed at the beginning of the chapter for a more exhaustive treatment of factor idiosyncrasies. For most anomalies, theoretical justifications have been brought forward, whether risk-based or behavioral. We list the most frequently cited factors below:</p>
<ul>
<li>Size (<strong>SMB</strong> = small firms minus large firms): <span class="citation">Banz (<a href="solutions-to-exercises.html#ref-banz1981relationship">1981</a>)</span>, <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1992cross">1992</a>)</span>, <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1993common">1993</a>)</span>, <span class="citation">Van Dijk (<a href="solutions-to-exercises.html#ref-van2011size">2011</a>)</span>, <span class="citation">Clifford Asness et al. (<a href="solutions-to-exercises.html#ref-asness2018size">2018</a>)</span> and <span class="citation">Astakhov, Havranek, and Novak (<a href="solutions-to-exercises.html#ref-astakhov2019firm">2019</a>)</span>.<br>
</li>
<li>Value (<strong>HML</strong> = high minus low: undervalued minus `growth’ firms): <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1992cross">1992</a>)</span>, <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama1993common">1993</a>)</span>, <span class="citation">C. S. Asness, Moskowitz, and Pedersen (<a href="solutions-to-exercises.html#ref-asness2013value">2013</a>)</span>. See <span class="citation">Israel, Laursen, and Richardson (<a href="solutions-to-exercises.html#ref-israel2020systematic">2020</a>)</span> and <span class="citation">Roca (<a href="solutions-to-exercises.html#ref-roca2021new">2021</a>)</span> for recent discussions.<br>
</li>
<li>Momentum (<strong>WML</strong> = winners minus losers): <span class="citation">Jegadeesh and Titman (<a href="solutions-to-exercises.html#ref-jegadeesh1993returns">1993</a>)</span>, <span class="citation">Carhart (<a href="solutions-to-exercises.html#ref-carhart1997persistence">1997</a>)</span> and <span class="citation">C. S. Asness, Moskowitz, and Pedersen (<a href="solutions-to-exercises.html#ref-asness2013value">2013</a>)</span>. The winners are the assets that have experienced the highest returns over the last year (sometimes the computation of the return is truncated to omit the last month). Cross-sectional momentum is linked, but not equivalent, to time series momentum (trend following), see e.g., <span class="citation">Moskowitz, Ooi, and Pedersen (<a href="solutions-to-exercises.html#ref-moskowitz2012time">2012</a>)</span> and <span class="citation">Lempérière et al. (<a href="solutions-to-exercises.html#ref-lemperiere2014two">2014</a>)</span>. Momentum is also related to contrarian movements that occur both at higher and lower frequencies (short-term and long-term reversals), see <span class="citation">Luo, Subrahmanyam, and Titman (<a href="solutions-to-exercises.html#ref-luo2020momentum">2020</a>)</span>.<br>
</li>
<li>Profitability (<strong>RMW</strong> = robust minus weak profits): <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama2015five">2015</a>)</span>, <span class="citation">Bouchaud et al. (<a href="solutions-to-exercises.html#ref-bouchaud2019sticky">2019</a>)</span>. In the former reference, profitability is measured as (revenues - (cost and expenses))/equity.<br>
</li>
<li>Investment (<strong>CMA</strong> = conservative minus aggressive): <span class="citation">Fama and French (<a href="solutions-to-exercises.html#ref-fama2015five">2015</a>)</span>, <span class="citation">Hou, Xue, and Zhang (<a href="solutions-to-exercises.html#ref-hou2015digesting">2015</a>)</span>. Investment is measured via the growth of total assets (divided by total assets). Aggressive firms are those that experience the largest growth in assets.<br>
</li>
<li>Low `risk’ (sometimes, <strong>BAB</strong> = betting against beta): <span class="citation">Ang et al. (<a href="solutions-to-exercises.html#ref-ang2006cross">2006</a>)</span>, <span class="citation">Baker, Bradley, and Wurgler (<a href="solutions-to-exercises.html#ref-baker2011benchmarks">2011</a>)</span>, <span class="citation">Frazzini and Pedersen (<a href="solutions-to-exercises.html#ref-frazzini2014betting">2014</a>)</span>, <span class="citation">Boloorforoosh et al. (<a href="solutions-to-exercises.html#ref-boloorforoosh2019beta">2020</a>)</span>, <span class="citation">Baker, Hoeyer, and Wurgler (<a href="solutions-to-exercises.html#ref-baker2019leverage">2020</a>)</span> and <span class="citation">Cliff Asness et al. (<a href="solutions-to-exercises.html#ref-asness2020betting">2020</a>)</span>. In this case, the computation of risk changes from one article to the other (simple volatility, market beta, idiosyncratic volatility, etc.).</li>
</ul>
<p>With the notable exception of the low risk premium, the most mainstream anomalies are kept and updated in the data library of Kenneth French (<a href="https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html" class="uri">https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html</a>). Of course, the computation of the factors follows a particular set of rules, but they are generally accepted in the academic sphere. Another source of data is the AQR repository: <a href="https://www.aqr.com/Insights/Datasets" class="uri">https://www.aqr.com/Insights/Datasets</a>.</p>
<p>In the dataset we use for the book, we proxy the value anomaly not with the book-to-market ratio but with the price-to-book ratio (the book value is located in the denominator). As is shown in <span class="citation">Clifford Asness and Frazzini (<a href="solutions-to-exercises.html#ref-asness2013devil">2013</a>)</span>, the choice of the variable for value can have sizable effects.</p>
<p>Below, we import data from Ken French’s data library. A word of caution: the data is updated frequently and sometimes, experiences methodological changes. We refer to <span class="citation">Akey, Robertson, and Simutin (<a href="solutions-to-exercises.html#ref-akey2021noisy">2021</a>)</span> for a study of such changes in the common Fama-French factors. We will use this data later on in the chapter.</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://www.quantmod.com">quantmod</a></span><span class="op">)</span> <span class="co"># Package for data extraction</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://xtable.r-forge.r-project.org/">xtable</a></span><span class="op">)</span> <span class="co"># Package for LaTeX exports </span></span>
<span><span class="va">min_date</span> <span class="op"><-</span> <span class="st">"1963-07-31"</span> <span class="co"># Start date</span></span>
<span><span class="va">max_date</span> <span class="op"><-</span> <span class="st">"2020-03-28"</span> <span class="co"># Stop date</span></span>
<span><span class="va">temp</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/tempfile.html">tempfile</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">KF_website</span> <span class="op"><-</span> <span class="st">"http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/"</span></span>
<span><span class="va">KF_file</span> <span class="op"><-</span> <span class="st">"ftp/F-F_Research_Data_5_Factors_2x3_CSV.zip"</span></span>
<span><span class="va">link</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="va">KF_website</span>, <span class="va">KF_file</span><span class="op">)</span> <span class="co"># Link of the file</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/download.file.html">download.file</a></span><span class="op">(</span><span class="va">link</span>, <span class="va">temp</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="co"># Download!</span></span>
<span><span class="va">FF_factors</span> <span class="op"><-</span> <span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_csv</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/connections.html">unz</a></span><span class="op">(</span><span class="va">temp</span>, <span class="st">"F-F_Research_Data_5_Factors_2x3.csv"</span><span class="op">)</span>, </span>
<span> skip <span class="op">=</span> <span class="fl">3</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Check the number of lines to skip!</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>date <span class="op">=</span> <span class="va">`...1`</span>, MKT_RF <span class="op">=</span> <span class="va">`Mkt-RF`</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Change the name of first columns</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="op">-</span><span class="va">date</span><span class="op">)</span>, <span class="va">as.numeric</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Convert values to number</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>date <span class="op">=</span> <span class="fu"><a href="https://lubridate.tidyverse.org/reference/ymd.html">ymd</a></span><span class="op">(</span><span class="fu"><a href="https://lubridate.tidyverse.org/reference/parse_date_time.html">parse_date_time</a></span><span class="op">(</span><span class="va">date</span>, <span class="st">"%Y%m"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Date in right format</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>date <span class="op">=</span> <span class="fu"><a href="https://lubridate.tidyverse.org/reference/rollbackward.html">rollback</a></span><span class="op">(</span><span class="va">date</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/weekday.POSIXt.html">months</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="co"># End of month date</span></span>
<span><span class="va">FF_factors</span> <span class="op"><-</span> <span class="va">FF_factors</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>MKT_RF <span class="op">=</span> <span class="va">MKT_RF</span> <span class="op">/</span> <span class="fl">100</span>, <span class="co"># Scale returns</span></span>
<span> SMB <span class="op">=</span> <span class="va">SMB</span> <span class="op">/</span> <span class="fl">100</span>,</span>
<span> HML <span class="op">=</span> <span class="va">HML</span> <span class="op">/</span> <span class="fl">100</span>,</span>
<span> RMW <span class="op">=</span> <span class="va">RMW</span> <span class="op">/</span> <span class="fl">100</span>,</span>
<span> CMA <span class="op">=</span> <span class="va">CMA</span> <span class="op">/</span> <span class="fl">100</span>,</span>
<span> RF <span class="op">=</span> <span class="va">RF</span><span class="op">/</span><span class="fl">100</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">date</span> <span class="op">>=</span> <span class="va">min_date</span>, <span class="va">date</span> <span class="op"><=</span> <span class="va">max_date</span><span class="op">)</span> <span class="co"># Finally, keep only recent points</span></span>
<span><span class="fu">knitr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/knitr/man/kable.html">kable</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">FF_factors</span><span class="op">)</span>, booktabs <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span> caption <span class="op">=</span> <span class="st">"Sample of monthly factor returns."</span><span class="op">)</span> <span class="co"># A look at the data (see table) </span></span></code></pre></div>
<div class="inline-table"><table class="table table-sm">
<caption>
<span id="tab:factorImport">TABLE 3.1: </span>Sample of monthly factor returns.
</caption>
<thead><tr>
<th style="text-align:left;">
date
</th>
<th style="text-align:right;">
MKT_RF
</th>
<th style="text-align:right;">
SMB
</th>
<th style="text-align:right;">
HML
</th>
<th style="text-align:right;">
RMW
</th>
<th style="text-align:right;">
CMA
</th>
<th style="text-align:right;">
RF
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1963-07-31
</td>
<td style="text-align:right;">
-0.0039
</td>
<td style="text-align:right;">
-0.0041
</td>
<td style="text-align:right;">
-0.0097
</td>
<td style="text-align:right;">
0.0068
</td>
<td style="text-align:right;">
-0.0118
</td>
<td style="text-align:right;">
0.0027
</td>
</tr>
<tr>
<td style="text-align:left;">
1963-08-31
</td>
<td style="text-align:right;">
0.0507
</td>
<td style="text-align:right;">
-0.0080
</td>
<td style="text-align:right;">
0.0180
</td>
<td style="text-align:right;">
0.0036
</td>
<td style="text-align:right;">
-0.0035
</td>
<td style="text-align:right;">
0.0025
</td>
</tr>
<tr>
<td style="text-align:left;">
1963-09-30
</td>
<td style="text-align:right;">
-0.0157
</td>
<td style="text-align:right;">
-0.0052
</td>
<td style="text-align:right;">
0.0013
</td>
<td style="text-align:right;">
-0.0071
</td>
<td style="text-align:right;">
0.0029
</td>
<td style="text-align:right;">
0.0027
</td>
</tr>
<tr>
<td style="text-align:left;">
1963-10-31
</td>
<td style="text-align:right;">
0.0253
</td>
<td style="text-align:right;">
-0.0139
</td>
<td style="text-align:right;">
-0.0010
</td>
<td style="text-align:right;">
0.0280
</td>
<td style="text-align:right;">
-0.0201
</td>
<td style="text-align:right;">
0.0029
</td>
</tr>
<tr>
<td style="text-align:left;">
1963-11-30
</td>
<td style="text-align:right;">
-0.0085
</td>
<td style="text-align:right;">
-0.0088
</td>
<td style="text-align:right;">
0.0175
</td>
<td style="text-align:right;">
-0.0051
</td>
<td style="text-align:right;">
0.0224
</td>
<td style="text-align:right;">
0.0027
</td>
</tr>
<tr>
<td style="text-align:left;">
1963-12-31
</td>
<td style="text-align:right;">
0.0183
</td>
<td style="text-align:right;">
-0.0210
</td>
<td style="text-align:right;">
-0.0002
</td>
<td style="text-align:right;">
0.0003
</td>
<td style="text-align:right;">
-0.0007
</td>
<td style="text-align:right;">
0.0029
</td>
</tr>
</tbody>
</table></div>
<p></p>
<p>Posterior to the discovery of these stylized facts, some contributions have aimed at building theoretical models that capture these properties. We cite a handful below:</p>
<ul>
<li>
<strong>size</strong> and <strong>value</strong>: <span class="citation">Berk, Green, and Naik (<a href="solutions-to-exercises.html#ref-berk1999optimal">1999</a>)</span>, <span class="citation">K. D. Daniel, Hirshleifer, and Subrahmanyam (<a href="solutions-to-exercises.html#ref-daniel2001overconfidence">2001</a>)</span>, <span class="citation">Barberis and Shleifer (<a href="solutions-to-exercises.html#ref-barberis2003style">2003</a>)</span>, <span class="citation">Gomes, Kogan, and Zhang (<a href="solutions-to-exercises.html#ref-gomes2003equilibrium">2003</a>)</span>, <span class="citation">Carlson, Fisher, and Giammarino (<a href="solutions-to-exercises.html#ref-carlson2004corporate">2004</a>)</span>, <span class="citation">R. D. Arnott et al. (<a href="solutions-to-exercises.html#ref-arnott2014can">2014</a>)</span>;</li>
<li>
<strong>momentum</strong>: <span class="citation">T. C. Johnson (<a href="solutions-to-exercises.html#ref-johnson2002rational">2002</a>)</span>, <span class="citation">Grinblatt and Han (<a href="solutions-to-exercises.html#ref-grinblatt2005prospect">2005</a>)</span>, <span class="citation">Vayanos and Woolley (<a href="solutions-to-exercises.html#ref-vayanos2013institutional">2013</a>)</span>, <span class="citation">Choi and Kim (<a href="solutions-to-exercises.html#ref-choi2014momentum">2014</a>)</span>.</li>
</ul>
<p>In addition, recent bridges have been built between risk-based factor representations and behavioural theories. We refer essentially to <span class="citation">Barberis, Mukherjee, and Wang (<a href="solutions-to-exercises.html#ref-barberis2016prospect">2016</a>)</span> and <span class="citation">K. Daniel, Hirshleifer, and Sun (<a href="solutions-to-exercises.html#ref-daniel2019short">2020</a>)</span> and the references therein.</p>
<p>While these factors (i.e., long-short portfolios) exhibit time-varying risk premia and are magnified by corporate news and announcements (<span class="citation">Engelberg, McLean, and Pontiff (<a href="solutions-to-exercises.html#ref-engelberg2018anomalies">2018</a>)</span>), it is well-documented (and accepted) that they deliver positive returns over long horizons.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content='<p>This has been a puzzle for the value factor during the 2010 decade during which the factor performed poorly (see <span class="citation">Bellone et al. (<a href="solutions-to-exercises.html#ref-bellone2020equity">2020</a>)</span> <span class="citation">Cornell and Damodaran (<a href="solutions-to-exercises.html#ref-cornell2021value">2021</a>)</span> and <span class="citation">Stagnol et al. (<a href="solutions-to-exercises.html#ref-stagnol2021understanding">2021</a>)</span>). <span class="citation">Shea and Radatz (<a href="solutions-to-exercises.html#ref-shea2020searching">2020</a>)</span> argue that it is because some fundamentals of value firms (like ROE) have not improved at the rate of those of growth firms. This underlines that it is hard to pick which fundamental metrics matter and that their importance varies with time. <span class="citation">Binz, Schipper, and Standridge (<a href="solutions-to-exercises.html#ref-binz2020can">2020</a>)</span> even find that resorting to AI to make sense (and mine) the fundamentals’ zoo only helps marginally.</p>'><sup>6</sup></a> We refer to <span class="citation">Gagliardini, Ossola, and Scaillet (<a href="solutions-to-exercises.html#ref-gagliardini2016time">2016</a>)</span> and to the survey <span class="citation">Gagliardini, Ossola, and Scaillet (<a href="solutions-to-exercises.html#ref-gagliardini2019estimation">2019</a>)</span>, as well as to the related bibliography for technical details on estimation procedures of risk premia and the corresponding empirical results. Large sample studies that documents regime changes in factor premia were also carried out by <span class="citation">Ilmanen et al. (<a href="solutions-to-exercises.html#ref-ilmanen2019factor">2019</a>)</span>, <span class="citation">S. Smith and Timmermann (<a href="solutions-to-exercises.html#ref-smith2020instability">2021</a>)</span> and <span class="citation">Chib, Zhao, and Zhou (<a href="solutions-to-exercises.html#ref-chib2021finding">2021</a>)</span>. Moreover, the predictability of returns is also time-varying (as documented in <span class="citation">Farmer, Schmidt, and Timmermann (<a href="solutions-to-exercises.html#ref-farmer2019pockets">2019</a>)</span>, <span class="citation">Tsiakas, Li, and Zhang (<a href="solutions-to-exercises.html#ref-tsiakas2020equity">2020</a>)</span> and <span class="citation">Liu, Pan, and Wang (<a href="solutions-to-exercises.html#ref-liu2020can">2020</a>)</span>), and estimation methods can be improved (<span class="citation">T. L. Johnson (<a href="solutions-to-exercises.html#ref-johnson2019fresh">2019</a>)</span>).</p>
<p>In Figure <a href="factor.html#fig:riskpremiaFF">3.2</a>, we plot the average monthly return aggregated over each calendar year for five common factors. The risk free rate (which is not a factor per se) is the most stable, while the market factor (aggregate market returns minus the risk-free rate) is the most volatile. This makes sense because it is the only long equity factor among the five series.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">FF_factors</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>date <span class="op">=</span> <span class="fu"><a href="https://lubridate.tidyverse.org/reference/year.html">year</a></span><span class="op">(</span><span class="va">date</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Turn date into year</span></span>
<span> <span class="fu"><a href="https://tidyr.tidyverse.org/reference/gather.html">gather</a></span><span class="op">(</span>key <span class="op">=</span> <span class="va">factor</span>, value <span class="op">=</span> <span class="va">value</span>, <span class="op">-</span> <span class="va">date</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Put in tidy shape</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">factor</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Group by year and factor</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span><span class="op">(</span>value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">value</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Compute average return</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">date</span>, y <span class="op">=</span> <span class="va">value</span>, color <span class="op">=</span> <span class="va">factor</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span> <span class="co"># Plot</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_path.html">geom_line</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/coord_fixed.html">coord_fixed</a></span><span class="op">(</span><span class="fl">500</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html">theme_light</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># Fix x/y ratio + theme</span></span></code></pre></div>
<div class="figure">
<span style="display:block;" id="fig:riskpremiaFF"></span>
<img src="ML_factor_files/figure-html/riskpremiaFF-1.png" alt="Average returns of common anomalies (1963-2020). Source: Ken French library." width="672"><p class="caption">
FIGURE 3.2: Average returns of common anomalies (1963-2020). Source: Ken French library.
</p>
</div>
<p></p>
<p>The individual attributes of investors who allocate towards particular factors is a blossoming topic. We list a few references below, even though they somewhat lie out of the scope of this book. <span class="citation">Betermier, Calvet, and Sodini (<a href="solutions-to-exercises.html#ref-betermier2017value">2017</a>)</span> show that value investors are older, wealthier and face lower income risk compared to growth investors who are those in the best position to take financial risks. The study <span class="citation">Cronqvist, Siegel, and Yu (<a href="solutions-to-exercises.html#ref-cronqvist2015value">2015</a>)</span> leads to different conclusions: it finds that the propensity to invest in value versus growth assets has roots in genetics and in life events (the latter effect being confirmed in <span class="citation">Cocco, Gomes, and Lopes (<a href="solutions-to-exercises.html#ref-cocco2019evidence">2020</a>)</span>, and the former being further detailed in a more general context in <span class="citation">Cronqvist et al. (<a href="solutions-to-exercises.html#ref-cronqvist2015fetal">2015</a>)</span>). Psychological traits can also explain some factors: when agents extrapolate, they are likely to fuel momentum (this topic is thoroughly reviewed in <span class="citation">Barberis (<a href="solutions-to-exercises.html#ref-barberis2018psychology">2018</a>)</span>). Micro- and macro-economic consequences of these preferences are detailed in <span class="citation">Bhamra and Uppal (<a href="solutions-to-exercises.html#ref-bhamra2019does">2019</a>)</span>. To conclude this paragraph, we mention that theoretical models have also been proposed that link agents’ preferences and beliefs (via prospect theory) to market anomalies (see for instance <span class="citation">Barberis, Jin, and Wang (<a href="solutions-to-exercises.html#ref-barberis2019prospect">2020</a>)</span>).</p>
<p>Finally, we highlight the need of replicability of factor premia and echo the recent editorial by <span class="citation">C. R. Harvey (<a href="solutions-to-exercises.html#ref-harvey2020replication">2020</a>)</span>. As is shown by <span class="citation">Linnainmaa and Roberts (<a href="solutions-to-exercises.html#ref-linnainmaa2018history">2018</a>)</span> and <span class="citation">Hou, Xue, and Zhang (<a href="solutions-to-exercises.html#ref-hou2019replicating">2020</a>)</span>, many proclaimed factors are in fact very much data-dependent and often fail to deliver sustained profitability when the investment universe is altered or when the definition of variable changes (<span class="citation">Clifford Asness and Frazzini (<a href="solutions-to-exercises.html#ref-asness2013devil">2013</a>)</span>).</p>
<p>Campbell Harvey and his co-authors, in a series of papers, tried to synthesize the research on factors in <span class="citation">C. R. Harvey, Liu, and Zhu (<a href="solutions-to-exercises.html#ref-harvey2016and">2016</a>)</span>, <span class="citation">C. Harvey and Liu (<a href="solutions-to-exercises.html#ref-harvey2017lucky">2019</a>)</span> and <span class="citation">C. R. Harvey and Liu (<a href="solutions-to-exercises.html#ref-harvey2019census">2019</a>)</span>. His work underlines the need to set high bars for an anomaly to be called a ‘true’ factor. Increasing thresholds for <span class="math inline">\(p\)</span>-values is only a partial answer, as it is always possible to resort to data snooping in order to find an optimized strategy that will fail out-of-sample but that will deliver a <span class="math inline">\(t\)</span>-statistic larger than three (or even four). <span class="citation">C. R. Harvey (<a href="solutions-to-exercises.html#ref-harvey2017presidential">2017</a>)</span> recommends to resort to a Bayesian approach which blends data-based significance with a prior into a so-called Bayesianized <em>p</em>-value (see subsection below).</p>
<p>Following this work, researchers have continued to explore the richness of this zoo. <span class="citation">Bryzgalova, Huang, and Julliard (<a href="solutions-to-exercises.html#ref-bryzgalova2019bayesian">2019</a>)</span> propose a tractable Bayesian estimation of large-dimensional factor models and evaluate all possible combinations of more than 50 factors, yielding an incredibly large number of coefficients. This combined with a Bayesianized <span class="citation">Fama and MacBeth (<a href="solutions-to-exercises.html#ref-fama1973risk">1973</a>)</span> procedure allows to distinguish between pervasive and superfluous factors. <span class="citation">Chordia, Goyal, and Saretto (<a href="solutions-to-exercises.html#ref-chordia2020anomalies">2020</a>)</span> use simulations of 2 million trading strategies to estimate the rate of <em>false discoveries</em>, that is, when a spurious factor is detected (type I error). They also advise to use thresholds for <em>t</em>-statistics that are well above three. In a similar vein, <span class="citation">C. R. Harvey and Liu (<a href="solutions-to-exercises.html#ref-harvey2019false">2020</a>)</span> also underline that sometimes <em>true</em> anomalies may be missed because of a one time <span class="math inline">\(t\)</span>-statistic that is too low (type II error).</p>
<p>The propensity of journals to publish positive results has led researchers to estimate the difference between reported returns and <em>true</em> returns. <span class="citation">A. Y. Chen and Zimmermann (<a href="solutions-to-exercises.html#ref-chen2020publication">2020</a>)</span> call this difference the <em>publication bias</em> and estimate it as roughly 12%. That is, if a published average return is 8%, the actual value may in fact be closer to (1-12%)*8%=7%. Qualitatively, this estimation of 12% is smaller than the out-of-sample reduction in returns found in <span class="citation">McLean and Pontiff (<a href="solutions-to-exercises.html#ref-mclean2016does">2016</a>)</span>.</p>
</div>
<div id="predictive-regressions-sorts-and-p-value-issues" class="section level3" number="3.2.4">
<h3>
<span class="header-section-number">3.2.4</span> Predictive regressions, sorts, and p-value issues<a class="anchor" aria-label="anchor" href="#predictive-regressions-sorts-and-p-value-issues"><i class="fas fa-link"></i></a>
</h3>
<p>For simplicity, we assume a simple form:
<span class="math display" id="eq:factsimple">\[\begin{equation}
\tag{3.2}
\textbf{r} = a+b\textbf{x}+\textbf{e},
\end{equation}\]</span>
where the vector <span class="math inline">\(\textbf{r}\)</span> stacks all returns of all stocks and <span class="math inline">\(\textbf{x}\)</span> is a lagged variable so that the regression is indeed predictive. If the estimate <span class="math inline">\(\hat{b}\)</span> is significant given a specified threshold, then it can be tempting to conclude that <span class="math inline">\(\textbf{x}\)</span> does a good job at predicting returns. Hence, long-short portfolios related to extreme values of <span class="math inline">\(\textbf{x}\)</span> (mind the sign of <span class="math inline">\(\hat{b}\)</span>) are expected to generate profits. This is unfortunately often false because <span class="math inline">\(\hat{b}\)</span> gives information on the <em>past</em> ability of <span class="math inline">\(\textbf{x}\)</span> to forecast returns. What happens in the future may be another story.</p>
<p>Statistical tests are also used for portfolio sorts. Assume two extreme portfolios are expected to yield very different average returns (like very small cap versus very large cap, or strong winners versus bad losers). The portfolio returns are written <span class="math inline">\(r_t^+\)</span> and <span class="math inline">\(r_t^-\)</span>. The simplest test for the mean is <span class="math inline">\(t=\sqrt{T}\frac{m_{r_+}-m_{r_-}}{\sigma_{r_+-r_-}}\)</span>, where <span class="math inline">\(T\)</span> is the number of points and <span class="math inline">\(m_{r_\pm}\)</span> denotes the means of returns and <span class="math inline">\(\sigma_{r_+-r_-}\)</span> is the standard deviation of the difference between the two series, i.e., the volatility of the long-short portfolio. In short, the statistic can be viewed as a scaled Sharpe ratio (though usually these ratios are computed for long-only portfolios) and can in turn be used to compute <span class="math inline">\(p\)</span>-values to assess the robustness of an anomaly. As is shown in <span class="citation">Linnainmaa and Roberts (<a href="solutions-to-exercises.html#ref-linnainmaa2018history">2018</a>)</span> and <span class="citation">Hou, Xue, and Zhang (<a href="solutions-to-exercises.html#ref-hou2019replicating">2020</a>)</span>, many factors discovered by researchers fail to survive in out-of-sample tests.</p>
<p>One reason why people are overly optimistic about anomalies they detect is the widespread reverse interpretation of the <em>p</em>-value. Often, it is thought of as the probability of one hypothesis (e.g., my anomaly exists) given the data. In fact, it’s the opposite; it’s the likelihood of your data sample, knowing that the anomaly holds.
<span class="math display">\[\begin{align*}
p-\text{value} &= P[D|H] \\
\text{target prob.}& = P[H|D]=\frac{P[D|H]}{P[D]}\times P[H],
\end{align*}\]</span>
where <span class="math inline">\(H\)</span> stands for hypothesis and <span class="math inline">\(D\)</span> for data. The equality in the second row is a plain application of Bayes’ identity: the interesting probability is in fact a transform of the <span class="math inline">\(p\)</span>-value.</p>
<p>Two articles (at least) discuss this idea. <span class="citation">C. R. Harvey (<a href="solutions-to-exercises.html#ref-harvey2017presidential">2017</a>)</span> introduces <strong>Bayesianized</strong> <span class="math inline">\(p\)</span>-<strong>values</strong>:
<span class="math display" id="eq:Bpv">\[\begin{equation}
\tag{3.3}
\text{Bayesianized } p-\text{value}=\text{Bpv}= e^{-t^2/2}\times\frac{\text{prior}}{1+e^{-t^2/2}\times \text{prior}} ,
\end{equation}\]</span>
where <span class="math inline">\(t\)</span> is the <span class="math inline">\(t\)</span>-statistic obtained from the regression (i.e., the one that defines the <em>p</em>-value) and prior is the analyst’s estimation of the odds that the hypothesis (anomaly) is true. The prior is coded as follows. Suppose there is a p% chance that the null holds (i.e., (1-p)% for the anomaly). The odds are coded as <span class="math inline">\(p/(1-p)\)</span>.
Thus, if the <em>t</em>-statistic is equal to 2 (corresponding to a <em>p</em>-value of 5% roughly) and the prior odds are equal to 6, then the Bpv is equal to <span class="math inline">\(e^{-2}\times 6 \times(1+e^{-2}\times 6)^{-1}\approx 0.448\)</span> and there is a 44.8% chance that the null is true. This interpretation stands in sharp contrast with the original <span class="math inline">\(p\)</span>-value which cannot be viewed as a probability that the null holds. Of course, one drawback is that the level of the prior is crucial and solely user-specified.</p>
<p>The work of <span class="citation">Alexander Chinco, Neuhierl, and Weber (<a href="solutions-to-exercises.html#ref-chinco2019estimating">2020</a>)</span> is very different but shares some key concepts, like the introduction of Bayesian priors in regression outputs. They show that coercing the predictive regression with an <span class="math inline">\(L^2\)</span> constraint (see the ridge regression in Chapter <a href="lasso.html#lasso">5</a>) amounts to introducing views on what the true distribution of <span class="math inline">\(b\)</span> is. The stronger the constraint, the more the estimate <span class="math inline">\(\hat{b}\)</span> will be shrunk towards zero. One key idea in their work is the assumption of a distribution for the true <span class="math inline">\(b\)</span> across many anomalies. It is assumed to be Gaussian and centered. The interesting parameter is the standard deviation: the larger it is, the more frequently significant anomalies are discovered. Notably, the authors show that this parameter changes through time and we refer to the original paper for more details on this subject.</p>
</div>
<div id="fama-macbeth-regressions" class="section level3" number="3.2.5">
<h3>
<span class="header-section-number">3.2.5</span> Fama-Macbeth regressions<a class="anchor" aria-label="anchor" href="#fama-macbeth-regressions"><i class="fas fa-link"></i></a>
</h3>
<p>
Another detection method was proposed by <span class="citation">Fama and MacBeth (<a href="solutions-to-exercises.html#ref-fama1973risk">1973</a>)</span> through a two-stage regression analysis of risk premia. The first stage is a simple estimation of the relationship <a href="factor.html#eq:apt">(3.1)</a>: the regressions are run on a stock-by-stock basis over the corresponding time series. The resulting estimates <span class="math inline">\(\hat{\beta}_{i,k}\)</span> are then plugged into a second series of regressions:
<span class="math display">\[\begin{equation}
r_{t,n}= \gamma_{t,0} + \sum_{k=1}^K\gamma_{t,k}\hat{\beta}_{n,k} + \varepsilon_{t,n},
\end{equation}\]</span>
which are run date-by-date on the cross-section of assets.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content='<p>Originally, <span class="citation">Fama and MacBeth (<a href="solutions-to-exercises.html#ref-fama1973risk">1973</a>)</span> work with the market beta only: <span class="math inline">\(r_{t,n}=\alpha_n+\beta_nr_{t,M}+\epsilon_{t,n}\)</span> and the second pass included nonlinear terms: <span class="math inline">\(r_{t,n}=\gamma_{n,0}+\gamma_{t,1}\hat{\beta}_{n}+\gamma_{t,2}\hat{\beta}^2_n+\gamma_{t,3}\hat{s}_n+\eta_{t,n}\)</span>, where the <span class="math inline">\(\hat{s}_n\)</span> are risk estimates for the assets that are not related to the betas. It is then possible to perform asset pricing tests to infer some properties. For instance, test whether betas have a linear influence on returns or not (<span class="math inline">\(\mathbb{E}[\gamma_{t,2}]=0\)</span>), or test the validity of the CAPM (which implies <span class="math inline">\(\mathbb{E}[\gamma_{t,0}]=0\)</span>).</p>'><sup>7</sup></a> Theoretically, the betas would be known and the regression would be run on the <span class="math inline">\(\beta_{n,k}\)</span> instead of their estimated values.
The <span class="math inline">\(\hat{\gamma}_{t,k}\)</span> estimate the premia of factor <span class="math inline">\(k\)</span> at time <span class="math inline">\(t\)</span>. Under suitable distributional assumptions on the <span class="math inline">\(\varepsilon_{t,n}\)</span>, statistical tests can be performed to determine whether these premia are significant or not. Typically, the statistic on the time-aggregated (average) premia <span class="math inline">\(\hat{\gamma}_k=\frac{1}{T}\sum_{t=1}^T\hat{\gamma}_{t,k}\)</span>:
<span class="math display">\[t_k=\frac{\hat{\gamma}_k}{\hat{\sigma_k}/\sqrt{T}}\]</span>
is often used in pure Gaussian contexts to assess whether or not the factor is significant (<span class="math inline">\(\hat{\sigma}_k\)</span> is the standard deviation of the <span class="math inline">\(\hat{\gamma}_{t,k}\)</span>).</p>
<p>We refer to <span class="citation">Jagannathan and Wang (<a href="solutions-to-exercises.html#ref-jagannathan1998asymptotic">1998</a>)</span> and <span class="citation">Petersen (<a href="solutions-to-exercises.html#ref-petersen2009estimating">2009</a>)</span> for technical discussions on the biases and losses in accuracy that can be induced by standard ordinary least squares (OLS) estimations. Moreover, as the <span class="math inline">\(\hat{\beta}_{i,k}\)</span> in the second-pass regression are <em>estimates</em>, a second level of errors can arise (the so-called errors in variables). The interested reader will find some extensions and solutions in <span class="citation">Shanken (<a href="solutions-to-exercises.html#ref-shanken1992estimation">1992</a>)</span>, <span class="citation">Ang, Liu, and Schwarz (<a href="solutions-to-exercises.html#ref-ang2018using">2018</a>)</span> and <span class="citation">Jegadeesh et al. (<a href="solutions-to-exercises.html#ref-jegadeesh2019empirical">2019</a>)</span>.</p>
<p>Below, we perform <span class="citation">Fama and MacBeth (<a href="solutions-to-exercises.html#ref-fama1973risk">1973</a>)</span> regressions on our sample. We start by the first pass: individual estimation of betas. We build a dedicated function below and use some functional programming to automate the process. We stick to the original implementation of the estimation and perform synchronous regressions.</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">nb_factors</span> <span class="op"><-</span> <span class="fl">5</span> <span class="co"># Number of factors</span></span>
<span><span class="va">data_FM</span> <span class="op"><-</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">left_join</a></span><span class="op">(</span><span class="va">data_ml</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Join the 2 datasets</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">stock_id</span>, <span class="va">R1M_Usd</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># (with returns...</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">stock_id</span> <span class="op"><a href="https://rdrr.io/r/base/match.html">%in%</a></span> <span class="va">stock_ids_short</span><span class="op">)</span>, <span class="co"># ... over some stocks)</span></span>
<span> <span class="va">FF_factors</span>, </span>
<span> by <span class="op">=</span> <span class="st">"date"</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> </span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">stock_id</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Grouping</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>R1M_Usd <span class="op">=</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/lead-lag.html">lag</a></span><span class="op">(</span><span class="va">R1M_Usd</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Lag returns</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">ungroup</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/stats/na.fail.html">na.omit</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Remove missing points</span></span>
<span> <span class="fu"><a href="https://tidyr.tidyverse.org/reference/pivot_wider.html">pivot_wider</a></span><span class="op">(</span>names_from <span class="op">=</span> <span class="st">"stock_id"</span>, values_from <span class="op">=</span> <span class="st">"R1M_Usd"</span><span class="op">)</span></span>
<span><span class="va">models</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="st">"`"</span>, <span class="va">stock_ids_short</span>, </span>
<span> <span class="st">'` ~ MKT_RF + SMB + HML + RMW + CMA'</span><span class="op">)</span>, <span class="co"># Model spec</span></span>
<span> <span class="kw">function</span><span class="op">(</span><span class="va">f</span><span class="op">)</span><span class="op">{</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/formula.html">as.formula</a></span><span class="op">(</span><span class="va">f</span><span class="op">)</span>, data <span class="op">=</span> <span class="va">data_FM</span>, <span class="co"># Call lm(.)</span></span>
<span> na.action<span class="op">=</span><span class="st">"na.exclude"</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> </span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Gather the output</span></span>
<span> <span class="st">"$"</span><span class="op">(</span><span class="va">coef</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Keep only coefs</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Convert to dataframe</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">Estimate</span><span class="op">)</span><span class="op">}</span> <span class="co"># Keep the estimates</span></span>
<span> <span class="op">)</span></span>
<span><span class="va">betas</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unlist.html">unlist</a></span><span class="op">(</span><span class="va">models</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="va">nb_factors</span> <span class="op">+</span> <span class="fl">1</span>, byrow <span class="op">=</span> <span class="cn">T</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Extract the betas</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>row.names <span class="op">=</span> <span class="va">stock_ids_short</span><span class="op">)</span> <span class="co"># Format: row names</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/colnames.html">colnames</a></span><span class="op">(</span><span class="va">betas</span><span class="op">)</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Constant"</span>, <span class="st">"MKT_RF"</span>, <span class="st">"SMB"</span>, <span class="st">"HML"</span>, <span class="st">"RMW"</span>, <span class="st">"CMA"</span><span class="op">)</span> <span class="co"># Format: col names</span></span></code></pre></div>
<p></p>
<div class="inline-table"><table class="table table-sm">
<caption>
<span id="tab:FMreg">TABLE 3.2: </span>Sample of beta values (row numbers are stock IDs).
</caption>
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:right;">
Constant
</th>
<th style="text-align:right;">
MKT_RF
</th>
<th style="text-align:right;">
SMB
</th>
<th style="text-align:right;">
HML
</th>
<th style="text-align:right;">
RMW
</th>
<th style="text-align:right;">
CMA
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:right;">
0.008
</td>
<td style="text-align:right;">
1.417
</td>
<td style="text-align:right;">
0.529
</td>
<td style="text-align:right;">
0.621
</td>
<td style="text-align:right;">
0.980
</td>
<td style="text-align:right;">
-0.379
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:right;">
-0.002
</td>
<td style="text-align:right;">
0.812
</td>
<td style="text-align:right;">
1.108
</td>
<td style="text-align:right;">
0.882
</td>
<td style="text-align:right;">
0.300
</td>
<td style="text-align:right;">
-0.552
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:right;">
0.004
</td>
<td style="text-align:right;">
0.363
</td>
<td style="text-align:right;">
0.306
</td>
<td style="text-align:right;">
-0.050
</td>
<td style="text-align:right;">
0.595
</td>
<td style="text-align:right;">
0.200
</td>
</tr>
<tr>
<td style="text-align:left;">
7
</td>
<td style="text-align:right;">
0.005
</td>
<td style="text-align:right;">
0.431
</td>
<td style="text-align:right;">
0.675
</td>
<td style="text-align:right;">
0.230
</td>
<td style="text-align:right;">
0.322
</td>
<td style="text-align:right;">
0.177
</td>
</tr>
<tr>
<td style="text-align:left;">
9
</td>
<td style="text-align:right;">
0.004
</td>
<td style="text-align:right;">
0.838
</td>
<td style="text-align:right;">
0.678
</td>
<td style="text-align:right;">
1.057
</td>
<td style="text-align:right;">
0.078
</td>
<td style="text-align:right;">
0.062
</td>
</tr>
<tr>
<td style="text-align:left;">
11
</td>
<td style="text-align:right;">
-0.001
</td>
<td style="text-align:right;">
0.986
</td>
<td style="text-align:right;">
0.121
</td>
<td style="text-align:right;">
0.483
</td>
<td style="text-align:right;">
-0.124
</td>
<td style="text-align:right;">
0.018
</td>
</tr>
</tbody>
</table></div>
<p>In the table, <em>MKT_RF</em> is the market return minus the risk free rate. The corresponding coefficient is often referred to as the beta, especially in univariate regressions. We then reformat these betas from Table <a href="factor.html#tab:FMreg">3.2</a> to prepare the second pass. Each line corresponds to one asset: the first 5 columns are the estimated factor loadings and the remaining ones are the asset returns (date by date).</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">loadings</span> <span class="op"><-</span> <span class="va">betas</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Start from loadings (betas)</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">Constant</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Remove constant</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># Convert to dataframe </span></span>
<span><span class="va">ret</span> <span class="op"><-</span> <span class="va">returns</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Start from returns</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">date</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Keep the returns only</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>row.names <span class="op">=</span> <span class="va">returns</span><span class="op">$</span><span class="va">date</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Set row names</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/t.html">t</a></span><span class="op">(</span><span class="op">)</span> <span class="co"># Transpose</span></span>
<span><span class="va">FM_data</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/cbind.html">cbind</a></span><span class="op">(</span><span class="va">loadings</span>, <span class="va">ret</span><span class="op">)</span> <span class="co"># Aggregate both</span></span></code></pre></div>
<p></p>
<div class="inline-table"><table class="table table-sm">
<caption>
<span id="tab:betaformat">TABLE 3.3: </span>Sample of reformatted beta values (ready for regression).
</caption>
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:right;">
MKT_RF
</th>
<th style="text-align:right;">
SMB
</th>
<th style="text-align:right;">
HML
</th>
<th style="text-align:right;">
RMW
</th>
<th style="text-align:right;">
CMA
</th>
<th style="text-align:right;">
2000-01-31
</th>
<th style="text-align:right;">
2000-02-29
</th>
<th style="text-align:right;">
2000-03-31
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
1
</td>
<td style="text-align:right;">
1.4173293
</td>
<td style="text-align:right;">
0.5292414
</td>
<td style="text-align:right;">
0.6206285
</td>
<td style="text-align:right;">
0.9800055
</td>
<td style="text-align:right;">
-0.3788295
</td>
<td style="text-align:right;">
-0.036
</td>
<td style="text-align:right;">
0.263
</td>
<td style="text-align:right;">
0.031
</td>
</tr>
<tr>
<td style="text-align:left;">
3
</td>
<td style="text-align:right;">
0.8120909
</td>
<td style="text-align:right;">
1.1083495
</td>
<td style="text-align:right;">
0.8824799
</td>
<td style="text-align:right;">
0.3002839
</td>
<td style="text-align:right;">
-0.5520309
</td>
<td style="text-align:right;">
0.077
</td>
<td style="text-align:right;">
-0.024
</td>
<td style="text-align:right;">
0.018
</td>
</tr>
<tr>
<td style="text-align:left;">
4
</td>
<td style="text-align:right;">
0.3629688
</td>
<td style="text-align:right;">
0.3061975
</td>
<td style="text-align:right;">
-0.0504485
</td>
<td style="text-align:right;">
0.5954709
</td>
<td style="text-align:right;">
0.2003223
</td>
<td style="text-align:right;">
-0.016
</td>
<td style="text-align:right;">
0.000
</td>
<td style="text-align:right;">
0.153
</td>
</tr>
<tr>
<td style="text-align:left;">
7
</td>
<td style="text-align:right;">
0.4314569
</td>
<td style="text-align:right;">
0.6748355
</td>
<td style="text-align:right;">
0.2303770
</td>
<td style="text-align:right;">
0.3220782
</td>
<td style="text-align:right;">
0.1773031
</td>
<td style="text-align:right;">
-0.009
</td>
<td style="text-align:right;">
0.027
</td>
<td style="text-align:right;">
0.000
</td>
</tr>
<tr>
<td style="text-align:left;">
9
</td>
<td style="text-align:right;">
0.8381647
</td>
<td style="text-align:right;">
0.6775922
</td>
<td style="text-align:right;">
1.0571755
</td>
<td style="text-align:right;">
0.0777108
</td>
<td style="text-align:right;">
0.0622119
</td>
<td style="text-align:right;">
0.032
</td>
<td style="text-align:right;">
0.076
</td>
<td style="text-align:right;">
-0.025
</td>
</tr>
<tr>
<td style="text-align:left;">
11
</td>
<td style="text-align:right;">
0.9858317
</td>
<td style="text-align:right;">
0.1205505
</td>
<td style="text-align:right;">
0.4833864
</td>
<td style="text-align:right;">
-0.1244214
</td>
<td style="text-align:right;">
0.0175315
</td>
<td style="text-align:right;">
0.144
</td>
<td style="text-align:right;">
0.258
</td>
<td style="text-align:right;">
0.049
</td>
</tr>
</tbody>
</table></div>
<p></p>
<p>We observe that the values of the first column (market betas) revolve around one, which is what we would expect.
Finally, we are ready for the second round of regressions.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">models</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="st">"`"</span>, <span class="va">returns</span><span class="op">$</span><span class="va">date</span>, <span class="st">"`"</span>, <span class="st">' ~ MKT_RF + SMB + HML + RMW + CMA'</span>, sep <span class="op">=</span> <span class="st">""</span><span class="op">)</span>,</span>
<span><span class="kw">function</span><span class="op">(</span><span class="va">f</span><span class="op">)</span><span class="op">{</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/formula.html">as.formula</a></span><span class="op">(</span><span class="va">f</span><span class="op">)</span>, data <span class="op">=</span> <span class="va">FM_data</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Call lm(.)</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/summary.html">summary</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Gather the output</span></span>
<span> <span class="st">"$"</span><span class="op">(</span><span class="va">coef</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Keep only the coefs</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Convert to dataframe</span></span>
<span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">Estimate</span><span class="op">)</span><span class="op">}</span> <span class="co"># Keep only estimates</span></span>
<span> <span class="op">)</span></span>
<span><span class="va">gammas</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unlist.html">unlist</a></span><span class="op">(</span><span class="va">models</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="va">nb_factors</span> <span class="op">+</span> <span class="fl">1</span>, byrow <span class="op">=</span> <span class="cn">T</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%>%</a></span> <span class="co"># Switch to dataframe</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>row.names <span class="op">=</span> <span class="va">returns</span><span class="op">$</span><span class="va">date</span><span class="op">)</span> <span class="co"># & set row names</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/colnames.html">colnames</a></span><span class="op">(</span><span class="va">gammas</span><span class="op">)</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Constant"</span>, <span class="st">"MKT_RF"</span>, <span class="st">"SMB"</span>, <span class="st">"HML"</span>, <span class="st">"RMW"</span>, <span class="st">"CMA"</span><span class="op">)</span> <span class="co"># Set col names</span></span></code></pre></div>
<p></p>
<div class="inline-table"><table class="table table-sm">
<caption>
<span id="tab:FamaMacBeth2b">TABLE 3.4: </span>Sample of gamma (premia) values.
</caption>
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:right;">
Constant
</th>
<th style="text-align:right;">
MKT_RF
</th>
<th style="text-align:right;">
SMB
</th>
<th style="text-align:right;">
HML
</th>
<th style="text-align:right;">
RMW
</th>
<th style="text-align:right;">
CMA
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
2000-01-31
</td>
<td style="text-align:right;">
-0.011
</td>
<td style="text-align:right;">
0.041
</td>
<td style="text-align:right;">
0.223
</td>
<td style="text-align:right;">
-0.143
</td>
<td style="text-align:right;">
-0.276
</td>
<td style="text-align:right;">
0.033
</td>
</tr>
<tr>
<td style="text-align:left;">
2000-02-29
</td>
<td style="text-align:right;">
0.014
</td>
<td style="text-align:right;">
0.075
</td>
<td style="text-align:right;">
-0.133
</td>
<td style="text-align:right;">
0.052
</td>
<td style="text-align:right;">
0.085
</td>
<td style="text-align:right;">
-0.036
</td>
</tr>
<tr>
<td style="text-align:left;">
2000-03-31
</td>
<td style="text-align:right;">
0.004
</td>
<td style="text-align:right;">
-0.010
</td>
<td style="text-align:right;">