knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The package fHMM can model empirical and simulated data.
You have to options to provide fHMM with empirical data:
You can save your data in a csv-file in a folder named data under the path
path needs to correspond to
path specified in
You can download daily prices of your preferred stock from https://finance.yahoo.com/ via
download_data(name, symbol, from, to, path)
name is your personal identifier for the stock,
symbol is the stock's symbol that has to match the official symbol on https://finance.yahoo.com,
to define the time interval (in format
path is the path where the data gets saved and needs to correspond to
path specified in
For example, the call
download_data(name = "dax", symbol = "^GDAXI", from = "2000-01-01", to = Sys.Date(), path = ".")
downloads the 21st century daily data of the Deutscher Aktienindex into the folder data in the current working directory (because
path = ".").
Historical events can be highlighted in the visualization of the decoded, empirical time series by passing a named list
events with elements
dates (a vector of dates) and
names (a vector of names for the events) to
For example, passing
events = list( dates = c("2001-09-11","2008-09-15","2020-01-27"), names = c("9/11 terrorist attack","Bankruptcy of Lehman Brothers","First COVID-19 case in Germany") )
fit_hmm highlights three important historical events in the decoded time series.
If you do not have empirical data at hand or simply want to conduct a simulation experiment, fHMM can simulate data from a hidden Markov model for you. If you do not specify the
data parameter in the model's
controls, data gets simulated for you.
You can specify the model coefficients by passing the list
thetaList format (see the vignette model parameters) to
fit_hmm. Otherwise, the parameters are randomly drawn from -1 to 1. Setting
controls scales these values by
y on the coarse scale and on the fine scale, respectively.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.