In the following I will describe how to use the
ffdownload-package to automatically download, process and save datasets from Kenneth French’s famous website.
We first install the
ffdownload-package from my github repository using
The next tasks depends on which datasets are actually required. In the following I will give some examples on how to appropriately use the
Downloading one ore more specific datasets
In this case, we download the Fama and French (1992), Fama and French (1993) 3-Factor-Dataset, process it (automatically) and plot the resulting factors. To do this, we use the optional argument
listinput specifying ‘F-F_Research_Data_Factors’ and consequently only downloading and processing this specific dataset.
require(FFdownload) tempf <- tempfile(fileext = ".RData") inputlist <- c("F-F_Research_Data_Factors") FFdownload(output_file = tempf, inputlist=inputlist) load(tempf) fig <- exp(cumsum(FFdownload$`x_F-F_Research_Data_Factors`$monthly$Temp2["1960-01-01/",c("Mkt.RF","SMB","HML")]/100)) plotFF <- plot(fig[,"Mkt.RF"],main="FF 3 Factors",major.ticks = "years",format.labels="%Y",col="black",lwd=2,lty=1,cex=0.8) plotFF <- lines(fig[,"SMB"],on=NA,main="Size",col="darkgreen",lwd=2,lty=1,ylim=c(0,5),cex=0.8) plotFF <- lines(fig[,"HML"],on=NA,main="Value",col="darkred",lwd=2,lty=1,ylim=c(0,15),cex=0.8) plotFF
We could also add momentum (Carhart 1997) and the additional two factors of the Fama and French (2014) 5-factor model by additionally specifying ‘F-F_Momentum_Factor’, ‘F-F_ST_Reversal_Factor’ and ‘F-F_LT_Reversal_Factor’.
Be aware, that downloading all monthly files takes some time in processing by the file converter. If you additionally include the daily files, processing time can sum to >1 hour.
If you want a Snapshot of all the files saved on your harddrive (before they change again) I recommend specifying a permanent
tempdir where the downloaded files will not be deleted on restart. Also, if you have already downloaded a Snapshot of the data without processing (
download_only=TRUE), you can post-process without re-downloading by setting
If you just want a list of all available files on the webpage to select the ones you really need to download, I suggest setting
listsave to a specific location and keep
download=FALSE as well as
Carhart, Mark M. 1997. “On Persistence in Mutual Fund Performance.” The Journal of Finance 52 (1): 57–82. doi:10.2307/2329556.
Fama, Eugene F., and Kenneth R. French. 1992. “The Cross-Section of Expected Stock Returns.” The Journal of Finance 47 (2): 427–65. doi:10.1111/j.1540-6261.1992.tb04398.x.
———. 1993. “Common Risk Factors in the Returns on Stocks and Bonds.” Journal of Financial Economics 33 (1): 3–56. doi:10.1016/0304-405X(93)90023-5.
———. 2014. “A Five-Factor Asset Pricing Model.” Journal of Financial Economics. doi:10.1016/j.jfineco.2014.10.010.