hdMTD: High-Dimensional MTD Modeling in R
- hdMTD is an R package for fitting and simulating high-dimensional Mixture Transition Distribution models that capture long-range dependencies in categorical time series.
- It implements various lag-selection methods—including BIC-based, CUT, FS, and FSC approaches—to estimate sparse lag sets and reduce the exponential parameter growth of high-order Markov chains.
- The package also provides EM-based parameter estimation and exact stationary simulation, with empirical illustrations demonstrating improved performance over traditional models.
hdMTD is an R package for fitting and simulating high-dimensional Mixture Transition Distribution (MTD) models, a parsimonious class of high-order Markov chains designed to capture long-range dependencies in categorical time series. In an MTD, the transition probability is written as a convex mixture of lower-order conditional distributions that depend on single lags, which replaces the exponential parameter growth of a general order- Markov chain with a representation whose parameter count is linear in . The package implements non-parametric lag selection, maximum likelihood estimation of transition probabilities, expectation-maximization estimation of MTD parameters, and exact simulation from the stationary distribution, with illustrations on simulated data and daily temperature records from Brazil (Gripp et al., 1 Sep 2025).
1. Model class and conceptual foundations
Let be a categorical time series taking values in a finite state space . A general order- Markov chain specifies
and requires a transition probability for every combination of past states. The parameter count grows like , which is exponential in .
An MTD model of order replaces the full 0-dimensional transition with
1
where 2 satisfy
3
Here 4 is a distribution on 5 independent of the past, and each 6 is a distribution on 7 for lag 8 and past symbol 9. In sampling terms, one first draws a lag index 0 with probability 1; if 2, one samples from 3, and otherwise from 4.
This representation is parsimonious because it requires 5 lag-specific matrices and mixture weights rather than a full 6-lag joint transition law. In the multimatrix case, the parameter count is linear in 7, up to 8. The package is centered on the multimatrix MTD, in which each lag has its own matrix 9, but it also supports the single-matrix case, where all lags share the same matrix.
The high-dimensional regime considered by hdMTD is the regime in which the maximum lag 0 can be large, possibly of order 1, the sample size. This is motivated by settings in which dependence may occur simultaneously at short and long scales, such as daily, weekly, and yearly lags. Traditional nonparametric Markov estimation typically forces 2, because estimating high-dimensional joint distributions becomes infeasible when most length-3 pasts are unobserved or rarely observed. hdMTD adopts the sparse-lag perspective: the relevant lag set is assumed to be small even when the maximal order is large.
A central quantity is the oscillation at lag 4,
5
where 6 is total variation distance and 7 differ only at lag 8. For an MTD,
9
If 0 or all rows of 1 are identical, then 2, so lag 3 is irrelevant. The relevant lag set is therefore
4
Once 5 is known, the transition law depends only on 6, not on the full 7-lag past.
2. Mathematical formulation and likelihood structure
hdMTD assumes a stationary Markov chain of order 8 on a finite state space 9. Each lag kernel 0 can be represented by a 1 stochastic matrix,
2
Inference is built from empirical joint and conditional probabilities computed from a sample 3.
For 4 and 5, the joint counts are
6
with empirical joint probabilities
7
If 8, the empirical conditional probabilities are
9
For a lag set 0, hdMTD also uses
1
and
2
Given a subset 3, the nonparametric log-likelihood is
4
and the BIC objective used in the package is
5
where 6 is the number of free parameters under the chosen MTD structure and 7 is a user-specified constant.
This formulation is significant because it separates two statistical tasks. The first is structural recovery of 8, the set of relevant lags. The second is estimation of the MTD parameters once a lag set has been chosen. hdMTD provides dedicated procedures for both tasks, rather than treating the problem as a single global search over all high-order Markov transition tables.
3. Lag selection, transition estimation, and EM inference
The package implements four lag-selection procedures: a BIC-based algorithm, the CUT estimator, the FS estimator, and the FSC estimator (Gripp et al., 1 Sep 2025).
The BIC-based algorithm, available through hdMTD_BIC() or hdMTD(..., method="BIC"), selects a lag set 9 minimizing a penalized log-likelihood over subsets whose sizes are restricted by minl and maxl. It allows multimatrix versus single-matrix structure and models with or without an independent part. Its main advantage is classical likelihood-based model selection; its main limitation is the exponential growth of the search space, so tractability depends on restricting the candidate set S, the size range, or both.
The CUT estimator, implemented as hdMTD_CUT(), starts from a candidate set 0 and determines whether each lag 1 is relevant by comparing empirical conditional distributions over pairs of 2-compatible pasts. The rule is based on
3
with threshold
4
where
5
for tunings 6, 7, and 8 with 9. If any compatible pair exceeds the threshold, lag 0 is kept; otherwise it is cut. Its complexity is 1, and consistency is proved when 2 and 3, even if 4. In practice the defaults are alpha=0.05, mu=1, and xi=0.5.
The forward stepwise estimator hdMTD_FS() greedily builds a lag set of size 5. At step 6, it adds the lag maximizing
7
This quantity measures how strongly the distribution of 8 changes with 9, conditional on the currently selected lag set. The complexity is
0
The order of the output encodes importance: the first selected lag is the most predictive among the candidates considered at the initial step. The stated theory implies that if 1, the probability that 2 is high for large 3, so FS is naturally used to build a superset of the relevant lag set.
The FSC estimator hdMTD_FSC() combines FS and CUT with sample splitting. One half of the sample is used to run FS and produce a candidate set 4; the other half is used to run CUT on that set. This is intended to avoid double-using the same data and yields a fully data-driven estimator of 5 in sparse high-order settings.
Once a lag set has been selected, hdMTD provides two forms of estimation. The function probs() returns empirical conditional probabilities 6, which are the maximum likelihood estimates under the nonparametric Markov assumption. The function MTDest() fits an MTD model by EM. In the multimatrix case, the latent variable is the component index 7. The E-step computes expected counts for component usage and lag-specific transitions, and the M-step updates 8, 9, and 00 by normalized expected counts. Iteration stops when the increase in log-likelihood is less than M (default M=0.01) or the number of iterations reaches nIter (default 100). The output may include updated mixture weights, lag matrices, the independent distribution, the number of iterations, log-likelihood increments, and estimated oscillations when oscillations=TRUE.
4. Software structure and workflow in R
hdMTD exposes both model-construction functions and inference functions. The package adopts a specific lag-indexing convention: outputs are given as positive integers, but these represent negative time lags. Thus c(1,15,30) represents lags 01. The input sample X is ordered from latest to oldest so that lag indexing matches the internal convention.
| Function | Role |
|---|---|
MTDmodel() |
Create an MTD object from Lambda, A, lam0, lamj, p0, and pj |
hdMTD() |
Generic interface with method = "FS", "CUT", "BIC", or "FSC" |
hdMTD_FS(), hdMTD_CUT(), hdMTD_BIC(), hdMTD_FSC() |
Method-specific lag-selection procedures |
probs() |
Empirical conditional probabilities for a chosen lag set |
oscillation() |
True or empirical oscillations for lags |
MTDest() |
EM estimation of MTD parameters |
perfectSample() |
Exact simulation from the stationary distribution |
MTDmodel(Lambda, A, lam0, lamj, p0, pj, single_matrix, indep_part) creates an MTD object and returns the transition matrix over all combinations of states at the relevant lags, the component matrices pj, and the weights lambdas. If pj is not provided, hdMTD samples the matrices uniformly and normalizes them. The options single_matrix=TRUE and indep_part=FALSE correspond to the single-matrix variant and the model without independent part.
A typical workflow begins with data preparation, including categorical encoding and reversal of time order. Lag selection then depends on prior information. If there is no prior candidate set, the package documentation recommends hdMTD_FS(X, d, l) with a reasonably large d and modest l, optionally followed by hdMTD_FSC(X, d, l) to prune irrelevant lags. If there is a candidate set S, one may use hdMTD_BIC(X, d, S, minl, maxl, ...) or hdMTD_CUT(X, d, S, alpha, mu, xi). After selecting 02, empirical transition probabilities can be obtained with probs(X, S, matrixform=TRUE/FALSE). Full MTD parameters are then estimated through MTDest(), and a complete model object can be reconstructed with MTDmodel().
This organization makes a clear distinction between nonparametric transition estimation and structured MTD estimation. The former uses empirical conditional probabilities directly; the latter estimates the convex-mixture representation itself. That distinction is important in practice because a chosen lag set can support either a nonparametric Markov model on the reduced lag set or an MTD model on the same set.
5. Exact simulation and empirical illustrations
hdMTD includes an exact simulation procedure from the stationary distribution through perfectSample() (Gripp et al., 1 Sep 2025). Given an MTD object with 03, it uses a backward randomization algorithm inspired by Comets et al. (2002). For each time 04, one samples 05 with 06. To simulate 07, one samples a lag index 08. If 09, 10 is sampled from 11 and the recursion stops. Otherwise, if 12 has not yet been generated, the procedure is called recursively at time 13, after which 14 is sampled from 15. Because 16, the recursion terminates in finite time almost surely. The result is a sample exactly distributed according to the stationary distribution, without burn-in or convergence diagnostics.
A simulated binary example uses 17, relevant lags 18, and weights 19, 20, 21, and 22. With d=40 and l=4, hdMTD_FS(X, d = 40, l = 4) returns 30 15 1 27, recovering the three relevant lags and adding one extra lag because four lags were requested. In the same example, hdMTD_BIC(X, d = 40, minl = 4, maxl = 4) returns 1 15 17 30. The paper also reports empirical comparisons among FS, a “Naive” estimator, and an “Oracle” estimator for a model with true 23. As the sample size 24 increases, FS’s mean total variation error 25 approaches Oracle’s 26, FS recovers 27 exactly in almost all replicates for 28, and the Naive estimator using lags 29 has much higher error.
The main real-world illustration is based on hourly maximum temperatures from Brasília (INMET), 2010–2024, aggregated into daily mean of hourly maximum temperatures and discretized into two categories: Category 1, 30 °C, about 31; and Category 2, 32 °C, about 33. After reversing time order, hdMTD_FS(Temp12, d = 400, l = 3) returns 1 364 6. The interpretation given is lag 34 for yesterday’s regime, lag 35 for a weekly pattern, and lag 36 for an annual pattern. CUT applied to the FS output keeps all three lags, and BIC on that candidate set chooses the full set c(1, 6, 364) as best.
The resulting FS-based MTD is compared with an independent model and a classical second-order Markov chain selected by BIC among orders 1–6. In a prediction experiment on the last 366 days, averaged over 1000 simulations, the reported metrics are: accuracy approximately 37 for the independent model, 38 for the second-order Markov chain, and 39 for the FS-based MTD; sensitivity approximately 40, 41, and 42; precision approximately 43, 44, and 45; and F1 score approximately 46, 47, and 48. The stated interpretation is that the sparse high-order model captures long-range seasonality and weekly structure that are not represented by the selected second-order chain.
6. Assumptions, limitations, and related usages of the acronym
The package is built for stationary MTD chains on a finite state space. Continuous data must therefore be discretized. Its theoretical guarantees are tied to sparsity of the relevant lag set, with 49 small and, in the cited framework, growing at most like 50. This is the regime in which lag selection remains statistically and computationally manageable even when the maximum order 51 is large.
Several limitations follow directly from that setup. If the dependence structure cannot be well represented as a convex mixture of single-lag conditional distributions, hdMTD may misrepresent the dynamics; the package documentation explicitly notes interactions among multiple lags simultaneously as an example. Even though the MTD parametrization is parsimonious, empirical probabilities can still become sparse for very large state spaces or extremely high 52. BIC search can be computationally expensive when the candidate set is large and the admissible subset sizes are broad, which is why FS and FSC are recommended in high-dimensional settings.
Practical interpretation also requires care. Positive lag indices in outputs represent negative time lags; oscillation values 53 quantify the strength of each lag’s effect; and the order of lags in FS output reflects selection order and incremental importance, whereas CUT and FSC outputs do not encode such a ranking. This suggests that hdMTD is best viewed not simply as a high-order Markov package, but as a workflow for sparse lag discovery, reduced-set transition estimation, structured MTD fitting, and stationary simulation.
A potential source of confusion is nomenclature. In a distinct context, the term “hdMTD” has been used informally to denote “hybrid-state driven MT dynamics” or “hybrid-state driven MT disposition” in quantitative magnetization transfer imaging, although the acronym is not used explicitly in that paper (Assländer et al., 2022). That usage refers to hybrid-state spin physics and generalized Bloch modeling rather than to mixture transition distribution models. In the statistical context of the R package, hdMTD denotes high-dimensional Mixture Transition Distribution models and the software environment built for their inference and simulation.