Skip to contents

Data preparation

Use these functions to prepare or simulate financial data.

set_controls() print(<fHMM_controls>)
Set and validate controls
download_data()
Download financial data from Yahoo Finance
prepare_data()
Prepare data
fHMM_parameters() print(<fHMM_parameters>)
Set and check model parameters
fHMM_data() print(<fHMM_data>) summary(<fHMM_data>)
Constructor of an fHMM_data object
plot(<fHMM_data>)
Plot method for an object of class fHMM_data

Model estimation

Use these function for model estimation and state decoding.

fit_model() print(<fHMM_model>)
Model fitting
fHMM_model()
Constructor of a model object
decode_states()
Decode the underlying hidden state sequence
reorder_states()
Reorder estimated states

Model evaluation

Use these functions to evaluate a fitted model.

coef(<fHMM_model>)
Model coefficients
npar()
Number of model parameters
compare_models()
Compare multiple models
compute_residuals()
Compute (pseudo-) residuals
plot(<fHMM_model>)
Plot method for an object of class fHMM_model
fHMM_colors()
Set color scheme for visualizations
fHMM_events() print(<fHMM_events>)
Checking events
predict(<fHMM_model>)
Prediction
residuals(<fHMM_model>)
Residuals

Data

The following data sets are included in the package.

dax
Deutscher Aktienindex (DAX) index data
spx
Standard & Poor’s 500 (S&P 500) index data
unemp
Unemployment rate data USA
vw
Volkswagen AG (VW) stock data

Models

The following pre-computed models are included in the package.

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
sim_model_4lnorm
Simulated 4-state HMM with log-normal distributions
unemp_spx_model_3_2
Unemployment rate and S&P 500 hierarchical HMM

Small utilities

These functions may be useful beyond {fHMM}.

check_date()
Check date format
find_closest_year()
Find the closest year to a given date
is_number()
Check for integers
is_tpm()
Check for transition probability matrix
match_all()
Best-possible match of two numeric vectors
sample_tpm()
Sample transition probability matrices
simulate_markov_chain()
Simulate Markov chain