Kenneth French Gift to the Finance World

June 29, 2011

(This article was first published on Timely Portfolio, and kindly contributed to R-bloggers)

Kenneth French gives one of the best gifts to the finance world at his website  I am surprised I have waited so long to write a post about this wonderful resource.  After seeing Systematic Relative Strength’s post The #1 Investment Return Factor No One Wants to Talk About, I thought I would play with Size and Momentum in R, and it is very clear that size and momentum have been very important return factors.

From TimelyPortfolio
From TimelyPortfolio
From TimelyPortfolio

R code (click to download):

#get very helpful Ken French data
#for this project we will look at Momentum Portfolios
#   require(PerformanceAnalytics)
require(ggplot2)   my.url=""
download.file(my.url, my.tempfile, method="auto",
quiet = FALSE, mode = "wb",cacheOK = TRUE)
#read space delimited text file extracted from zip
french_momentum <- read.table(file=my.usefile,
header = TRUE, sep = "", = TRUE,
skip = 12, nrows=1013)
colnames(french_momentum) <- c(paste("Small",
paste("Large",colnames(french_momentum)[1:3],sep="."))     #get dates ready for xts index
datestoformat <- rownames(french_momentum)
datestoformat <- paste(substr(datestoformat,1,4),
substr(datestoformat,5,7),"01",sep="-")   #get xts for analysis
french_momentum_xts <- as.xts(french_momentum[,1:6],   french_momentum_xts <- french_momentum_xts/100   #jpeg(filename="performance by momentum and size.jpg",quality=100,width=6.25, height = 5, units="in",res=96)
main="Performance by Kenneth French Size and Momentum
Monthly Since 1927"
side=1,adj=0,cex=0.75)   #jpeg(filename="rolling performance by momentum and size.jpg",quality=100,width=6.25, height = 5, units="in",res=96)
main="Performance by Kenneth French Size and Momentum
36 Month Rolling Since 1927"
legend.loc = "bottomright",
side=1,adj=0,cex=0.75)   #use ggplot2 for boxplot
#could also use chart.Boxplot() from PerformanceAnalytics
df <-
dfmelt <- melt(df,id.vars=1)
colnames(dfmelt) <- c("date","frenchmomentum","return")
#jpeg(filename="boxplot by momentum and size.jpg",quality=100,width=6.25, height = 5, units="in",res=96)
ggplot(dfmelt,aes(x=frenchmomentum,y=return,colour=frenchmomentum)) +
geom_boxplot() + opts(title="Kenneth French Momentum and Size")

Created by Pretty R at

To leave a comment for the author, please follow the link and comment on their blog: Timely Portfolio. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)