get_marginals
returns the marginal state, response, transition, and emission
probabilities, optionally per grouping defined by condition
. By default,
the marginalization weights sequences by the corresponding posterior
probabilities of the latent states, i.e., conditional probabilities of the
latent states given all data (weighting = "posterior"
). If
weighting = "forward"
, marginalization is based on forward probabilities,
i.e. state probabilities given data up to that point which allows you to
compute, for example, state marginals of form
\(P(state_t | data_1, \ldots, data_t)\) (whereas in posterior probability
weighting the conditioning is on \(data_1,\ldots,data_T\).
If weighting = "none"
, all individuals and time points are treated equally,
without accounting for the probability that individual is at particular
state at particular time.
get_marginals(
model,
probs = NULL,
condition = NULL,
newdata = NULL,
type = c("state", "response", "transition", "emission"),
weighting = c("posterior", "forward", "none")
)
An object of class nhmm
or mnhmm
.
Vector defining the quantiles of interest. Default is
NULL
, in which case no quantiles are computed. The quantiles are based on
bootstrap samples of coefficients, stored in object$boot
.
An optional vector of variable names used for conditional
marginal probabilities. Default is NULL
, in which case marginalization is
done over all variables, so that for example marginal emission probabilities
are computed over all individuals and time points.
An optional data frame containing the new data to be used in computing the probabilities.
A character vector defining the marginal probabilities of
interest. Can be one or multiple of "state"
, "response"
, "transition"
,
and "emission"
. Default is to compute all of these.
A character string defining the type of weighting used in
marginalization. One of "posterior"
, "forward"
, "none"
. See details.