Description Usage Arguments Details Value Note Author(s) Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | specifyModel a re-implmentation of the
R Package quantmodel specifyModel.
specifyModel, creates a single reusable model specification
for subsequent buildModel calls. An object of class quantmod
is created that can be then be reused with
different modeling methods and parameters.
No data frame is specified, as data is retrieved from potentially
multiple environments, and internal calls to getSymbolsEnv.
(1) The new parameter source.envir exists and is
passed to the (also) re-implmented R CRAN pacakge
quantmod function getModelData.
getSymbolsEnv searches first in (source.envir) to acquire Symbols.
If the Symbol is not found in the enviroment (source.envir),
then get the Symbol from elsewhere.
(2) The new parameter ... Dots is passed to passed to
the function getModelData (that are eventually passed
to getSymbolsEnv).
The situation may be useful that the caller setup source lookups
of specific Symbols using src (and yahoo case "from" and "to")
using the R CRAN package quantmod function setSymbolLookup.
|
1 | specifyModel(formula, na.rm = TRUE, source.envir = NULL, ...)
|
formula |
R formula. Default is none. Required. An object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specifcation are given under Details. |
na.rm |
Logical. Default is TRUE. Remove all incomplete rows. If na.rm is TRUE, then "na.exclude" is Done. "Without rules" this puts back (rbind) the last observation. |
source.envir |
Environment. Default is NULL. |
... |
Dots passed to getModelData. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Models are specified through the standard formula mechanism.
As financial models may include a variety of financial and economic
indicators, each differing in source, frequency, and/or class,
a single mechanism to specify sources is included within a call
to specifyModel. See getModelData for details of how this
process works.
Currently, objects of class quantmod.OHLC, zoo and ts
are supported within the model formula.
All symbols are first (attempted to be ) retrieved from the
the source.envir followed by the global environment,
without inheritence. If an object is not found in the
global environment, it is added to a list of objects to load
through the getSymbolsEnv function. getSymbolsEnv retrieves each
object specified by using information as to its location
specified apriori via setDefaults or setSymbolLookup.
Internally all data is coerced to zoo, data.frame, or
numeric classes.
|
Returns an object of class quantmod. Use modelData to extract full data set as zoo object.
1 2 3 4 5 6 7 8 9 10 | It is possible to include any supported series in the formula by
simply specifying the object's symbol. See *Details* for a list
of currently supported classes.
Use getSymbols.skeleton to create additional methods of
data sourcing, e.g. from a proprietary data format or
currently unimplemented source (Bloomberg, Oracle).
See getSymbols.MySQL and getSymbols.yahoo for examples
of adding additional functionality.
|
Andre Mikulec (the re-impemtation)
Jeffrey Ryan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
# list of Symbols
Symbols <- unlist(lapply( c("MSFT","AAPL","WMT","COST"),
function(x) {
l <- list()
l[[x]] <- getSymbolsEnv(x, auto.assign = FALSE)
}), recursive = FALSE)
# environment of Symbols
Symbols <- list2env(Symbols)
# see the Symbols
ls.str(Symbols)
# acquire the Symbols and return them (to this frame)
# getSymbolsEnv(c("AAPL","ORCL"), source.envir = Symbols)
# delete (not used)
# rm("AAPL","ORCL")
# This example uses R CRAN package econModel functions
# LD(lead) and LG(lag).
# Symbols are acquired from the environment Symbols.
# This call tries to acquire Symbols
# from the "source.envir" Symbols.
quantmod <- specifyModel(LD(quantmod::ClCl(WMT)) ~
LG(quantmod::OpCl(AAPL)) + LG(quantmod::LoHi(COST),0:2),
source.envir = Symbols,
from = "2007-01-01" # passed to the function getSymbolsEnv
to = "2011-12-31" # passed to the function getSymbolsEnv
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.