ts_transmat: Transition matrix

ts_transmatR Documentation

Transition matrix

Description

Create a transition matrix from a discrete time series, e.g. to generate Monte Carlo simulations.

Usage

ts_transmat(yd, nbins = length(unique(yd)))

Arguments

yd

A discrete numeric vector or time series, e.g. transformed using ts_discrete(), or, ts_symbolic().

nbins

The number of bins used to transform a continuous time series, or, the number of expected (given nbins, or, theoretically possible) values for a discrete series (default = length(unique(yd)))

Value

A transition probability matrix

Examples


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


FredHasselman/casnet documentation built on April 20, 2024, 3:05 p.m.