I was impressed by the down-to-earth debate between Eugene Fama and Richard Thaler. Their discussion was very insightful in order to make sense of what’s going on with Efficient Market Hypothesis, CAPM, Fama and French 3 Factor Model, Markowitz and where is the field moving. This will be my last blog post on economics for a while, so expect lots of Machine Learning and Statistics topics next. This is a continuation that is supposed to add some missing pieces to the analysis done in the partI and partII

My first impression is that the microfoundation, theory-based CAPM is just an invalid model from a variety of perspectives, there is too much evidence against it^{1}. On the other line of analysis, the empirical approach by Fama relies on the EMH, which he admitted is almost untestable. This means that the focus is on asset pricing models that work in real world and that the data should show us the way. For `E.F.`

, rigorous statistical testing of the hypotheses is of the foremost importance. His objection to the notion of a bubble can be understood as “show me the statistical procedure/test”, as it is easy to say in retrospective that something was a bubble. Usually, I might disagree with the theory that CAPM is build on, but here I can rely on one of the fathers of modern finance and the whole body of evidence to disregard it. `R.T.`

separated the EMH in an useful way by asking two questions, which could help avoid lots of confusion:

- Can you beat the market?
- Are the prices right?

From other videos of E.Fama, it is clear that he is frustrated by the behaviorists cherrypicking anomalies without regard to the psychological theory and in order to invalidate a theory you should come with your own, so, “what’s your theory”? From a practical point of view, the points they were debating do not make a huge difference. `R.T.`

argues we can have a pretty good guess if something is a bubble in order to intervene very gently, even though there might not be a formal test for it.

I considered going through the Chicago’s Booth Asset Pricing (PartI) and Asset Pricing (PartII) course in order to understand all these issues deeply, but the outlook of saying in the end `"just go buy an index fund"`

looks grim. After all it is worth it, because when we build an empirical model, we might implicitly make some huge assumptions about expectations or predictability. So, in order not to make stupid mistakes it’s better to know the theory well. I’ll throw in another red pill related to the state of macroeconomics, which should do justice to Eugene saying that Finance is the most successful part of economics.

Another thing which became clear, is that the previous questions I was raising and doubts I had are totally founded. It should’t be something new for the people in the field, but it’s certaily useful for a newcomer

## Analysing portfolio models without reading Fama is useless

Before digging into the data, I would like to go through the Fama and French 2004 paper. As a lot of things in economics, this powerful and intuitive theoretical model does not hold against empirical evidence. Last time, we built portfolios using ideas from Markowitz (in a toy form) at time \(t - 1\) resulting in a stochastic return at time \(t\), where we as investors care about the mean and return (implicitly assuming risk aversion). If taken one step further, we’d have to solve one of the dual problems of maximizing expected returns given variance or minimizing variance given returns.

In order to “tell the CAPM story” we should add to the usual picture the risk-free rate, which could bring additional investment opportunities, the efficient fronteer becoming a straight line. Formally:

\[ R_p = wR_f + (1 - w)R_{rp} \] \[ \mathbb{E}(R_p)=wR_f + (1-w)\mathbb{E}(R_{rp}) \] \[ \mathbb{V}(R_p) = (1-w)\mathbb{V}(R_{rp}) \] Basically what we care about, is that the efficient portfolio will be a linear combination of the risk-free asset and a risky portfolio, tangent to the risky efficiency fronteer.

Now, in order to have a testable relationship between return and risk, CAPM adds two more assumptions to the Markowitz model. Let’s take the quote from Fama, as it’s quite the pill to swallow:

The first assumption is complete agreement: given market clearing asset prices at \(t-1\), investors agree on the joint distribution of asset returns from \(t-1\) to \(t\). And this distribution is the true one-that is, it is the distribution from which the returns we use to test the model are drawn. The second assumption is that there is borrowing and lending at a risk-free rate, which is the same for all investors and does not depend on the amount borrowed or lent.

In the end, it implies that the market portfolio \(M\) must be on the minimum variance fronteer, so the minimum variance portfolio should hold for the market portfolio (then all investors should see the same opportunity set?). For \(i = 1, ..., N\) risky assets \[
\mathbb{E}(R_i)=\mathbb{E}(R_{ZM}) + \beta_{iM}[\mathbb{E}(R_M)- \mathbb{E}(R_{ZM})]
\] This expression is easily recognizable if we replace \(\mathbb{E}(R_{ZM})\) with \(R_f\), which is the security market line and it tells the story of the linear relationship between `beta`

(non-diversifiable, systematic risk) and asset returns, conceptually holding for negative values of beta. All the interpretations are extremely tricky and even more, we swipe under the carpet the assumptions of quadratic utility functions (or probability distribution with two moments).

\[ \beta_{iM}=\frac{cov(R_i, R_M)}{\mathbb{V}(R_M)} \] As beta is basically a regression coefficient, it shows how does a return of the asset vary as a result of variation in market return given all other factors stay constant. Fama gives an even more insightful interpretation: the risk of market portfolio \(\mathbb{V}(R_M)\) is a weighted average of covariance risks of assets in Market, i.e. proportional to the contribution to portfolio risk.

\[ \mathbb{V}(R_m)=Cov(R_M, R_M)=Cov \bigg(\sum_{i=1}^N x_{iM}R_i, R_M \bigg) \\ = \sum_{i=1}^N x_{iM}Cov(R_i, R_M ) \]

Last step is to get rid of \(\mathbb{E}(R_{ZM})\). If we assume `unrestricted risk-free borrowing and lending`

, that asset doesn’t contribute to market risk (variance), so it can be replaced by the risk free rate. Fisher Black shows we don’t have to make this assumption, but the alternative is not much more realistic.

Fama and French go on to describe different approaches for testing the empirical validity of CAPM and find multiple problems with it. Nonetheless, it’s a stepping stone to the more relevant models. I am losing my interest quickly here, but at least I know what I don’t know right now and might come back at it some day.

One thing is clear, that the exercise that will be done below misses the larger point of all this (theoretical) struggle to find the “perfect portfolio”. It seems like all of this is pointless unless you go back and read all foundational papers by Fama, Black, Merton, Fisher and the following most cited empirical tests of theoretical models.

## Toy Example of CAPM

See the previous blog posts for a justification of why the following stocks were chosen and a visualization, exploratory data analysis. We’ll also throw in a “risk-free” asset and the S&P price index.

```
library(tidyquant)
library(timekit)
library(ochRe)
```

The question on how much data to estimate the CAPM is very tricky, and basically should be calibrated for, in order for the estimations to be reliable. I stumbled upon an amazing answer on Quora by S. Hakala, so here is a brief summary: it depends. There are issues of adjusting for changes in the company or industry over time, financial leverage and to accurately reflect the state of it at the current moment. Financial crisis will distort betas, but also looking only at the recovery, removing outliers is also important. There seems so much more to it than the recommended rule of thumb of three years. If you just estimate betas without asking all those questions, the estimates can be very unreliable, which was indeed shown decade after decade by Fama and French.

We’ll do the most naive thing here, following the workflow from tiqyquant. The right thing to do though, is to seriously think about all of the above questions and the problem becomes really hard. Also, the time period for calculating returns, is not at all given or restricted to daily returns.

```
risky.list <- c("GOOGL", "AMZN", "NFLX", "JNJ", "TSLA")
Ra <- risky.list %>%
tq_get(
get = "stock.prices",
from = "2015-01-01",
to = "2017-12-31"
) %>%
group_by(symbol) %>%
tq_transmute(
select = adjusted,
mutate_fun = periodReturn,
period = "daily",
col_rename = "Ra"
)
```

`## Warning: package 'bindrcpp' was built under R version 3.4.4`

`Ra`

```
## # A tibble: 3,775 x 3
## # Groups: symbol [5]
## symbol date Ra
## <chr> <date> <dbl>
## 1 GOOGL 2015-01-02 0.
## 2 GOOGL 2015-01-05 -0.0191
## 3 GOOGL 2015-01-06 -0.0247
## 4 GOOGL 2015-01-07 -0.00294
## 5 GOOGL 2015-01-08 0.00348
## 6 GOOGL 2015-01-09 -0.0122
## 7 GOOGL 2015-01-12 -0.00731
## 8 GOOGL 2015-01-13 0.00954
## 9 GOOGL 2015-01-14 0.00823
## 10 GOOGL 2015-01-15 -0.00379
## # ... with 3,765 more rows
```

```
SP <- getSymbols("SP500", src = "FRED", env = NULL)
Rb <- SP %>% na.omit() %>% tk_tbl(rename_index = "date") %>%
rename(Rb = SP500) %>%
filter(date > as.Date("2015-01-01") &
date < as.Date("2017-12-31")) %>%
tq_transmute(
select = Rb,
mutate_fun = periodReturn,
period = "daily",
col_rename = "Rb"
)
# check the number of days
# nrow(Rb); nrow(Ra[Ra$symbol == "GOOGL",])
Rb
```

```
## # A tibble: 755 x 2
## date Rb
## <date> <dbl>
## 1 2015-01-02 0.
## 2 2015-01-05 -0.0183
## 3 2015-01-06 -0.00889
## 4 2015-01-07 0.0116
## 5 2015-01-08 0.0179
## 6 2015-01-09 -0.00840
## 7 2015-01-12 -0.00809
## 8 2015-01-13 -0.00258
## 9 2015-01-14 -0.00581
## 10 2015-01-15 -0.00925
## # ... with 745 more rows
```

```
data <- left_join(Ra, Rb, by = "date")
data
```

```
## # A tibble: 3,775 x 4
## # Groups: symbol [?]
## symbol date Ra Rb
## <chr> <date> <dbl> <dbl>
## 1 GOOGL 2015-01-02 0. 0.
## 2 GOOGL 2015-01-05 -0.0191 -0.0183
## 3 GOOGL 2015-01-06 -0.0247 -0.00889
## 4 GOOGL 2015-01-07 -0.00294 0.0116
## 5 GOOGL 2015-01-08 0.00348 0.0179
## 6 GOOGL 2015-01-09 -0.0122 -0.00840
## 7 GOOGL 2015-01-12 -0.00731 -0.00809
## 8 GOOGL 2015-01-13 0.00954 -0.00258
## 9 GOOGL 2015-01-14 0.00823 -0.00581
## 10 GOOGL 2015-01-15 -0.00379 -0.00925
## # ... with 3,765 more rows
```

It is useful to observe how the estimations are sensitive to the time interval compared to the last estimation which had more data. The \(R^2\) are decent, but nothing too thrilling. All the KPIs below have some interpretation, and people came up with rules involving Taynor ratios and so on.

```
# tq_performance_fun_options()
capm <- data %>% tq_performance(
Ra = Ra,
Rb = Rb,
performance_fun = table.CAPM
)
capm
```

```
## # A tibble: 5 x 13
## # Groups: symbol [5]
## symbol ActivePremium Alpha AnnualizedAlpha Beta `Beta-` `Beta+`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 GOOGL 0.167 0.000600 0.167 1.04 1.02 1.07
## 2 AMZN 0.469 0.00150 0.458 1.13 1.17 1.08
## 3 NFLX 0.477 0.00160 0.502 1.37 1.64 1.03
## 4 JNJ 0.0413 0.000300 0.0705 0.696 0.664 0.814
## 5 TSLA 0.0328 0.000300 0.0781 1.19 1.45 0.945
## # ... with 6 more variables: Correlation <dbl>,
## # `Correlationp-value` <dbl>, InformationRatio <dbl>, `R-squared` <dbl>,
## # TrackingError <dbl>, TreynorRatio <dbl>
```

```
# for single assets
data %>% tq_performance(
Ra = Ra,
Rb = NULL,
performance_fun = SharpeRatio,
Rf = 0.01 / 12,
p = 0.95)
```

```
## # A tibble: 5 x 4
## # Groups: symbol [5]
## symbol `ESSharpe(Rf=0.1%,p=95%)` `StdDevSharpe(Rf=0.~ `VaRSharpe(Rf=0.1~
## <chr> <dbl> <dbl> <dbl>
## 1 GOOGL 0.0333 0.0124 0.0333
## 2 AMZN 0.0995 0.0606 0.0995
## 3 NFLX 0.0563 0.0489 0.0563
## 4 JNJ -0.0184 -0.0343 -0.0242
## 5 TSLA -0.00154 -0.00368 -0.00228
```

```
# for portfolios
w <- tibble(
symbols = c("GOOGL", "AMZN", "NFLX", "JNJ", "TSLA"),
weights = c(0.4, 0.25, 0.25, 0.05, 0.05)
)
p1 <- Ra %>% tq_portfolio(
assets_col = symbol,
returns_col = Ra,
weights = w,
col_rename = "Ra"
)
# mean(p1$Ra); sd(p1$Ra)
```

From a brief look at the scatterplots, a removal of outliers might help get more robust estimates.

```
data %>%
ggplot(aes(x = Rb, y = Ra, color = symbol)) +
geom_point(alpha = 0.2) +
geom_hline(yintercept = c(0.06, -0.07), lty = 2, color = "grey40") +
geom_smooth(method = "lm", se = FALSE) +
facet_wrap(~symbol, ncol = 3) +
scale_color_ochre(palette = "tasmania") +
theme_minimal() +
labs(x = "Baseline SP500 Return", y = "Asset Return",
title = "Relationship between asset return and market")
```

Assess the validity of the model using t-tests, Ramsey test for linearity, homoskedasticity test, Autocorrelation of first and higher order (Durbin-Watson statistic), Kolmogorov-Smirnov Normality test, Chow test. I always wondered about the carelessness these tests are taught, as tests are also models and might fail in unexpected ways, are based on assumptions. As a practitioner of statistics it would be nice not to abuse them myself.

Evaluate the performance of CAPM on hold-out dataset

## Soft Event Analysis

What happened at the global level? Market Level?

Extensive descriptive statistics for a pair of market index and a stock (for daily returns)

Cohraine and Larsen, other two giants of finance argue that there’s a whole world beyond analysing returns: Volumes and Prices themselves.

ACF, PACF, ARMA, ARCH-GARCH and model selection

## Concluding remarks

In conclusion, it’s impossible to rigorously study and build models of portfolios without knowing the assumptions. After carefully listening to these giants of finance, “technical analysis” presented in the last two posts seems like woodoo. If you show me a great performance by someone using technical anaysis, how much can be attributed to chance (when you take into account the sample size)? Suddenly, Taleb Nassim’s “Fooled by Randomness” presses the right pain points, even if you don’t like it.

Fama, Eugene F; French, Kenneth R (Summer 2004). “The Capital Asset Pricing Model: Theory and Evidence”↩