Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

buildModel

Build quantmod model given specified fitting method


Description

Construct and attach a fitted model of type method to quantmod object.

Usage

buildModel(x, method, training.per, ...)

Arguments

x

An object of class quantmod created with specifyModel or an R formula

training.per

character vector representing dates in ISO 8601 format “CCYY-MM-DD” or “CCYY-MM-DD HH:MM:SS” of length 2

method

A character string naming the fitting method. See details section for available methods, and how to create new methods.

...

Additional arguments to method call

Details

Currently available methods include:

lm, glm, loess, step, ppr, rpart[rpart], tree[tree], randomForest[randomForest], mars[mda], polymars[polspline], lars[lars], rq[quantreg], lqs[MASS], rlm[MASS], svm[e1071], and nnet[nnet].

The training.per should match the undelying date format of the time-series data used in modelling. Any other style may not return what you expect.

Additional methods wrappers can be created to allow for modelling using custom functions. The only requirements are for a wrapper function to be constructed taking parameters quantmod, training.data, and .... The function must return the fitted model object and have a predict method available. It is possible to add predict methods if non exist by adding an S3 method for predictModel. The buildModel.skeleton function can be used for new methods.

Value

An object of class quantmod with fitted model attached

Note

See buildModel.skeleton for information on adding additional methods

Author(s)

Jeffrey Ryan

See Also

Examples

## Not run: 
getSymbols('QQQQ',src='yahoo')
q.model = specifyModel(Next(OpCl(QQQQ)) ~ Lag(OpHi(QQQQ),0:3))
buildModel(q.model,method='lm',training.per=c('2006-08-01','2006-09-30'))

## End(Not run)

quantmod

Quantitative Financial Modelling Framework

v0.4.18
GPL-3
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Wouter Thielen [ctb], Paul Teetor [ctb], Steve Bronder [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.