probs {hdMTD}R Documentation

Estimated transition probabilities

Description

Computes the Maximum Likelihood estimators (MLE) for an MTD Markov chain with relevant lag set S.

Usage

probs(X, S, matrixform = FALSE, A = NULL, warning = FALSE)

Arguments

X

A vector or single-column data frame containing a sample of a Markov chain (X[1] is the most recent).

S

A numeric vector of unique positive integers. Typically, S represents a set of relevant lags.

matrixform

Logical. If TRUE, the output is formatted as a stochastic transition matrix.

A

A numeric vector of distinct integers representing the state space. If not provided, this function will set A <- sort(unique(X)).

warning

Logical. If TRUE, the function warns the user when the state space is automatically set as A <- sort(unique(X)).

Details

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).

Value

A data frame or a matrix containing estimated transition probabilities:

Examples

X <- testChains[, 3]
probs(X, S = c(1, 30))
probs(X, S = c(1, 15, 30))


[Package hdMTD version 0.1.0 Index]