Learn R Programming

rstpm2 (version 1.6.5)

markov_sde: Predictions for continuous time, nonhomogeneous Markov multi-state models using Aalen's additive hazards models.

Description

A numerically efficient algorithm to calculate predictions from a continuous time, nonhomogeneous Markov multi-state model. The main inputs are are a list of Aalen's additive hazards models, the initial values, the transition matrix and the covariate patterns. The predictions include state occupancy probabilities and length of stay. Standard errors are calculated using the delta method. Includes differences and standardisation.

Usage

markov_sde(models, trans, newdata, init = NULL, nLebesgue = 10000 + 1, los = FALSE,
           nOut = 300, weights = 1)
# S3 method for markov_sde
standardise(x, ...)
# S3 method for markov_sde
plot(x, y, stacked=TRUE, which=c("P","L"), index=NULL,
    xlab="Time", ylab=NULL, col=2:6, border=col,
    ggplot2=FALSE, lattice=FALSE, alpha=0.2,
    strata=NULL,
    ...)
# S3 method for markov_sde
as.data.frame(x, row.names=NULL, optional=NULL, ci=TRUE,
    P.conf.type="logit", L.conf.type="log",
    P.range=c(0,1), L.range=c(0,Inf),
    ...)

Value

markov_sde returns an object of class

"markov_sde".

Arguments

models

list of models. Currently allows only for aalen regression models.

trans

Transition matrix describing the states and transitions in the multi-state model. If S is the number of states in the multi-state model, trans should be an S x S matrix, with (i,j)-element a positive integer if a transition from i to j is possible in the multi-state model, NA otherwise. In particular, all diagonal elements should be NA. The integers indicating the possible transitions in the multi-state model should be sequentially numbered, 1,...,K, with K the number of transitions. See msprep

newdata

data.frame of the covariates to use in the predictions

init

vector of the initial values with the same length as the number of states. Defaults to the first state having an initial value of 1 (i.e. "[<-"(rep(0,nrow(trans)),1,1)).

nLebesgue

Number of steps for the continuous integration

los

logical variable for whether to estimate the length of stay

nOut

number of rows to represent the continuous changes

weights

numeric vector to represent differences or standardisation

For plot.markov_sde:

y

(currently ignored)

stacked

logical for whether to stack the plots. Default: TRUE

index

indicator of which row of newdata to plot

which

character to indicate either transition probabilities ("P") or length of stay ("L")). Default: "P".

xlab

x-axis label

ylab

x-axis label

col

colours (ignored if ggplot2=TRUE)

border

border colours for the polygon (ignored if ggplot=TRUE)

ggplot2

use ggplot2

alpha

alpha value for confidence bands (ggplot)

lattice

use lattice

strata

formula for the stratification factors for the plot

For as.data.frame.markov_sde:

row.names

add in row names to the output data-frame

optional

(not currently used)

ci

logical for whether to include confidence intervals. Default: TRUE

P.conf.type

type of transformation for the confidence interval calculation for the state occupancy probabilities. Default: logit transformation. This is changed to "identity" if any of the weights are negative

L.conf.type

type of transformation for the confidence interval calculation for the length of stay calculation. Default: log transformation. "identity" if any of the weights are negative

P.range

valid values for the state occupancy probabilities. Default: (0,1).

L.range

valid values for the state occupancy probabilities. Default: (0,Inf).

For standardise.markov_sde:

x

object to extract standardised values

...

other arguments. For plot.markov_sde, these arguments are passed to plot.default. For standardise.markov_sde, these arguments are not used, as the standardisation must be done earlier in markov_sde.

Author

Mark Clements

Details

Uses an approach developed by Ryalen and colleagues. This is a re-implementation in C++.

The current implementation only allows for a vector of initial values rather than a matrix. The predictions will need to be re-run for different vectors of initial values.

See Also

markov_msm