Package: fHMM 1.4.3

fHMM: Fitting Hidden Markov Models to Financial Data

Fitting (hierarchical) hidden Markov models to financial data via maximum likelihood estimation. See Oelschläger, L. and Adam, T. "Detecting Bearish and Bullish Markets in Financial Time Series Using Hierarchical Hidden Markov Models" (2021, Statistical Modelling) <doi:10.1177/1471082X211034048> for a reference on the method. A user guide is provided by the accompanying software paper "fHMM: Hidden Markov Models for Financial Time Series in R", Oelschläger, L., Adam, T., and Michels, R. (2024, Journal of Statistical Software) <doi:10.18637/jss.v109.i09>.

Authors:Lennart Oelschläger [aut, cre], Timo Adam [aut], Rouven Michels [aut]

fHMM_1.4.3.tar.gz
fHMM_1.4.3.zip(r-4.7)fHMM_1.4.3.zip(r-4.6)fHMM_1.4.3.zip(r-4.5)
fHMM_1.4.3.tgz(r-4.6-x86_64)fHMM_1.4.3.tgz(r-4.6-arm64)fHMM_1.4.3.tgz(r-4.5-x86_64)fHMM_1.4.3.tgz(r-4.5-arm64)
fHMM_1.4.3.tar.gz(r-4.7-arm64)fHMM_1.4.3.tar.gz(r-4.7-x86_64)fHMM_1.4.3.tar.gz(r-4.6-arm64)fHMM_1.4.3.tar.gz(r-4.6-x86_64)
fHMM_1.4.3.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
fHMM/json (API)

# Install 'fHMM' in R:
install.packages('fHMM', repos = c('https://loelschlaeger.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/loelschlaeger/fhmm/issues

Pkgdown/docs site:https://loelschlaeger.de

Uses libs:
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • dax - Deutscher Aktienindex (DAX) index data
  • dax_model_2n - DAX 2-state HMM with normal distributions
  • dax_model_3t - DAX 3-state HMM with t-distributions
  • dax_vw_model - DAX/VW hierarchical HMM with t-distributions
  • sim_model_2gamma - Simulated 2-state HMM with gamma distributions
  • spx - Standard & Poor’s 500 (S&P 500) index data
  • unemp - Unemployment rate data USA
  • unemp_spx_model_3_2 - Unemployment rate and S&P 500 hierarchical HMM
  • vw - Volkswagen AG (VW) stock data

On CRAN:

Conda:

financehidden-markov-modelscppopenmp

6.28 score 20 stars 12 scripts 558 downloads 20 exports 129 dependencies

Last updated from:d5ca69a8bd. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK208
linux-devel-x86_64OK214
source / vignettesOK267
linux-release-arm64OK189
linux-release-x86_64OK206
macos-release-arm64OK135
macos-release-x86_64OK418
macos-oldrel-arm64OK133
macos-oldrel-x86_64OK355
windows-develOK213
windows-releaseOK209
windows-oldrelOK171
wasm-releaseOK176

Exports:compare_modelscompute_residualsdecode_statesdownload_datafHMM_eventsfHMM_parametersfit_modelll_hmmnparpar2parConpar2parUnconparCon2parparCon2parUnconparUncon2parparUncon2parConprepare_datareorder_statesset_controlssimulate_hmmviterbi

Dependencies:askpassbackportsbase64encBBbbmlebdsmatrixbenchmarkmebenchmarkmeDatabootbriobslibcachemcallrcheckmateclicodetoolscpp11crayoncubaturecurldescdiffobjdigestdoParalleldplyrevaluatefarverfastmapfontawesomefontBitstreamVerafontLiberationfontquiverforeachfsfuturefuture.applygdtoolsgenericsGenOrdggfunggimageggiraphggplot2ggplotifyglobalsglueGPArotationgridGraphicsgtablehexbinhexStickerhighrhmshtmltoolshtmlwidgetshttrisobanditeratorsjquerylibjsonliteknitrlabelinglatticelifecyclelistenvlubridatemagickmagrittrMASSMatrixmemoisemimemnormtmvtnormnleqslvnlmenumDerivoeliopensslpadrparallellypillarpkgbuildpkgconfigpkgloadpracmapraiseprettyunitsprocessxprogressprogressrpspsychpurrrquadprogR6rappdirsRColorBrewerRcppRcppArmadillorlangrmarkdownrprojrootS7sassscalesshowtextshowtextdbSimMultiCorrDatastringistringrsyssysfontssystemfontstestthattibbletidyselecttimechangetinytextriangleutf8vctrsVGAMviridisLitewaldowithrxfunyamlyulab.utils

Controls
The set_controls function | Example specifications | HMMs for empirical data | Simulated HMM data | Hierarchical HMMs | References

Last update: 2026-05-05
Started: 2022-01-22

Data management
Empirical data | Download stock data | Highlighting events | Simulated data

Last update: 2026-05-05
Started: 2022-01-13

Model checking
Model checking using pseudo-residuals | Implementation | References

Last update: 2026-05-05
Started: 2022-01-13

Model definition
The Hidden Markov Model | Adding a Hierarchical Structure | References

Last update: 2026-05-05
Started: 2022-01-22

Model estimation
Likelihood evaluation using the forward algorithm | Challenges associated with the likelihood maximization | Application | References

Last update: 2026-05-05
Started: 2022-01-22

Model selection
Information criteria | Challenges associated with model selection | The compare_models() function | References

Last update: 2026-05-05
Started: 2022-01-13

State decoding and prediction
State decoding using the Viterbi algorithm | The decode_states() function | Invariance Toward State Labeling | Prediction | References

Last update: 2026-05-05
Started: 2022-03-02

Introduction
Motivation | Package and vignettes overview | Placement in the literature | References

Last update: 2024-05-31
Started: 2022-01-22

Readme and manuals

Help Manual

Help pageTopics
Compare multiple modelscompare_models
Compute (pseudo-) residualscompute_residuals
Deutscher Aktienindex (DAX) index datadax
DAX 2-state HMM with normal distributionsdax_model_2n
DAX 3-state HMM with t-distributionsdax_model_3t
DAX/VW hierarchical HMM with t-distributionsdax_vw_model
Decode the underlying hidden state sequencedecode_states viterbi
Download financial data from Yahoo Financedownload_data
Constructor of an 'fHMM_data' objectfHMM_data print.fHMM_data summary.fHMM_data
Checking eventsfHMM_events print.fHMM_events
Constructor of a model objectAIC.fHMM_model BIC.fHMM_model coef.fHMM_model fHMM_model logLik.fHMM_model nobs.fHMM_model npar npar.fHMM_model predict.fHMM_model print.fHMM_model residuals.fHMM_model summary.fHMM_model
Set and check model parametersfHMM_parameters print.fHMM_parameters
Model fittingfit_model
Log-likelihood function of an (H)HMMll_hmm
Plot method for an object of class 'fHMM_data'plot.fHMM_data
Plot method for an object of class 'fHMM_model'plot.fHMM_model
Prepare dataprepare_data
Reorder estimated statesreorder_states
Define and validate model specificationsprint.fHMM_controls set_controls summary.fHMM_controls validate_controls
Simulated 2-state HMM with gamma distributionssim_model_2gamma
Simulate datasimulate_hmm
Standard & Poor’s 500 (S&P 500) index dataspx
Unemployment rate data USAunemp
Unemployment rate and S&P 500 hierarchical HMMunemp_spx_model_3_2
Volkswagen AG (VW) stock datavw