Fit time series whose level, dynamics or volatility change with a latent regime. Choose which parameters can switch, infer regime probabilities, and forecast with bootstrap prediction intervals.
Compare three synthetic AR(1) series with two regimes. Each example was fitted with MSARM 1.0.1 in R. The browser displays the stored results.
Series and inferred regimes
Smoothed probabilities use the full observed series.
Fitted parameters
Regime
Intercept
AR(1)
Variance
Transition probabilities
To / from
Regime 1
Regime 2
Regime numbers are arbitrary and can refer to different fitted states across examples.
From series to forecast
Estimate with EM
Specify the AR order, regime count and switching mask. EM alternates between estimating latent regime probabilities and updating the model parameters. Multiple random starts and a variance floor help with sensitivity to initialisation and near-degenerate variances.
Infer states
Filtering conditions on observations through the current time. Smoothing uses the entire sample. The fitted object returns smoothed probabilities and fitted values for the most probable smoothed regime.
Forecast uncertainty
Propagate regime probabilities and lag moments for point forecasts. The residual bootstrap simulates future regime transitions and resamples centred, standardised residuals along each path. Quantiles give pointwise prediction intervals.
Use MSARM in R
R · Simulate, fit, forecast
library(MSARM)
set.seed(12)
y <- arima.sim(list(ar = 0.5), n = 150)
fit <- MSARM.fit(y, K = 1, N = 2,
Switcher = c(TRUE, FALSE, TRUE))
pred <- MSARM.predict(fit, n.ahead = 8,
boot = TRUE, L = 1000)
MSARM.plot(pred, conf = TRUE)
MSARM.fit()
Estimate transitions, regime coefficients and smoothed probabilities. Choose a start by log-likelihood, RSS, RCM or normalised entropy.
MSARM.predict()
Return point forecasts and future regime probabilities. Enable boot for the bootstrap mean and prediction quantiles.
MSARM.plot()
Plot the observed series and forecasts. Enable conf to display the bootstrap bands when available.
Lower-level functions
Inference and likelihood.eta_function evaluates conditional densities. zeta_Yt_function calculates filtered and one-step predicted probabilities, zeta_YT_function smooths them, and Log_Likelihood_function evaluates the conditional log-likelihood.
Initialisation and transitions.alpha_0_function, P_0_function and zeta_1_0_function initialise coefficients, transitions and regime weights. P_ij_next_function updates the transition matrix.
Worked EM routines. The three case-specific EM routines expose the estimation steps behind different switching masks. The associated helpers update regression coefficients and, in Example 5, regime variances.