Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trprob_trcov

Function to extract transition probabilities and (co)variance


Description

The trprob method is used to extract transition probabilities, while trcov is used to obtain the (co)variance.

Usage

## S3 method for class 'etm'
trprob(x, tr.choice, timepoints, ...)
## S3 method for class 'etm'
trcov(x, tr.choice, timepoints, ...)

Arguments

x

An object of class etm.

tr.choice

A character vector of the form "from to" describing for which transition one wishes to obtain the transition probabilities or covariance estimates. For trprob, tr.choice must be of length 1, while it can be of length 2 for trcov.

timepoints

Time points at which one want the estimates. When missing, estimates are obtained for all event times.

...

Further arguments.

Value

A vector containing the transition probabilities or covariance estimates either at the time specified in timepoints or at all transition times.

Author(s)

Arthur Allignol, arthur.allignol@gmail.com

See Also

Examples

data(sir.cont)

# Modification for patients entering and leaving a state
# at the same date
# Change on ventilation status is considered
# to happen before end of hospital stay
sir.cont <- sir.cont[order(sir.cont$id, sir.cont$time), ]
for (i in 2:nrow(sir.cont)) {
  if (sir.cont$id[i]==sir.cont$id[i-1]) {
    if (sir.cont$time[i]==sir.cont$time[i-1]) {
      sir.cont$time[i-1] <- sir.cont$time[i-1] - 0.5
    }
  }
}

### Computation of the transition probabilities
# Possible transitions.
tra <- matrix(ncol=3,nrow=3,FALSE)
tra[1, 2:3] <- TRUE
tra[2, c(1, 3)] <- TRUE

# etm
fit.etm <- etm(sir.cont, c("0", "1", "2"), tra, "cens", 0)

## extract P_01(0, t) and variance
p01 <- trprob(fit.etm, "0 1")
var.p01 <- trcov(fit.etm, "0 1")

## covariance between P_00 and P_01
cov.00.01 <- trcov(fit.etm, c("0 0", "0 1"))

## P_01 at some time points
trprob(fit.etm, "0 1", c(0, 15, 50, 100))

etm

Empirical Transition Matrix

v1.1.1
MIT + file LICENSE
Authors
Mark Clements [aut, cre], Arthur Allignol [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.