Estimation of MTD parameters through the Expectation Maximization (EM) algorithm.
MTDest(
X,
S,
M = 0.01,
init,
iter = FALSE,
nIter = 100,
A = NULL,
oscillations = FALSE
)An S3 object of class c("MTDest", "MTD") (a list) with at least the following elements:
lambdas: estimated mixture weights (independent part first, if any).
pj: list of estimated transition matrices \(p_j\).
p0: estimated independent distribution (if applicable).
logLik: log-likelihood of the final fitted model.
iterations, deltaLogLik, lastComputedDelta (optional):
returned if iter = TRUE. Here, iterations is the number of
parameter updates performed; deltaLogLik stores the successive
absolute log-likelihood changes for the accepted updates; and
lastComputedDelta is the last computed change (which may be below
M when the loop stops by convergence).
oscillations (optional): returned if oscillations = TRUE.
call: the matched call.
S: the lag set used for estimation.
A: the state space used for estimation.
n: the sample size.
n_eff: the effective sample size used for estimation.
A vector or single-column data frame containing an MTD chain sample
(X[1] is the most recent).
A numeric vector of distinct positive integers, sorted increasingly.
Typically, S represents a set of relevant lags.
A stopping point for the EM algorithm. If M=NULL the algorithm
will run for a total of nIter iterations (i.e., no convergence check).
A list with initial parameters: p0 (optional), lambdas
(required), pj (required). The entries in lambdas are weights
for the distribution p0 and the distributions present in the list
pj. Therefore, the order in which the elements appear in the vector
lambdas is important for correct assignment. See Details.
Logical. If TRUE include iteration diagnostics in the output
(number of updates iterations; vector of absolute log-likelihood changes
deltaLogLik; and lastComputedDelta, the last delta log-likelihood
compared against M).
An integer positive number with the maximum number of EM iterations.
Optional integer vector giving the state space. If omitted, defaults
to sort(unique(X)).
Logical. If TRUE, also compute oscillations for the
fitted model (see oscillation).
Objects returned by MTDest() have class c("MTDest","MTD") and support:
print and summary: methods for fitted objects
(see MTDest-methods).
coef: extracts fitted parameters lambdas, pj, and p0
(inherited from "MTD"; see MTD-methods).
logLik: returns the final log-likelihood stored in the fit
(see MTDest-methods).
plot: diagnostic plots for fitted objects (see plot.MTDest).
probs, oscillation, and perfectSample: additional utilities
available by inheritance from "MTD".
as.MTD: coerces an "MTDest" fit to an "MTD" model.
Stable access to fitted components is provided by MTD-accessors, including
S (or Lambda), lags, lambdas,
pj, p0, states, and transitP.
Regarding the M parameter: it functions as a stopping
criterion within the EM algorithm. When the difference between
the log-likelihood computed with the newly estimated parameters
and that computed with the previous parameters falls below M,
the algorithm halts. Nevertheless, if the value of nIter
(which represents the maximum number of iterations) is smaller
than the number of iterations required to meet the M criterion,
the algorithm will conclude its execution when nIter is reached.
To ensure that the M criterion is effectively utilized, we
recommend using a higher value for nIter, which is set to a
default of 100.
Concerning the init parameter, it is expected to be a list with 2 or
3 entries. These entries consist of:
an optional vector named p0, representing an independent
distribution (the probability in the first entry of p0 must be
that of the smallest element in A and so on), a required list
of matrices pj, containing a stochastic matrix for each
element of S (the first matrix corresponds to the smallest lag in
S and so on), and a vector named lambdas representing
the weights, the first entry must be the weight for p0, and then one entry
for each element in pj list. If your MTD model does not have an independent
distribution p0, set init$lambdas[1]=0.
Lebre, Sophie and Bourguignon, Pierre-Yves. (2008). An EM algorithm for estimation in the Mixture Transition Distribution model. Journal of Statistical Computation and Simulation, 78(1), 1-15. tools:::Rd_expr_doi("10.1080/00949650701266666")
MTDmodel for constructing an MTD model,
hdMTD for lag selection procedures,
MTDest-methods for methods specific to fitted objects,
MTD-methods for methods inherited from "MTD",
MTD-accessors for stable access to components,
and as.MTD for coercion of fits to model objects.
# Simulating data.
set.seed(1)
MTD <- MTDmodel(Lambda = c(1, 10), A = c(0, 1), lam0 = 0.01)
X <- perfectSample(MTD, N = 400)
# Initial Parameters:
init <- list(
'p0' = c(0.4, 0.6),
'lambdas' = c(0.05, 0.45, 0.5),
'pj' = list(
matrix(c(0.2, 0.8, 0.45, 0.55), byrow = TRUE, ncol = 2),
matrix(c(0.25, 0.75, 0.3, 0.7), byrow = TRUE, ncol = 2)
)
)
fit <- MTDest(X, S = c(1, 10), init = init, iter = TRUE)
str(fit, max.level = 1)
fit$logLik
class(fit)
fit2 <- MTDest(X, S = c(1, 10), init = init, oscillations = TRUE)
fit2$oscillations
Run the code above in your browser using DataLab