countsTab {hdMTD} | R Documentation |
Counts sequences of length d+1 in a sample
Description
Creates a tibble containing all unique sequences of length d+1
found in
the sample, along with their absolute frequencies.
Usage
countsTab(X, d)
Arguments
X |
A numeric vector, a single-column data frame, or a list with a sample from a Markov chain. The first element must be the most recent observation. |
d |
A positive integer specifying the number of elements in each sequence,
which will be |
Details
The function generates a tibble with d+2
columns. In the first
d+1
columns, each row displays a unique sequence of size d+1
observed in the sample. The last column, called Nxa
, contains the
number of times each of these sequences appeared in the sample.
The number of rows in the output varies between 1
and |A|^{d+1}
,
where |A|
is the number of unique states in X
, since it depends
on the number of unique sequences that appear in the sample.
Value
A tibble with all observed sequences of length d+1
and their
absolute frequencies.
Examples
countsTab(c(1,2,2,1,2,1,1,2,1,2), 3)
# Using test data.
countsTab(testChains[, 1], 2)