MGMT 675



AI-Assisted Financial Analysis

Alphas and Betas

Objectives for this Week

  1. Estimate the cost of equity capital for CVX
  2. Evaluate the performance of Fidelity Magellan relative to a Fama-French benchmark

Cost of equity capital

Capital Asset Pricing Model

Expected stock return is \(r_f + \beta \times \overline{r_m - r_f}\)

  1. Get today’s \(r_f\) from FRED
  2. Get historical \(\overline{r_m - r_f}\) from French’s data library
  3. Estimate beta by running regression \[r - r_f = \alpha + \beta (r_m-r_f) + \varepsilon\]

Let’s estimate the beta first.

Data for regression

The regression is: \[r - r_f = \alpha + \beta (r_m-r_f) + \varepsilon\]

  1. CVX return \(r\) from Yahoo adjusted closing prices
  2. Risk-free rate \(r_f\) from French’s data library
  3. Market excess return \(r_m-r_f\) from French’s data library

Compute CVX returns

  • Ask Julius to pip install yfinance==0.1.70 and import yfinance as yf
  • Then (all instructions at once to avoid repeated downloads) ask Julius to:
    • use yf.Ticker to get CVX closing prices (= adjusted closing prices) since 2010
    • downsample to end-of-month and compute returns as 100 times percent change
    • convert dates to pandas monthly period format

Get Fama-French factors

Ask Julius to use the pandas datareader get the monthly Fama-French factors since 2010 from French’s data library,

Prepare data for the regression

  • Ask Julius to do an inner merge on the dates of the CVX returns and Fama-French factors.
  • Ask Julius to keep only the last 120 rows.
  • Ask Julius to add the excess CVX return to the dataframe by subtracting RF from the CVX return.
  • Ask Julius to show the head and tail of the dataframe.

Run the regression

  • Ask Julius to regress the excess CVX return on MKT-RF, including an intercept, and show a summary of the results.
  • Ask Julius to assign the MKT-RF regression coefficient to a new variable called beta.

Estimate the market risk premium

  • Ask Julius to use pandas datareader to get the annual Fama-French factors from French’s data library starting in 1926.
  • Ask Julius to compute the mean of MKT-RF and assign it to a new variablecalled market_premium.

Get the current risk-free rate

  • Ask Julius to use pandas datareader to get 1-month Treasury bill yields from FRED.
  • Ask Julius to get the most recent 1-month Treasury bill yield and assign it to a new variable called rf.

CVX cost of equity capital

Ask Julius to compute rf + beta * market_premium.

Visualize the regression

  • Ask Julius to produce a scatter plot with the excess CVX return on the y axis and MKT-RF on the x axis.
    • Tip: we might need to give Julius the name of the dataframe containing the excess CVX return and MKT-RF.
    • Look back at the code where Julius showed the head and tail of the dataframe to find the name.
  • Ask Julius to include the regression line on the scatter plot.

Visualization tips

  • We can ask Julius to set the style of the plot. I like the seaborn whitegrid style.
  • There are other choices: seaborn plot styles
  • If Julius is balky at including the regression line, ask it to create a seaborn regplot with ci=None.
  • You can also specify the colors of the points and the line (the line could be a different color than the points).

Interactive plots

  • Suppose we’re giving a presentation in which we show the regression plot.
    • We anticipate there might be questions about some of the points - e.g., extreme values.
    • We could tag them with annotations, but it creates clutter.
    • It might be useful to be able to hover over points and have pop-ups with details.
  • This requires html.

Use plotly

  • Ask Julius to use the dataframe containing the CVX excess return and MKT-RF and to convert the dates to strings.
  • Ask Julius to use plotly to create a scatter plot with a regression line, the CVX excess return on the y-axis, and MKT-RF on the x-axis.
  • Ask Julius to include the date in the hover data.
  • Ask Julius to save the figure as html.

See the results

  • Download the html file.
  • Open it from Windows Explorer or the Mac Finder (it probably won’t work opening it from your web browser).
  • Try out different plotly templates - e.g., plotly_dark.
  • More visualization coming next week.

Mutual Fund Performance

Performance measures

  • Rankings
  • Performance relative to benchmark (large cap, …)
  • Performance after adjusting for risk exposures
    • relative to benchmark adjusting for benchmark beta
    • or including other risk exposures
    • alpha = average return after adjustments

Fama-French factors: motivation

  • Certain types of stocks have beaten others historically
  • Efficient markets view: must be due to risk exposures that investors care about
  • Not sure what risks are, but use difference in returns of different types of stocks as proxies

Fama-French 5 factors

  • MKT-RF = market return minus T-bill return
  • SMB = Small stock return Minus Big stock return
  • HML = High book-to-market (value) return Minus Low book-to-market return
  • CMA = Conservative (low asset growth) return Minus Aggressive return
  • RMW = Robust (high profitability) return Minus Weak return

Data

  • Start a new chat.
  • Repeat the steps in the Yahoo/Fama-French merge, except
    • Get FMAGX (Fidelity Magellan) from Yahoo for the maximum history possible
    • Get the monthly 5-factor Fama-French factors from French’s data library for the maximum history possible
    • Keep all months after doing an inner merge (not just last 120)

Run regression

  • The regression is \[r-\text{RF} = \alpha + \beta_1 \times \text{MKT-RF} + \beta_2 \times \text{SMB}\] \[+ \beta_3 \times \text{HML} + \beta_4 \times \text{CMA} + \beta_5 \times \text{RMW} + \varepsilon\]

  • Ask Julius to add the excess FMAGX return to the dataframe (FMAGX return minus RF).

  • Ask Julius to regress the excess FMAGX return on the Fama-French factors and report the summary.

Interpretation

  • A risk-adjusted benchmark for FMAGX is \[(1-\beta_1)\times \text{RF} + \beta_1 \times \text{MKT} + \beta_2 \times \text{SMB}\] \[+ \beta_3 \times \text{HML} + \beta_4 \times \text{CMA} + \beta_5 \times \text{RMW} + \varepsilon\]
  • Call this BMARK. The regression can be restated as \[ r - \text{BMARK} = \alpha + \varepsilon\]
  • \(\alpha + \varepsilon\) is over-performance when positive and under-performance when negative.

History of Over or Under-Performance

  • Ask Julius to add a variable called over_under to the dataset defined as (regression intercept + regression residuals) / 100.
  • Ask Julius to compute the cumulative product of (1 + over_under) and to plot it.

Attribution analysis

  • Attribution analysis is breaking down the benchmark.
  • How much return comes from market exposure? size exposure? value exposure? …
  • We can calculate the average return to the value exposure as \(\beta_3 \overline{\text{HML}}\), etc.
  • We can visualize these by plotting the cumulative product of \(1 + \beta_3 \times \text{HML}/100\), etc.
  • Ask Julius.