R: Get matrix of observed transition frequencies

transitions {MCMCprecision} | R Documentation

## Get matrix of observed transition frequencies

### Description

Summarizes a sequence of discrete values by the observed transition frequencies.

### Usage

    transitions(z, labels, order = 1)

### Arguments

`z` | vector of model indices (numerical or character)
`labels` | fixed labels for models that should be included in transition matrix, e.g., `labels=1:20` or `c("m1","m2",...)`
`order` | order of the transition table. If `order=1`, a matrix with transition frequencies from `z[t+1]` is returned. If `order=2`, a 3-dimensional array is returned with transition frequencies for `z[t]`, `z[t+1]`, and `z[t+2]`.

### Value

a square matrix with transition frequencies

### Examples

    P <- matrix(c(.9,.1,0,
                  .1,.6,.3,
                  .2,.3,.5), 3, byrow=TRUE)
    z <- rmarkov(2000, P)
    transitions(z)
    transitions(z, order = 2)

[Package MCMCprecision version 0.3.9 Index]