toNthOrder: Return the n-step transition chain

View source: R/chainTransforms.R

toNthOrderR Documentation

Return the n-step transition chain

Description

Returns the markovchain object whose transition matrix is P^{\code{order}}: from any state, its one-step transition probabilities are the original chain's order-step transition probabilities.

Usage

toNthOrder(object, order)

Arguments

object

A markovchain object.

order

A single integer of at least 2.

Details

This is a thin, discoverability-only wrapper around object ^ order (see ^,markovchain,numeric-method), provided under this name because PyDTMC's equivalent method is called to_nth_order(). It exists so that the operation is easy to find by that name; it introduces no new computation; the underlying ^ method is already O(n^3\log(\code{order})) via repeated squaring (expm::%^%), not a naive order-fold product, so there is nothing to improve on algorithmically here.

Value

A new markovchain object on the same states as object, with transition matrix P^{\code{order}}.

See Also

toBoundedChain, lazyChain

Examples

mc <- new("markovchain", states = c("a", "b"),
          transitionMatrix = matrix(c(0.9, 0.1, 0.3, 0.7), byrow = TRUE, nrow = 2))
identical(unclass(toNthOrder(mc, 5)@transitionMatrix), unclass((mc ^ 5)@transitionMatrix))


markovchain documentation built on Oct. 10, 2026, 9:07 a.m.