Description Usage Arguments Details Value Author(s) References Examples
Fit time series factor model by time series regression techniques for single or multiple assets. Classic OLS, Robust regression can be chosen and several model selection methods can be applied. Class "TimeSeriesFactorModel" will be created too.
1 2 3 4 5 6 7 8 | fitTimeSeriesFactorModel(assets.names, factors.names,
data = data, num.factor.subset = 1,
fit.method = c("OLS", "DLS", "Robust"),
variable.selection = "none", decay.factor = 0.95,
nvmax = 8, force.in = NULL,
subsets.method = c("exhaustive", "backward", "forward", "seqrep"),
lars.criteria = "Cp", add.up.market.returns = FALSE,
add.quadratic.term = FALSE, excess.market.returns.name)
|
assets.names |
names of assets returns. |
factors.names |
names of factors returns. |
num.factor.subset |
scalar. Number of factors selected by all subsets. |
data |
a vector, matrix, data.frame, xts, timeSeries
or zoo object with |
fit.method |
"OLS" is ordinary least squares method, "DLS" is discounted least squares method. Discounted least squares (DLS) estimation is weighted least squares estimation with exponentially declining weights that sum to unity. "Robust" |
variable.selection |
"none" will not activate variables sellection. Default is "none". "stepwise" is traditional forward/backward #' stepwise OLS regression, starting from the initial set of factors, that adds factors only if the regression fit as measured by the Bayesian Information Criteria (BIC) or Akaike Information Criteria (AIC) can be done using the R function step() from the stats package. If "Robust" is chosen, the function step.lmRob in Robust package will be used. "all subsets" is Traditional all subsets regression can be done using the R function regsubsets() from the package leaps. "lar" , "lasso" is based on package "lars", linear angle regression. If "lar" or "lasso" is chose. fit.method will be ignored. |
decay.factor |
for DLS. Default is 0.95. |
nvmax |
control option for all subsets. maximum size of subsets to examine |
force.in |
control option for all subsets. The factors that should be in all models. |
subsets.method |
control option for all subsets. se exhaustive search, forward selection, backward selection or sequential replacement to search. |
lars.criteria |
either choose minimum "cp": unbiased estimator of the true rist or "cv" 10 folds cross-validation. Default is "Cp". See detail. |
add.up.market.returns |
Logical. If |
add.quadratic.term |
Logical. If |
excess.market.returns.name |
colnames market returns minus risk free rate. (Rm-Rf). |
add.up.market.returns
adds a max(0,Rm-Rf) term in
the regression as suggested by Merton-Henriksson Model
(1981) to measure market timing. The coefficient can be
interpreted as number of free put options.
If Robust
is chosen, there is no subsets but all
factors will be used. Cp is defined in
http://www-stat.stanford.edu/~hastie/Papers/LARS/LeastAngle_2002.pdf.
p17.
an S3 object containing
asset.fit Fit objects for each asset. This is the class "lm" for each object.
alpha N x 1 Vector of estimated alphas.
beta N x K Matrix of estimated betas.
r2 N x 1 Vector of R-square values.
resid.variance N x 1 Vector of residual variances.
call function call.
data original data as input
factors.names factors.names as input
variable.selection variable.selection as input
assets.names asset.names as input
Eric Zivot and Yi-An Chen.
Efron, Hastie, Johnstone and Tibshirani (2002) "Least Angle Regression" (with discussion) Annals of Statistics; see also http://www-stat.stanford.edu/~hastie/Papers/LARS/LeastAngle_2002.pdf.
Hastie, Tibshirani and Friedman (2008) Elements of Statistical Learning 2nd edition, Springer, NY.
Christopherson, Carino and Ferson (2009). Portfolio Performance Measurement and Benchmarking, McGraw Hill.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
# load data from the database
data(managers.df)
fit <- fitTimeSeriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
factors.names=c("EDHEC.LS.EQ","SP500.TR"),
data=managers.df,fit.method="OLS")
# summary of HAM1
summary(fit$asset.fit$HAM1)
# plot actual vs. fitted over time for HAM1
# use chart.TimeSeries() function from PerformanceAnalytics package
dataToPlot = cbind(fitted(fit$asset.fit$HAM1), na.omit(managers.df$HAM1))
colnames(dataToPlot) = c("Fitted","Actual")
chart.TimeSeries(dataToPlot, main="FM fit for HAM1",
colorset=c("black","blue"), legend.loc="bottomleft")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.