Dieter Menne wrote:

Dieter Menne wrote:
I do not know if this a problem with me, my data or cph/survest in package
design. The example below works with a standard data set, but not with my
data, but I cannot locate the problem.


Dieter Menne found out after hours, that in one case and explicit cast is
required, but none in the other, and has no idea why.

#---------------------------------------
library(Design)
data(ovarian)
dd = datadist(ovarian)
options(datadist="dd")
ovarian$rx = as.factor(ovarian$rx)
cp = cph(Surv(futime,fustat)~rx,data=ovarian,surv=TRUE,x=TRUE,y=TRUE)
summary(cp)
survplot(cp,rx=NA)
# works ok, without casting to a data frame
survest(cp,newdata=levels(ovarian$rx),what="survival",times=500)

It's just an accident that it ever worked without making it a data frame.

Frank


# Small data set, 223 rows, 3650 bytes
cc = read.table("http://www.menne-biomed.de/uni/cc.csv",header=TRUE)
#cc = read.table("cc.csv",header=TRUE)
dd = datadist(cc)
cp = cph(Surv(DaysToEvent,event)~ITTGroup,data=cc,surv=TRUE,x=TRUE,y=TRUE)
survplot(cp,ITTGroup=NA)
summary(cp)

survest(cp,newdata=levels(cc$ITTGroup),times=200)
#Error in survfit.cph(list(coefficients = c(0.435291247251185,
-0.143015493753166 :
#  NA/NaN/Inf in foreign function call (arg 13)
#In addition: Warning message:
#NAs introduced by coercion

# Works when explicitly converted to a data frame
survest(cp,newdata=data.frame(ITTGroup=levels(cc$ITTGroup)),times=200)



--
Frank E Harrell Jr   Professor and Chair           School of Medicine
                     Department of Biostatistics   Vanderbilt University

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to