Learn R Programming

icmstate (version 0.2.0)

evalstep: Sample from a markov chain multi state model with exactly observed transition times

Description

Given a markov chain multi state model with exactly observed transition times, sample from this chain at the observation times, giving interval censored observations (panel data).

Usage

evalstep(time, stepf, newtime, subst = -Inf, to.data.frame = FALSE)

Value

A numeric vector or data.frame (if to.data.frame = TRUE) containing either the observed states or the named columns newtime and res, representing the observation times and observed states.

Arguments

time

Times at which a transition occurs

stepf

States at which the chain is in at times

newtime

Observation times of the chain, to create observed states

subst

State to return if observation time is before first transition time. Default = -Inf.

to.data.frame

Should the result be returned as a data.frame?

Author

Hein Putter

Examples

Run this code
obs_states <- evalstep(time = seq(0, 20, 2), stepf = sample(1:9, 11, replace = TRUE),
                newtime = c(-1, 1, 7, 9, 19))
obs_states

Run the code above in your browser using DataLab