set_controls {fHMM} | R Documentation |
Define and validate model specifications
Description
This function defines and validates specifications for model estimation.
Usage
set_controls(
controls = list(),
hierarchy = FALSE,
states = if (!hierarchy) 2 else c(2, 2),
sdds = if (!hierarchy) "normal" else c("normal", "normal"),
horizon = if (!hierarchy) 100 else c(100, 30),
period = if (hierarchy && is.na(horizon[2])) "m" else NA,
data = NA,
file = NA,
date_column = if (!hierarchy) "Date" else c("Date", "Date"),
data_column = if (!hierarchy) "Close" else c("Close", "Close"),
from = NA,
to = NA,
logreturns = if (!hierarchy) FALSE else c(FALSE, FALSE),
merge = function(x) mean(x),
fit = list(),
runs = 10,
origin = FALSE,
accept = 1:3,
gradtol = 0.01,
iterlim = 100,
print.level = 0,
steptol = 0.01
)
validate_controls(controls)
## S3 method for class 'fHMM_controls'
print(x, ...)
## S3 method for class 'fHMM_controls'
summary(object, ...)
Arguments
controls |
Either a The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values. Important: Specifications in |
hierarchy |
A If By default, |
states |
An If By default, |
sdds |
A
The distribution parameters, i.e. the
can be fixed via, e.g., If By default, |
horizon |
A If By default, If |
period |
Only relevant if In this case, a
By default, |
data |
Either The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values, see below. Specifications in |
file |
A If Alternatively, it can be a |
date_column |
A If By default, |
data_column |
A If By default, |
from |
A |
to |
A |
logreturns |
A If By default, |
merge |
Only relevant if In this case, a
|
fit |
A The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values, see below. Specifications in |
runs |
An By default, |
origin |
Only relevant for simulated data, i.e., if the In this case, a By default, |
accept |
An By default, |
gradtol |
A positive By default, |
iterlim |
A positive By default, |
print.level |
One of By default, |
steptol |
A positive By default, |
x , object |
An object of class |
... |
Currently not used. |
Details
See the vignette on controls for more details.
Value
An object of class fHMM_controls
, which is a list
that contains
model and estimation specifications.
Examples
# 2-state HMM with t-distributions for simulated data
set_controls(
states = 2, # the number of states
sdds = "t", # the state-dependent distribution
runs = 50 # the number of optimization runs
)
# 3-state HMM with normal distributions for the DAX closing prices
set_controls(
states = 3,
sdds = "normal",
file = download_data("^GDAXI"), # the data set
date_column = "Date", # the column with the dates
data_column = "Close" # the column with the data
)
# hierarchical HMM with Gamma and Poisson state distributions
set_controls(
hierarchy = TRUE, # defines a hierarchy
states = c(3, 2), # coarse scale and fine scale states
sdds = c("gamma", "poisson"), # distributions for both layers
horizon = c(100, NA), # 100 simulated coarse-scale data points
period = "m" # monthly simulated fine-scale data
)
# hierarchical HMM with data from .csv-file
set_controls(
hierarchy = TRUE,
states = c(3, 2),
sdds = c("t", "t"),
file = c(
system.file("extdata", "dax.csv", package = "fHMM"),
system.file("extdata", "dax.csv", package = "fHMM")
),
date_column = c("Date", "Date"),
data_column = c("Close", "Close"),
logreturns = c(TRUE, TRUE)
)