Learn R Programming

msSurv (version 1.2-2)

Pst: Computation of P(s,t)

Description

This function calculates the transition probability matrix between any two values s and t and then prints it. The function also calculates and prints the cov(P(s,t)) matrix if the user specifies. Values are returned invisibly.

Usage

Pst(object, s=0, t="last", deci=4, covar=FALSE)

Arguments

object
An msSurv object.
s
The lower time. Default is 0.
t
The highter time. Default is "last" which is the highest (or "last") event time.
deci
Numeric argument specifying number of decimal places for estimates. Default is 4.
covar
Logical argument to determine if var(P(s,t)) is computed. Default is FALSE.

Value

Returned invisibly:
Pst
The transition probability matrix between two times s and t.
cov.Pst
Covariance matrix for the transition probability matrix between two times s and t (if covar==TRUE).

Details

Computation of P(s,t) and var(P(s,t)) for multistate models are described in Andersen et al. (1993).

References

Nicole Ferguson, Somnath Datta, Guy Brock (2012). msSurv: An R Package for Nonparametric Estimation of Multistate Models. Journal of Statistical Software, 50(14), 1-24. URL http://www.jstatsoft.org/v50/i14/. Andersen, P.K., Borgan, O., Gill, R.D. and Keiding, N. (1993). Statistical models based on counting processes. Springer Series in Statistics. New York, NY: Springer.

See Also

msSurv

Examples

Run this code

## Row elements of data 
p1 <- c(1,0,0.21,1,3)
p2 <- c(2,0,0.799,1,2)
p22 <- c(2,0.799,1.577,2,3)
p3 <- c(3,0,0.199,1,0)

## Combining data into a matrix
ex1 <- rbind(p1,p2,p22,p3)
colnames(ex1) <- c("id", "start", "stop", "start.stage", "end.stage")
ex1 <- data.frame(id=ex1[,1], start=ex1[,2], stop=ex1[,3],
                  start.stage=ex1[,4], end.stage=ex1[,5])


## Inputting nodes & edges of the tree structure
Nodes <- c("1","2","3") # states in MSM
Edges <- list("1"=list(edges=c("2","3")),"2"=list(edges=c("3")),
           "3"=list(edges=NULL)) ## allowed transitions between states
                                 ## edges=NULL implies terminal node

## Specifying tree
treeobj <- new("graphNEL", nodes=Nodes, edgeL=Edges,
                edgemode="directed")

## Running msSurv
ans1 <- msSurv(ex1,treeobj)
Pst(ans1, s=0.25, t=2.5)

Run the code above in your browser using DataLab