Calculate Ekholm SelctionShare & TimingShare in R based on TimelyPortfolio post SelectionShare & TimingShare | Masterfully Written by Delightfully Responsive Author.
library(Quandl)
library(xts)
library(pipeR)
# get function from this gist
source(paste0(
"https://gist.githubusercontent.com/timelyportfolio/e5728c8c7fb45dbdb6e0",
"/raw/e124379f19225fcdee18f30cb848da6fc6cae764/ekholm.R"
))
f <- Quandl("KFRENCH/FACTORS_D",type = "xts") / 100
"FCNTX" %>>%
getSymbols( from = "1896-01-01", auto.assign = F ) %>>%
(
structure(
ROC( .[,6], n = 1, type = "discrete" )
,dimnames = list(
NULL
,gsub(x = colnames(.)[6], pattern = "[\\.]Adjusted", replacement = "")
)
)
) %>>%
merge(f) %>>% # Quandl("KFRENCH/FACTORS_D",type = "xts") / 100
na.omit %>>%
jensen_ekholm