Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 580

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 583

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 586

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 589

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 592
2011 April 19 » The Calculating Investor

In this video post, I walk  through a basic demo showing how to run the Fama-French regression using R.

This is my first attempt at doing a screencast, so please let me know if you have any comments or suggestions.  

The demo is easiest to follow when viewed in full screen HD.  In lower resolutions, the on-screen commands may be difficult to read.

Additional Info:

The slides used in this screencast can be accessed here, and the CSV data file is available here.

The R code used in the demo is shown below:

# Fama-French Regression example in R

# Load CSV file into R
ff_data <- read.table("ffdata.csv",header=TRUE,sep=",")

# Extract Fama-French Factors and Fund Returns
rmrf <- ff_data[,2]/100
smb <- ff_data[,3]/100
hml <- ff_data[,4]/100
rf <- ff_data[,5]/100
fund <- ff_data[,6]/100

# Calculate Excess Returns for Target fund
fund.xcess <- fund - rf

# Run Fama-French Regression
ffregression <- lm(fund.xcess ~ rmrf + smb + hml)

# Print summary of regression results
print(summary(ffregression))