ts_transmat | R Documentation |
Create a transition matrix from a discrete time series, e.g. to generate Monte Carlo simulations.
ts_transmat(yd, nbins = length(unique(yd)))
yd |
A discrete numeric vector or time series, e.g. transformed using |
nbins |
The number of bins used to transform a continuous time series, or, the number of expected (given |
A transition probability matrix
set.seed(4321)
# Random uniform numbers
y <- runif(10,0,20)
# Discrete version
yd <- ts_discrete(y, nbins = 10)
# Transition probabilities
ts_transmat(yd = yd, nbins = 10)
# Note: The number of 'observed' bins differs from 'expected' bins
table(yd)
# Not specifying the expected bins will generate a different matrix!
ts_transmat(yd = yd, nbins = length(unique(yd)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.