predict.tsfm: Predicts asset returns based on a fitted time series factor...

View source: R/predict.tsfm.r

predict.tsfmR Documentation

Predicts asset returns based on a fitted time series factor model

Description

S3 predict method for object of class tsfm. It calls the predict method for fitted objects of class lm, lmRob or lars as appropriate.

Usage

## S3 method for class 'tsfm'
predict(object, newdata = NULL, ...)

Arguments

object

an object of class tsfm produced by fitTsfm.

newdata

a vector, matrix, data.frame, xts, timeSeries or zoo object containing the variables with which to predict.

...

optional arguments passed to predict.lm or predict.lmrob, such as se.fit, or, to predict.lars such as mode.

Value

predict.tsfm produces a matrix of return predictions, if all assets have equal history. If not, a list of predicted return vectors of unequal length is produced.

Author(s)

Yi-An Chen and Sangeetha Srinivasan

See Also

fitTsfm, summary.tsfm

Examples

# load data from the database
data(managers, package = 'PerformanceAnalytics')

# fit the factor model with LS
fit <- fitTsfm(asset.names = colnames(managers[,(1:6)]),
               factor.names = c("EDHEC LS EQ","SP500 TR"), 
               data = managers)

predict_fit <- predict(fit)

newdata <- data.frame(rnorm(n=NROW(fit$data)), rnorm(n=NROW(fit$data)))
colnames(newdata) <- c("EDHEC LS EQ", "SP500 TR")
rownames(newdata) <- zoo::index(fit$data)

predict_fit_2 <- predict(fit, newdata, interval = "confidence")


braverock/factorAnalytics documentation built on Dec. 16, 2024, 1:05 p.m.