Workshop 3 Solution, Econometric Models

Author

Alberto Dorantes

Published

March 5, 2024

Abstract
This is an INDIVIDUAL workshop. In this workshop we keep learning about Simple Regression Model and its application to estimate the Capital Asset Pricing Model (CAPM).

1 Q Estimating the CAPM model for a stock

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. 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 market 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.

3 Data collection

We load the quantmod package (remember to install it in Google Colab)

# load package quantmod
library(quantmod)

3.1 Download stock data

Download monthly stock data for Apple, Tesla and the S&P500 from 2019 to Feb 23, 2024 from Yahoo Finance using the getSymbols function and obtain continuously compounded returns for each.

getSymbols(c("^GSPC", "AAPL", "TSLA"), from="2019-01-01", 
           to="2024-02-23", periodicity="monthly", src="yahoo")
[1] "GSPC" "AAPL" "TSLA"
# I join the 3 price datasets:
prices = merge(GSPC, AAPL, TSLA) 
# I get only the adjusted prices:
adjprices = Ad(prices)
# I calculate continuously compounded returns:
returns = diff(log(adjprices))
# I drop the first row since they have NA values:
returns = na.omit(returns)
# I rename the column names of the returns dataset
colnames(returns) = c("GSPC","AAPL", "TSLA")

3.2 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"

The TB3MS serie 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 returns from simple returns, which is applying the natural log of the growth factor (1+rfrate)

3.3 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/2024-02-01"]

3.4 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 = returns$TSLA - rfrate 
GSPC_Premr = returns$GSPC - rfrate

4 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.7,0.7))
abline(lm(TSLA_Premr ~ GSPC_Premr),col='blue')

WHAT DOES THE PLOT TELL YOU? BRIEFLY EXPLAIN

R: I CAN SEE THAT THE RANGE OF PREMIUM RETURNS OF THE MARKET (GSPC) RANGES APPROX. BETWEEN -18% AND +8%, WHILE THE TESLA PREMIUM RETURNS RANGES BETWEEN MORE THAN -40% TO +40% MONTHLY RETURNS.

I CAN ALSO SEE THAT TESLA PREMIUM RETURNS ARE POSITIVELY RELATED TO THE MARKET PREMIUM RETURNS, AND ITS SENSITIVITY TO CHANGES IN THE MARKET PREMIUM RETURN IS VERY HIGH. I CAN SEE THAT APPROX. FOR EACH + 1.00 PERCENT POINT OF INCREASE IN THE MARKET PREMIUM RETURN, TESLA PREMIUM RETURN MOVES IN MUCH MORE THAN +1.00 PERCENT POINT SINCE THE SLOPE OF THE LINE IS VERY INCLINED WITH A DEGREE HIGHER THAN 45 DEGREES, WHICH IS SLOPE=1.

5 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.33689 -0.07713 -0.01174  0.12030  0.43028 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.01647    0.02181   0.755    0.453    
GSPC_Premr   2.22377    0.41210   5.396 1.27e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.168 on 59 degrees of freedom
Multiple R-squared:  0.3305,    Adjusted R-squared:  0.3191 
F-statistic: 29.12 on 1 and 59 DF,  p-value: 1.266e-06

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.02714767 to 0.06008389

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.399573 to 3.047965

6 CHALLENGE

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

6.1 INTERPRETATIONS FOR TESLA

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

LOOKING AT THE RESULTS FOR BETA0 (Intercept) I CAN SEE THE FOLLOWING:

THE ESTIMATION OF THE AVERAGE FOR BETA0 IS 0.0164681. THEN, ON AVERAGE TESLA OFFERS EXCESS PREMIUM RETURNS OVER THE MARKET.

HOWEVER, LOOKING AT THE STANDARD ERROR OF BETA0 WE CAN IDENTIFY WHETHER BETA0 IS SIGNIFICANTLY GREATER THAN ZERO AT THE 95% CONFIDENCE INTERVAL. IF WE SUBTRACT ABOUT 2 STANDARD DEVIATIONS FROM ITS MEAN AND ADD ABOUT 2 STANDARD ERRORS FROM ITS MEAN, WE CAN ESTIMATE HOW MUCH -WITH A PROBABILITY OF 95%- THE BETA0 WILL MOVE IN THE FUTURE:

95% CONFIDENCE INTERVAL FOR BETA0 = [-4.4310697 .. 4.4640059 ]

THIS MEANS THAT BETA0 CAN MOVE FROM A NEGATIVE VALUE, TO ZERO TO A POSITIVE VALUE WITH A PROBABILITY OF 95%. IN OTHER WORDS, BETA0 IS NOT SIGNIFICANTLY GREATER THAN ZERO, INDICATING THAT AT THE 95% CONFIDENCE LEVEL, TESLA IS NOT OFFERING PREMIUM RETURNS OVER THE MARKET

WE CAN SEE THAT THE P-VALUE FOR BETA0 IS 0.44. THIS MEANS THAT WITH A PROBABILITY OF 56% (1-0.44), I COULD REJECT THE NULL HYPOTHESIS (ACCEPT THAT BETA0 IS POSITIVE). IN OTHER WORDS, THE PROBABILITY THAT I WILL BE WRONG IF I ACCEPT THAT BETA0 IS POSITIVE IS 44%.

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

THIS HYPOTHESIS STATES THAT SHARE PRICES REFLECT ALL INFORMATION AND ARE ALWAYS TRADED AT THEIR FAIR VALUE ON EXCHANGES, MAKING IR IMPOSSIBLE FOR INVESTORS TO PURCHASE UNDERVALUATED STOCKS OR SELL STOCKS FOR INFLATED PRICES. THEREFORE, IT SHOULD BE IMPOSSIBLE TO OUTPERFORM THE OVERALL MARKET AND THE ONLY WAY AN INVESTOR CAN OBTAIN HIGHER RETURNS IS BY PURCHASING RISKIER INVESTMENTS.

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

R: ZERO. THIS HYPOTHESIS IMPLIES THAT THERE IS NO STOCK OR PORTFOLIO THAT CONSISTENTLY OFFERS RETURNS OVER THE MARKET RETURN. IN OTHER WORDS, THE MARKET PORTFOLIO SHOULD BE THE MOST OPTIMAL OF ALL PORTFOLIOS OR INDIVIDUAL STOCKS. ALTHOUGH THIS IS WHAT THE MARKET EFFICIENT HYPOTHESIS IMPLIES, IT IS POSSIBLE TO FIND PORTFOLIOS THAT TEMPORARILY OFFERS SIGNIFICANT EXCESS RETURNS OVER THE MARKET, BUT IT IS VERY HARD TO FIND THEM.

(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)

TO RESPOND QUESTIONS ABOUT THE MARKET RISK OF THE STOCK, WE MUST ANALYZE BETA1 OF THE CAPM REGRESSION.

REMEMBER THAT BETA1 REPRESENTS THE SENSITIVITY OF THE STOCK PREMIUM RETURN WHEN THE MARKET PREMIUM RETURNS MOVE IN +1%. IF BETA1=1 THIS MEANS THAT THE STOCK ON AVERAGE IS EQUALLY SENSIBLE THAN THE MARKET. IN OTHER WORDS, THAT THE STOCK IS EQUALLY RISKY THAN THE MARKET.

IN THIS CASE WE SEE THAT BETA1 ON AVERAGE IS EQUAL TO 2.2237689, INDICATING THAT ON AVERAGE TESLA IS MUCH RISKIER THAN THE MARLET. HOWEVER, IF WE WANT TO KNOW WHETHER TESLA IS SIGNIFICANTLY RISKIER THAN THE MARKET, WE NEED TO LOOK AT ITS STANDARD ERROR OR DO A SPECIAL t-TEST.

THE EASIEST WAY TO KNOW WHETHER TESLA IS SIGNIFICANTLY RISKIER THAN THE MARKET (WHETHER BETA1>1) IS ESTIMATING AN APPROXIMATE 95% CONFIDENCE INTERVAL. WE DID THAT AS:

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.399573 to 3.047965

THEN WE SEE THAT WITH A 95% PROBABILITY, THE BETA1 OF TESLA WILL MOVE BETWEEN 1.3995729 TO 3.0479648. THIS MEANS THAT TESLA IS SIGNIFICANTLY RISKIER AT THE 95% CONFIDENCE LEVEL.

WE CAN ALSO RESPOND THE SAME QUESTION IF WE DO THE FOLLOWING HYPOTHESIS TEST. THE REGRESSION MODEL AUTOMATICALLY RUNS A T-TEST FOR B1 CONSIDERING THAT THE NULL HYPOTHESIS STATES THAT BETA1=0. IN THIS CASE, WE NEED TO CHANGE THE NULL HYPOTHESIS AS:

H0: B1= 1 HA: B1>1

THEN, WE FOLLOW THE METHOD OF HYPOTHESIS TEST TO CALCULATE THE t-VALUE OF THE TEST:

tvalue = \frac{(2.2237689 - 1)}{0.412098} = 2.9696066

THEN, SINCE I GOT A t-VALUE > 2, THEN I CAN REJECT THE NULL HYPOTHESIS AT THE 95% CONFIDENCE LEVEL AND SAY THAT TESLA IS SIGNIFICANTLY RISKIER THAN THE MARKET. IN OTHER WORDS, THAT ITS BETA1 IS SIGNIFICANTLY GREATER THAN 1.

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

7 READING

Read carefully: Basics of Linear Regression Models.

8 Quiz 3 and W3 submission

Go to Canvas and respond Quiz 3 about Basics of Return and Basics of Descriptive Statistics. You will be able to try this quiz up to 3 times. Questions in this Quiz are related to concepts of the readings related to this Workshop. 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%)