Workshop 2, Investment Funds

Author

Alberto Dorantes, Ph.D.

Published

April 17, 2024

Abstract
In this workshop we learn the foundations of the Capital Asset Pricing Model (CAPM) and multi-factor models. In addition, we further explore how these models can help us define the right variance-covariance matrix for portfolio optimization.

1 General directions for this Workshop

Using an RNotebook in Google Colab you have to:

Replicate all the R Code along with its output.

You have to do whatever is asked in the workshop. It can be: a) Responses to specific questions and/or do an exercise/challenge.

Any QUESTION or any INTERPRETATION you need to do will be written in CAPITAL LETTERS. For ANY QUESTION or INTERPRETATION, you have to RESPOND IN CAPITAL LETTERS right after the question.

It is STRONGLY RECOMMENDED that you write your OWN NOTES as if this were your personal notebook. Your own workshop/notebook will be very helpful for your further study.

You have to submit the link of your Google Colab. You must share your notebook with the Tec de Monterrey community.

2 The CAPM model

The Capital Asset Pricing Model states that the expected return of a stock is given by the risk-free rate plus its beta coefficient multiplied by the market premium return. In mathematical terms:

E[R_i] = R_f + β_1(R_M − R_f )

We can express the same equation as:

(E[R_i] − R_f ) = β_1(R_M − R_f )

Then, we are saying that the expected value of the premium return of a stock is equal to the premium market return multiplied by its market beta coefficient.

In this model there is NO b_0 coefficient since the CAPM assumes that b_0 should be zero since there should not be a stock that systematically offeres excess returns compared to the market returns. However, when we estimate the CAPM with historical data, it is very recommended to estimate the b_0 coefficient.

Then, the CAPM model used to estimate its beta coefficients is expressed as:

StockPremiumReturn_{i,t} = b_0 + b_1(MarketPremiumReturn_t) + ε_t Where:

StockPremiumReturn_{i,t}=(E[R_i] − R_f)

MarketPremiumReturn_{i,t}=(R_M − R_f)

ε_t ∼ N(0, σ_ε); the error is a random shock with an expected mean=0 and a specific standard deviation or volatility. This error represents the result of all factors that influence stock returns, and cannot be explained by the model (by the market).

As in the Single-Index model, you can estimate the b_1 coefficient of the CAPM as:

b_1=\frac{cov(MarketPremiumReturn,StockPremiumReturn_i)}{var(MarketPremiumReturn)}

And the b_0 coefficient can be calculated as:

b_0 = \overline{StockPremiumReturns_i} - b_1*\overline{MarketPremiumReturns}

Remember that the bar over the variable means the arithmetic mean of the variable.

In the CAPM we use premium returns instead of returns for the calculation of the beta coefficients.

The interpretation of b_1 in the CAPM is the same than in the Single-Index Model, but we have to refer to premium returns instead of returns. Then, b_1 is a measure of market risk of the stock, while b_0 is a measure of excess return of the stock over the market.

If b_1=2.0, the means that the risk of the stock is the doble compared to the market. In other words, for each +1% of change in the market premium return, it is expected that the stock premium return will move in aboutg +2%.

The CAPM was developed based on Portfolio Theory. More specifically, CAPM was developed after the concept of Capital Market Line (CML). The CML was derived in the 1960’s from Markowitz Portfolio Theory (developed 1953). The main contributors to the idea of the CML and the development of the CAPM are Jack Treynor, William F. Sharpe, John Litner and Jan Mossin.

Remember that the CML is the set of efficient portfolios when the risk-free asset is added to the optimal portfolio of risky assets.

It is assumed that, if all participants of a financial market are risk-averse, and if they estimate the risk and correlations of assets returns in the same way, then the most optimal portfolio of risky assets that offer the highest premium return for each unit of risk is the Market Portfolio. In other words, the Market Portfolio is expected to have the highest possible Sharpe ratio. Remember that Sharpe ratio is a measure of how much expected return a portfolio offers for each unit of risk (1 unit of standard deviation). Then, the Sharpe ratio is estimated as:

SharpRatio = \frac{(E[PortRet]-RiskFreeRate)}{SD(PortfolioReturn)} When we add the risk-free rate to the tangency portfolio, **then the set of efficient portfolios will NOT lie in the curved efficient frontier; the efficient portfolios will lie in the Capital Market Line.

In other words, the CML becomes the efficient frontier after adding the risk-free instrument to the tangent portfolio of risky assets.** The CML equation is:

E[PortRet]=RiskFreeRate+\left[\frac{(E[MarketReturn]-RiskFreeRate)}{SD(MarketReturn)}\right]PortfolioRisk

The ratio in the brackets is the Sharpe Ratio, which is the slope of the Capital Market Line when plotting PortfilioRisk in the X axis and Expected Portfolio Return in the Y axis.

Imagine we want to do a portfolio with 5 stocks. Then, we can estimate the expected return of each stock, and then estimate the efficient frontier and the optimal portfolio using Portfolio Theory.

[1] "TSLA" "AMZN" "AAPL" "JPM"  "WMT" 
Call:
globalMin.portfolio(er = ER, cov.mat = COV, shorts = FALSE)

Portfolio expected return:     0.009853649 
Portfolio standard deviation:  0.04744997 
Portfolio weights:
  TSLA   AMZN   AAPL    JPM    WMT 
0.0000 0.0901 0.0000 0.2227 0.6872 
Call:
tangency.portfolio(er = ER, cov.mat = COV, risk.free = rfree, 
    shorts = FALSE)

Portfolio expected return:     0.0245524 
Portfolio standard deviation:  0.07979925 
Portfolio weights:
  TSLA   AMZN   AAPL    JPM    WMT 
0.0551 0.0000 0.7647 0.0000 0.1802 

Assuming a risk-free rate = 3%, the efficient frontier, the tangency portfolio and the Capital Market Line for this portfolio would be:

The green line is the Capital Market Line (CML) for this example. We can see that the CML is more efficient than the efficient frontier (the blue curved line). There are some risk levels around 5% and 6% of portfolio risk where the portfolios that lie in the CML have higher expected returns compared to the blue efficient portfolios!

How can we interpret the CML? The different portfolios that lie in the CML are constructed with 2 assets.

  • The risk-free asset

  • The tangency portfolio

If we invest 100% if the risk-free asset and 0% in the tangency portfolio, then we are in the initial point of the CML (at the left); if we invest 0% in the risk-free and 100% in the tangency portfolio, then we are in the tangency point of the CML. Then, if we invest 50% in the risk-free and 50% in the tangency portfolio, we will be in the middle point of the CML between the risk-free portfolio and the tangency portfolio.

The CML portfolios that lie to the right of the tangency portfolio are portfolios that short the risk-free rate and then invest more money in the tangency portfolio (long the tangency and short the risk-free asset). This cannot be done in the real world since we cannot get a loan with a rate equal to the the risk-free rate!

Then, any point in the CML is a combination of weights between the tangency portfolio and the risk-free asset.

If we could create a portfolio considering ALL stocks in the US market and running the same optimization process we did, it is expected that the tangency portfolio will be the Market Portfolio with weights equal to the proportion of market capitalization of each stock compared to the total capitalization of the market. This will be true if we do the following assumptions:

  • All investors are risk-averse, but they are mean-variance optimizers. In other words, they are 100% rational (they prefer maximize return for each risk level)

  • All investors calculate in the same way the expected return of each asset, expected risk of each asset, and correlations of all pairs of assets (the covariance matrix)

Then, with these assumptions, if we keep adding stocks to our portfolio of 5 assets until we add ALL of them, then it is expected that the Tangency (optimal) portfolio will be the Market Portfolio.

With this idea of adding stocks to a portfolio, the idea of the CAPM was developed.

Once we add many stocks and estimate the tangency portfolio we will be close to the Market Portfolio.

In the next section, I describe the details of how the CAPM was developed from Portfolio Theory.

2.1 Derivation of the CAPM

Here I explain a mathematical derivation of the CAPM (see Sharpe 1964 for more details).

I start developing the equation for the Capital Market Line. From Portfolio Theory, we know that the market portfolio is the tangency portfolio and is the most optimal portfolio (with the assumptions I mentioned earlier).

The first idea to come up to the CML is that we can construct a portfolio of 2 assets: the risk-free asset and the market portfolio. Then we can describe the return of this portfolio R as follows:

P=wR_{f}+\left(1-w\right)R_{m}

Following Portfolio Theory, we can estimate the variance and risk of this portfolio R as:

VAR[P]=w^{2}VAR(R_{f})+(1-w)^{2}VAR(R_{m})+2w(1-w)COV(R_{f},R_{m})

Since the R_f is the risk-free rate asset, then by definition it has no variability (it is constant) so its variance and its covariance with the market return must be zero. Then, the variance of the portfolio P can be written as:

VAR(P)=(1-w)^2VAR(R_m)

Taking the squared root of both sides to get the portfolio risk:

PortfolioRisk=SD(P)=(1-w)SD(R_m)

Then the risk of the portfolio will be reduced as the % allocated to the risk-free asset (w) increases; if w=1 then the risk becomes zero since 100% is invested in the risk-free asset. If w=0, then the risk becomes the risk of the market.

To simplify the notation, I will use the Greek letter for standard deviation ($\sigma$) and variance $\sigma^{2}$:

\sigma_{p}=(1-w)\sigma_{_{m}}

Then the return and risk of the portfolio P depends on w. Then I can estimate how much the return and risk changes for a change in w, and then estimate how much the portfolio return changes when the portfolio risk changes. To do this, I can take the partial derivative of the portfolio return and risk equations with respect to w, and then divide both derivatives to get the rate of change in return for a change in risk:

\frac{\delta\sigma_{p}}{\delta w}=-\sigma_{m}

\frac{\delta P}{\delta w}=R_{f}-R_{m}

Now dividing both derivatives I get the marginal change of portfolio return for any change in portfolio risk:

\frac{\delta R}{\delta\sigma_{p}}=\frac{(R_{m}-R_{f})}{\sigma_{m}}

We arrive to the slope of the Capital Market Line, which is also called the Sharpe Ratio. The numerator is the market premium return and the denominator is the risk of the market. Then the Sharpe Ratio measures how much the market premium return changes for each unit of change in the market risk.

Since the CML states a linear relation between the portfolio return (Y axis) and portfolio risk (X axis), we can get the CML equation considering that the point where the line crosses the Y axis (the portfolio return) is the risk-free return:

CML=E[P]=R_f+\frac{(R_{m}-R_{f})}{\sigma_{m}}\sigma_p

Now, with a similar logic, we can think in a portfolio composed of 2 assets:

R_i: A risky asset i

R_m: The market portfolio

Then, we assign w% to the asset i and (1-w)% to the market return. Then, this new portfolio can be written as:

P=wR_{i}+\left(1-w\right)R_{m}

Following Portfolio Theory, we can estimate the variance and risk of this portfolio R as:

VAR[P]=w^{2}VAR(R_{i})+(1-w)^{2}VAR(R_{m})+2w(1-w)COV(R_{i},R_{m})

Using the notation of sigma squared for the variances, I can re-write this formula as:

\sigma^{2}_{p}=w^2\sigma^{2}_{i}+(1-w)^{2}\sigma^2_{m}+2w(1-w)\sigma_{im}

Where \sigma_{im} is the covariance between the stock return and the market return.

Then the portfolio risk is the squared root of its variance:

\sigma_{p}=\left[w^2\sigma^{2}_{i}+(1-w)^{2}\sigma^2_{m}+2w(1-w)\sigma_{im}\right]^{\frac{1}{2}}

Following the same rational than in the case of the portfolio of the risk-free and the market assets, I take the partial derivatives of return and risk with respect to the weight w , and then divide these 2 derivatives to get the marginal change of return for any change in portfolio risk:

\frac{\delta P}{\delta w}=R_i-R_m

Now I do the same for portfolio risk:

\frac{\delta\sigma_{p}}{\delta w}=\frac{1}{2}\left[\frac{2w\sigma_{i}^{2}+2(1-w)(-1)\sigma_{m}^{2}+\sigma_{im}(2)-4w\sigma_{im}}{\sigma_{p}}\right]

Simplifying:

\frac{\delta\sigma_{p}}{\delta w}=\frac{w\sigma_{i}^{2}+(w-1)\sigma_{m}^{2}+\sigma_{im}-2w\sigma_{im}}{\sigma_{p}}

When w=0 I am considering only the Market Portfolio, so the portfolio p becomes the market portfolio. Then, I evaluate this derivative when w=0 to see the rate of change of portfolio return with respect to weight:

\frac{\delta\sigma_{p}}{\delta w}\mid_{w=0}=\frac{\sigma_{im}-\sigma_{m}^{2}}{\sigma_{m}}

Now dividing both derivatives I get the instantaneous rate of change of return with respect to portfolio risk at the Market portfolio:

\frac{\delta P}{\delta\sigma_{p}}\mid_{w=0}=\frac{(R_i-R_m)\sigma_{m}}{\sigma_{im}-\sigma_{m}^{2}}

The rate of change of return with respect of portfolio risk must be equal to the Sharpe Ratio since this portfolio is the market return (w=0). Then, I make this equation equal to the Sharpe Ratio and do some algebra to get the return of the stock in terms of the return of the market:

SharpeRatio=\frac{(R_{m}-R_{f})}{\sigma_{m}}

Then:

\frac{(R_{m}-R_{f})}{\sigma_{m}}=\frac{(R_i-R_m)\sigma_{m}}{\sigma_{im}-\sigma_{m}^{2}}

Moving terms to leave R_i alone we get:

R_{i}=R_{f}+\frac{\sigma_{im}}{\sigma_{m}^{2}}(R_{m}-R_{f})

The ratio of covariance divided by the variance of the market return is actually the beta coefficient of the stock, which is a measure of market risk of the stock.

We arrive to the Capital Asset Pricing Formula!

Then, when a market there is equilibrium (supply equals demand), the CAPM equation should hold. The CAPM states that the expected return of a risky assets is equal to the risk-free rate plus the market premium return multiplied (scaled) by stock beta. The stock beta measures the market risk of a stock, which is how much on average the premium return of the stock changes for each change in the market premium return.

2.2 Estimation of the CAPM beta

We can estimate the beta of each stock using a simple linear regression with historical cc returns.

Moving the risk-free rate to the left of the CAPM equation, we can express the CAPM as:

(R_i − R_f ) = β_1(R_M − R_f )

Then, we are saying that the expected value of the premium return of a stock is equal to the premium market return multiplied by its market beta coefficient. You can estimate the beta coefficient of the CAPM using a regression model and using continuously compounded returns instead of simple returns. However, you must include the intercept b0 in the regression equation:

(r_i − r_f ) = β_0 + β_1(r_M − r_f ) + ε

Where ε ∼ N(0, σ_ε); the error is a random shock with an expected mean=0 and a specific standard deviation or volatility. This error represents the result of all factors that influence stock returns, and cannot be explained by the model (by the market).

In the single-index model, the dependent variable was the stock return and the independent variable was the market return. Unlike the market model, here the dependent variable is the difference between the stock return minus the risk-free rate (the stock premium return), and the independent variable is the premium return, which is equal to the market return minus the risk-free rate. Let’s run this model in r with a couple of stocks.

According to the market efficiency hypothesis, it is expected that the β_0 coefficient is zero, since it is assumed that there is no asset or financial instrument that systematically outperforms the market. The market efficient hypothesis states that all information of a stock that is released to the market is assimilated immediately by all market participants, which will react accordingly and will make the stock to price correctly without systematically beating the market.

Although the theory states that β_0 must be zero, we have to include it in the model, and, if the theory is true, then we expect that the p-vaue of beta0 to be non-significant. According to the market efficient hypothesis, if β_0 is estimated, it is expected that, if it is not zero (that will always be the case), it will not be statistically significant! In other words, although it will be non-zero, since its p-value should be much greater than 0.05, then it is like assuming that β_0 is zero since it could be negative, zero or positive.

Let’s do an exercise to estimate the CAPM.

2.3 Data collection

We first clean our environment and load the quantmod package:

# To clear our environment we use the remove function rm:
rm(list=ls())

# To avoid scientific notation for numbers: 
options(scipen=999)

# load package quantmod
library(quantmod)

2.4 Download stock data

Download monthly stock data for Apple, Tesla and the S&P500 from 2014 to Dec, 2020 from Yahoo Finance using the getSymbols function and obtain continuously compounded returns for each.

getSymbols(c("AAPL", "^GSPC", "TSLA"), from="2019-01-01", 
           to="2023-09-22", periodicity="monthly", src="yahoo")
[1] "AAPL" "GSPC" "TSLA"
#I select only the adjusted prices of each stock and merge them together:
prices <- merge(Ad(AAPL), Ad(GSPC), Ad(TSLA))

# I calculate continuously compounded returns to all columns of the 
#   price object:
APPL_r <- na.omit(diff(log(prices$AAPL.Adjusted)))
GSPC_r <- na.omit(diff(log(prices$GSPC.Adjusted)))
TSLA_r <- na.omit(diff(log(prices$TSLA.Adjusted)))

# I use the na.omit() function to remove NA values (since the first month 
#  is not possible to calculate returns) and select only Adjusted columns.

2.5 Download risk-free data from the FED

Download the risk-free monthly rate for the US (6-month treasury bills), which is the TB6MS ticker:

getSymbols("TB3MS", src = "FRED")
[1] "TB3MS"

This return is given in percentage and in annual rate. I divide it by 100 and 12 to get a monthly simple rate since I am using monthly rates for the stocks:

rfrate<-TB3MS/100/12

Now I get the continuously compounded return from the simple return:

rfrate <- log(1+rfrate)

I used the formula to get cc reteurns from simple returns, which is applying the natural log of the growth factor (1+rfrate)

2.6 Subsetting the risk-free dataset

Unfortunately, when getSymbols brings data from the FED, it brings all historical values of the series, even though the end date is specified.

Then, I do a sub-setting of the risk-free rate dataset to keep only those months that are equal to the months I brought for the stocks:

rfrate <- rfrate["2019-02-01/2023-09-01"]

2.7 Estimating the premium returns

Now you have to generate new variables (columns) for the premium returns for the stocks and the S&P 500. The premium returns will be equal to the returns minus the risk-free rat:

TSLA_Premr <- TSLA_r - rfrate
APPL_Premr <- APPL_r - rfrate
GSPC_Premr <- GSPC_r - rfrate

3 Q Visualize the relationship

  1. Do a scatter plot putting the S&P500 premium returns as the independent variable (X) and Tesla premium return as the dependent variable (Y). We also add a line that better represents the relationship between the stock returns and the market returns:
plot.default(x=GSPC_Premr, y=TSLA_Premr)
abline(lm(TSLA_Premr ~ GSPC_Premr),col='blue')

Sometimes graphs can be deceiving. In this case, the range of X axis and Y axis are different, so it is better to do a graph where we can make both X and Y ranges with equal distance. We also add a line that better represents the relationship between the stock returns and the market returns. Type:

plot.default(x=GSPC_Premr, y=TSLA_Premr, ylim=c(-0.5,0.5),xlim=c(-0.6,0.6))
abline(lm(TSLA_Premr ~ GSPC_Premr),col='blue')

WHAT DOES THE PLOT TELL YOU? BRIEFLY EXPLAIN

4 Q Estimating the CAPM model for a stock

Use the premium returns to run the CAPM regression model for each stock.

We start with Tesla:

Tesla_CAPM <-lm(TSLA_Premr ~ GSPC_Premr, na.action=na.omit)

# Note that I added the parameter na.action=na.omit to validate in case some
# of the return series have NA values. NA values will be omitted
# I apply the function summary to the Tesla_CAPM object to get the coefficients and the
# standard errors. I assign the result in the Tesla_s object
Tesla_s <-summary(Tesla_CAPM)
# The summary function, shows the results for the B1 and B0 coefficients, their
# residuals, t and p values.
# The first line shows the B0 coefficients
# The second, the coefficients for B1

Tesla_s

Call:
lm(formula = TSLA_Premr ~ GSPC_Premr, na.action = na.omit)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.34916 -0.08349 -0.00128  0.11682  0.41868 

Coefficients:
            Estimate Std. Error t value   Pr(>|t|)    
(Intercept)  0.02809    0.02252   1.248      0.218    
GSPC_Premr   2.23248    0.42153   5.296 0.00000223 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1671 on 54 degrees of freedom
Multiple R-squared:  0.3419,    Adjusted R-squared:  0.3297 
F-statistic: 28.05 on 1 and 54 DF,  p-value: 0.000002226

To do a rough estimate of the 95% confidence interval for B0:

minB0 <- Tesla_s$coefficients[1,1]  - (2* Tesla_s$coefficients[1,2] )
maxBO <-  Tesla_s$coefficients[1,1]  + (2* Tesla_s$coefficients[1,2] )

cat("The approx. B0 confidence interval goes from", minB0, "to", maxBO)
The approx. B0 confidence interval goes from -0.01694103 to 0.07312409

To estimate the 95% confidence interval for B1:

minB1 <- Tesla_s$coefficients[2,1]  - (2* Tesla_s$coefficients[2,2] )
maxB1 <-  Tesla_s$coefficients[2,1]  + (2* Tesla_s$coefficients[2,2] )

cat("The approx. B1 confidence interval goes from", minB1, "to", maxB1)
The approx. B1 confidence interval goes from 1.389419 to 3.075543

Follow the same procedure to get Apple’s CAPM and respond after you run your CAPM regression model for both stocks:

(a) INTERPRET THE RESULTS OF THE COEFFICIENTS (b0 and b1), THEIR STANDARD ERRORS, P-VALUES AND 95% CONFIDENCE INTERVALS.

(b) DO A QUICK RESEARCH ABOUT THE EFFICIENT MARKET HYPOTHESIS. BRIEFLY DESCRIBE WHAT THIS HYPOTHESIS SAYS.

(c) ACCORDING TO THE EFFICIENT MARKET HYPOTHESIS, WHAT IS THE EXPECTED VALUE OF b0 in the CAPM REGRESSION MODEL?

(d) ACCORDING TO YOUR RESULTS, IS TESLA SIGNIFICANTLY RISKIER THAN THE MARKET ? WHAT IS THE t-test YOU NEED TO DO TO RESPOND THIS QUESTION? Do the test and provide your interpretation. (Hint: Here you have to change the null hypothesis for b1: H0: b1=1; Ha=b1<>1)

5 Multi-Factor Models

After the CAPM was introduced, it received strong critiques by researchers and analysts since there were some stocks that had positive abnormal returns that were not explained by the CAPM. In other words, several stocks had alpha coefficients significantly positive for a long time. These and other cases are considered anomalies since the CAPM does not explain the excess return of all assets all the time. In other words, there should be other sources of systematic risk, not only the market risk.

In 1993, the 3-factor (Fama&French) model was proposed. This factor model starts with the CAPM model and adds 2 other sources of systematic risk. The sources of systematic risk are called factors.

The FF 3-factor model includes the following factors:

  • Market Factor

  • Value Factor

  • Size Factor

The value factor refers that firms with high book-to-market value usually get higher future returns compared to firms with low book-to-market value. The book-to-market value of a stock is the ratio:

BTM_t =\frac{bookvalue_t}{marketvalue_t}

The book value at any accounting period t is the accounting value of a stock, which can be estimated as the difference between total assets minus total liabilities:

bookvalue_t=totalassets_t-totalliabilities_t

Then, if both values are equal, BTM =1. Most current active firms have BTM that are much less than 1, so the market value must be always greater than the book value. This difference can be explained by intangible assets such as competitive advantage, quality of products/services, innovation, reputation, etc.

The market value of a stock at any period t is the product of stock price times the number of shares outstanding:

marketvalue_t=(stockprice_t)(sharesoutstanding)

The value factor is estimated “artificially” by creating 2 portfolios over time: one with firms with high BMV and firms with low BMV. The portfolio returns are subtracted each period to get the difference in returns between the portfolio with high BMV and the portfolio with low BMV.

It is supposed that this is a factor that measure how firms with high BMV usually recover and surprise with excess returns in the near future.

The size factor refers that usually small firms get high future returns compared to big firms. This factor is also calculated “virtually” by creating a portfolio with small firms and a portfolio with big firms over time, and then get the difference between these 2 portfolios. This difference is considered the SIZE factor.

Then, now the 3 factors, market, value and size are calculated with excess returns. The market is calculated as the market return minus the risk-free return; the value factor is calculated as the difference between the portfolio of high BMV portfolio returns minus low BMV portfolio returns overtime. The size factor is calculated as the difference of returns between the portfolio with SMALL firms and the portfoio with BIG firms.

5.1 Estimatig 3-factor FF model with real data

The FF factors are constantly estimated for the US and other international markets. These calculations are public and can be downloaded from a web page (https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html)

We use the frechdata R library to automatically get the FF factors from this page:

library(dplyr)
library(frenchdata)

After the 3-factor FF model, they proposed other 2 extra factors, so now we can use up to 5 factors to model stock returns. These extra factors are profitability and investment pattern.

I download the historic series for the 5 factors for the US market:

ff5 =
  download_french_data("Fama/French 5 Factors (2x3)")

The ff5 R object is a list of 3 datsets. The first dataset contains monthly historical returns of the factors. Then, I get the first dataset:

ff5data = ff5$subsets$data[[1]]
# I see the most current values of the factors:
tail(ff5data)
# A tibble: 6 × 7
    date `Mkt-RF`   SMB   HML   RMW   CMA    RF
   <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 202309    -5.24 -1.8   1.52  1.86 -0.83  0.43
2 202310    -3.19 -4.05  0.19  2.46 -0.66  0.47
3 202311     8.84 -0.12  1.64 -3.91 -1     0.44
4 202312     4.87  7.32  4.93 -3.07  1.32  0.43
5 202401     0.71 -5.74 -2.38  0.69 -0.96  0.47
6 202402     5.06 -0.78 -3.48 -1.98 -2.13  0.42

Now I download historic stock prices of a company to run the FF 3-factor model:

Bajo datos de precios de 1 empresa para hacer mi modelo de 3 factores:

library(quantmod)
getSymbols(Symbols=c("WMT"), periodicity="monthly",from="2019-01-01")
[1] "WMT"

I calculate monthly returns:

ret = diff(log(Ad(WMT)))
names(ret)=c("rwmt")

I do some data management to put the historical data into 1 dataset before I run the multiple regression model:

library(xts)
library(lubridate)
ff5data$m = ym(ff5data$date) 
# I change the dataset to an xts time-series dataset:
ff5data.xts <- xts(x = ff5data, order.by = ff5data$m)
# I merge both datasets:
dataw = merge(ff5data.xts,ret)

dataw = dataw["2019-01-01/"]

The return data of the FF factors are in percentage, so I have to do the right transformation. I can multply times 100 the stock returns:

dataw$rwmt = dataw$rwmt * 100
dataw$rmktp = dataw$Mkt.RF
# I calculate the stock premium returns:
dataw$rwmtp =dataw$rwmt - dataw$RF

I run the models:

# CAMP:
modcapm = lm(rwmtp ~ rmktp, data=dataw, na.action=na.omit )
summary(modcapm)

Call:
lm(formula = rwmtp ~ rmktp, data = dataw, na.action = na.omit)

Residuals:
    Min      1Q  Median      3Q     Max 
-17.692  -2.064   0.693   3.044  10.776 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   0.4713     0.5991   0.787 0.434570    
rmktp         0.4487     0.1084   4.139 0.000112 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 4.581 on 59 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.225, Adjusted R-squared:  0.2119 
F-statistic: 17.13 on 1 and 59 DF,  p-value: 0.0001124
# FF3 factor model:
modff3 = lm(rwmtp ~ rmktp + SMB + HML, data=dataw, na.action=na.omit )
summary(modff3)

Call:
lm(formula = rwmtp ~ rmktp + SMB + HML, data = dataw, na.action = na.omit)

Residuals:
     Min       1Q   Median       3Q      Max 
-16.6925  -2.2518   0.8044   2.5979   8.3818 

Coefficients:
            Estimate Std. Error t value   Pr(>|t|)    
(Intercept)  0.24956    0.57331   0.435     0.6650    
rmktp        0.54741    0.10941   5.003 0.00000573 ***
SMB         -0.48203    0.20072  -2.401     0.0196 *  
HML         -0.09215    0.12835  -0.718     0.4757    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 4.341 on 57 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.3278,    Adjusted R-squared:  0.2924 
F-statistic: 9.266 on 3 and 57 DF,  p-value: 0.00004377

You have to interpret the FF model in detail

6 CHALLENGE

  • Para el dataset de empresas de Estados Unidos, calcular:

o Book-to-market ratio o Earnings per share ratio o Size o Stock returns

  • Visualizar tendencias de crecimientos: o Valor de mercado¬¬ o BMR o Ventas / NetIncome

Reportar insights generales

  • Correr Modelos de regresión para examinar la relación entre Stock return y bmr, size y eps. Controlar por tiempo (años)

o Modelo 1: Variable dependiente: F1 Stock anual returns – main effects

o Modelo 2: Variable dependiente : F4 Stock anual returns – main effects

o Modelo 3: Variable dependiente: F1 Stock anual returns – main effects e interacción entre eps y bmr

o Modelo 4: Variable dependiente: F1 Stock anual returns – main effects e interacción entre eps y size

o Modelo 5: Variable dependiente: F4 Stock anual returns – main effects e interacción entre eps y bmr

o Modelo 6: Variable dependiente: F4 Stock anual returns – main effects e interacción entre eps y size

Del output de todos los modelos, idenfificar principales insights de la relación de los fundamentales vs stock returns. Puedes interpretar en detalle 1 modelo y hacer comparaciones con los otros.

Qué resultados son consistentes y cuáles son inesperados de acuerdo al modelo de factores de Fama & French?

  • Considerar los siguientes 2 portafolios con 5 stocks

o Portafolio 1 – Utilizando BMR y Earnings per Share divide by price, qué stocks seleccionarías de acuerdo a tus insights de la regresión fundamental?

o (opcional) Portafolio 2 – Utilizando Firm Size y Earnings per Share divided by price, qué stocks seleccionarías de acuerdo a tus insights de la regresión fundamental?

  • Estimar Modelos de 3 factores para los 5 stocks seleccionados del Portafolio 1 o Interpretar en detalle 1 Modelo, y reportar insights del resultado de los otros 4 modelos en cuestión de riesgo sistemático vs no-sistemático

  • En base a los modelos de factores, qué pesos asignarías y por qué? Cómo utilizas el riesgo sistemático vs no-sistemático de cada stock para maximizar el posible retorno-riesgo de tu portafolio? Qué riesgo sistemático de mercado tendría tu portafolio? Considera que el portafolio es para mediano-largo plazo. Puedes hacer tus suposiciones

7 W2 submission

The grade of this Workshop will be the following:

  • Complete (100%): If you submit an ORIGINAL and COMPLETE HTML file with all the activities, with your notes, and with your OWN RESPONSES to questions

  • Incomplete (75%): If you submit an ORIGINAL HTML file with ALL the activities but you did NOT RESPOND to the questions and/or you did not do all activities and respond to some of the questions.

  • Very Incomplete (10%-70%): If you complete from 10% to 75% of the workshop or you completed more but parts of your work is a copy-paste from other workshops.

  • Not submitted (0%)

Remember that you have to submit your .html file through Canvas BEFORE THE FIRST CLASS OF NEXT WEEK.