[R] Warning in 'probtrans'-function ('mstate'-package)

Johannes Johow johannes.johow at gmx.de
Sat Sep 17 13:36:29 CEST 2011


Dear all,
in order to estimate transition-specific probabilities in a multi-state 
model i applied the 'probtrans()' function from the 'mstate'-package.
Now, i am at loss with the following message (see attached example):

Warning message:
In probtrans(msf.0, predt = 0) :
Negative diagonal elements of (I+dA); the estimate may not be meaningful.

I am not very familiar with matrix algebra nor did i find anything about 
this issue in accompanying docs of the package. However, I have the 
feeling that the impact of this warning differs between the two  
predictions provided in the example code.  Also, there must be a 
difference between a "warning" and an "error" so my main question is:

How does this "inconsistency"(?) arise and are there any criterias to 
decide whether the model's validity is seriously affected of it?

Best,
Johannes

###    EXAMPLE:
#
library(mstate)

# set up transistion matrix for illness-death model with competing risks 
(2 death causes)
tmat <- transMat(x=list(
c(2),
c(3,4),
c(),
c()), names=
c(NA, "ill", "cause1", "cause2"))

# create example data with 't' (time), 's' (status) & 'v' 
(variables/predictors)  in 'wide format'..
set.seed(123)
S1 <- data.frame(
t1 = rnorm(100, 10, 1),
t2 = rnorm(100, 20, 1),
s0 = 1,
s1 = sample(c(0,1),100, replace=TRUE),
v1 = rnorm(100, 10, 1),
v2 = rnorm(100, 10, 1),
v3 =  sample(c(0,1),100, replace=TRUE))
S1$s2 <- ifelse(S1$s1==1, 0, 1)
covs <- c("v1", "v2", "v3")

#   ...reshape to long format
SL <-  msprep(time = c(NA, "t1", "t2", "t2"),
  status = c(NA, "s0", "s1", "s2"),
   data= S1, trans=tmat, keep=covs)

#   add 'transition-specific' covariates
SLV <- expand.covs(SL, covs, append=TRUE, longnames=TRUE)
head(SLV)
names(SLV)

#   fit stratified Markov model
cox1 <- coxph(Surv(Tstart, Tstop, status) ~
(v1.1 + v2.1) * v3.1 +
(v1.2 + v2.2) * v3.2 +
(v1.3 + v2.3) * v3.3 +
strata(trans), SLV,
method = "breslow")
summary(cox1)

#   'cloned' data for making predictions: specific covariate 'v3' fixed 
at 0 (& 1):
SLV0 <-  SLV[1:3,]
SLV0$v3.1 <- 0
SLV0$v3.2 <- 0
SLV0$v3.3 <- 0
SLV0$strata <- 1:3

SLV1 <-  SLV0
SLV1$v3.1 <- 1
SLV1$v3.2 <- 1
SLV1$v3.3 <- 1

#  estimate...

    msf.0 <- msfit(cox1, SLV0, trans=tmat)
    pt.0 <- probtrans(msf.0, predt=0)

#  [..output:]
#   Warning message:
#   In probtrans(msf.0, predt = 0) :
#   Warning! Negative diagonal elements of (I+dA); the estimate may not 
be meaningful.

    msf.1 <- msfit(cox1, SLV1, trans=tmat)
    pt.1 <- probtrans(msf.1, predt=0)

#  [..output:]
#   There were 50 or more warnings (use warnings() to see the first 50)

    par(mfrow=c(1,2))
    plot(pt.0)
    plot(pt.1)

#  note black bars in right panel(?)



More information about the R-help mailing list