probs | R Documentation |
Computes the Maximum Likelihood estimators (MLE) for an MTD Markov chain with
relevant lag set S
.
probs(X, S, matrixform = FALSE, A = NULL, warning = FALSE)
X |
A vector or single-column data frame containing a sample of a Markov chain ( |
S |
A numeric vector of unique positive integers. Typically, |
matrixform |
Logical. If |
A |
A numeric vector of distinct integers representing the state space.
If not provided, this function will set |
warning |
Logical. If |
The probabilities are estimated as:
\hat{p}(a | x_S) = \frac{N(x_S a)}{N(x_S)}
where N(x_S a)
is the number of times the sequence x_S
appeared in the sample
followed by a
, and N(x_S)
is the number of times x_S
appeared
(followed by any state). If N(x_S) = 0
, the probability is set to 1 / |A|
(assuming a uniform distribution over A
).
A data frame or a matrix containing estimated transition probabilities:
If matrixform = FALSE
, the function returns a data frame with three columns:
The past sequence x_S
(a concatenation of past states).
The current state a
.
The estimated probability \hat{p}(a | x_S)
.
If matrixform = TRUE
, the function returns a stochastic transition matrix,
where rows correspond to past sequences x_S
and columns correspond to states in A
.
X <- testChains[, 3]
probs(X, S = c(1, 30))
probs(X, S = c(1, 15, 30))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.