How can someone make the Kenneth French library data returns quarterly from monthly? Since they are not loq returns, then you need to compound returns rather than summing them up. I want to make the returns of the SML, HML, the industry portfolio and the risk free that he uses, as quarterly returns. Does anybody know how you can deal with such a problem in R?
-
$\begingroup$ Wll I can not understand how can i convert monthly to quarterly data. I only know that the best way to deal with this problem is to convert annual data to quarterly data. Specifically, if $x$ is the yearly return of a stock, then I can use the formula: $$r_{\text{quarter}}=\left(1+\frac{x}{100}\right)^{3/12}-1$$ $\endgroup$– Hunger LearnMay 7, 2020 at 11:41
1 Answer
You add 1 to every monthly return of a given quarter, take the product of those returns, and then subtract 1.
In R (without any package): Suppose r
are the monthly returns, and dt
are the timestamps.
r <- rep(0.01, 12)
dt <- seq(from = as.Date("2020-1-1"),
to = as.Date("2020-12-1"),
by = "1 month")
tapply(r,
paste(as.POSIXlt(dt)$year + 1900, quarters(dt)),
FUN = function(x) prod(x + 1) - 1)
## 2020 Q1 2020 Q2 2020 Q3 2020 Q4
## 0.0303 0.0303 0.0303 0.0303
If you prefer the convenience of packages:
library("NMOF") ## for function 'French'
library("PMwR") ## for function 'returns'
P <- French(dest.dir = tempdir(),
dataset = "F-F_Research_Data_Factors_CSV.zip",
weighting = "value", frequency = "monthly",
price.series = TRUE)
head(P)
## Mkt-RF SMB HML RF
## 1926-06-30 1.000000 1.0000000 1.000000 1.000000
## 1926-07-31 1.029600 0.9770000 0.971300 1.002200
## 1926-08-31 1.056781 0.9633220 1.011997 1.004706
## 1926-09-30 1.060586 0.9506061 1.012099 1.007016
## 1926-10-31 1.026223 0.9509864 1.017260 1.010239
## 1926-11-30 1.052186 0.9490844 1.013700 1.013371
returns(P, t = as.Date(row.names(P)), period = "quarterly")
## Mkt-RF SMB HML RF
## 1926-09-30 0.0605859 -0.04939385 0.0120987 0.00701632
## 1926-12-31 0.0180728 -0.00200016 0.0013818 0.00912759
## 1927-03-31 0.0425284 -0.02248889 0.0526542 0.00812182
## 1927-06-30 0.0344638 0.02324739 0.0394452 0.00812182
## 1927-09-30 0.1457918 -0.07356559 -0.0548306 0.00792060
## 1927-12-31 0.0411792 0.05924812 -0.0563754 0.00681538
(disclosure: I am the maintainer of packages NMOF
and PMwR
.)