ff5.Capm.estimation | R Documentation |
A function estimating the parameters of the Fama-French five factors model and the coefficients of the CAPM model. The Fama-French five factors are: the market factor, SMB (Small Minus Big), HML (High Minus Low), RMW (Robust Minus Weak) , CMA (Conservative Minus Aggresive)
ff5.Capm.estimation(ticker, from, to)
ticker |
A single character variable storing the ticker of the stock to be downloaded. Note that since data are downloaded from Yahoo finance, the ticker should be the same as the ones reported on Yahoo finance. See examples. This variable can also be a data.frame with either two columns (one with dates in format %Y%m%d and one with daily return of the portfolio), or one column with the daily returns of the portfolio and as rownames the dates. |
from |
A single character variable storing the starting date from which we want to download the data. The format should be "yyyy-mm-dd" |
to |
A single character variable storing the ending date up to the day in which we want to download the stock data. The format should be "yyyy-mm-dd" |
## Not run:
#with a single stock as ticker
ff5.Capm.estimation("AAPL", "2015-01-01", "2020-01-01")
#With a data frame of one single column of returns and dates as name of the rows as ticker
returns <- rnorm(n = 1827, mean = 0 , sd = 2.5)
dates <- seq(as.Date("2015-01-01"), as.Date("2020-01-01"), by = "days")
df <- data.frame(returns)
rownames(df) <- dates
ff5.Capm.estimation(df, "2015-01-01" , "2020-01-01")
#With a data frame of two columns as ticker, one of dates and one of returns
returns <- rnorm(n = 1827, mean = 0 , sd = 2.5)
dates <- seq(as.Date("2015-01-01"), as.Date("2020-01-01"), by = "days")
df <- data.frame(dates, returns)
ff5.Capm.estimation(df, "2015-01-01" , "2020-01-01")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.