hongyuan cao
2007-May-04 09:15 UTC
[R] Error in if (!length(fname) || !any(fname == zname)) { :
Dear R users, I tried to fit a cox proportional hazard model to get estimation of stratified survival probability. my R code is as follows: cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] +colon[,20]+colon[,9], surv=TRUE) Error in if (!length(fname) || !any(fname == zname)) { : missing value where TRUE/FALSE needed Here colon[,13] is the one that I want to stratify and the others are all coefficients. How can I solve this problem? Thanks a lot!!!!! Grace --------------------------------- [[alternative HTML version deleted]]
Vladimir Eremeev
2007-May-04 10:01 UTC
[R] Error in if (!length(fname) || !any(fname == zname)) { :
For me, the simplest way to find, what is wrong, would be tracing the R code: library(debug) mtrace(cph) cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] +colon[,20]+colon[,9], surv=TRUE) ... then find the place of the error and analyze how to adjust the function call arguments to avoid the error and get the desired result. hongyuan cao wrote:> > I tried to fit a cox proportional hazard model to get estimation of > stratified survival probability. my R code is as follows: > > cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] > +colon[,20]+colon[,9], surv=TRUE) > Error in if (!length(fname) || !any(fname == zname)) { : > missing value where TRUE/FALSE needed > Here colon[,13] is the one that I want to stratify and the others are all > coefficients. How can I solve this problem? Thanks a lot!!!!! > > Grace >-- View this message in context: http://www.nabble.com/Error-in-if-%28%21length%28fname%29-%7C%7C-%21any%28fname-%3D%3D-zname%29%29-%7B-%3A-tf3691016.html#a10319988 Sent from the R help mailing list archive at Nabble.com.
Vladimir Eremeev
2007-May-04 10:11 UTC
[R] Error in if (!length(fname) || !any(fname == zname)) { :
Vladimir Eremeev wrote:> > For me, the simplest way to find, what is wrong, would be tracing the R > code: > > library(debug) > mtrace(cph) > cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] > +colon[,20]+colon[,9], surv=TRUE) > > ... then find the place of the error and analyze how to adjust the > function call arguments to avoid the error and get the desired result. >and then, switch off the tracing mtrace(cph,FALSE) or mtrace.off() -- View this message in context: http://www.nabble.com/Error-in-if-%28%21length%28fname%29-%7C%7C-%21any%28fname-%3D%3D-zname%29%29-%7B-%3A-tf3691016.html#a10320118 Sent from the R help mailing list archive at Nabble.com.
Frank E Harrell Jr
2007-May-04 14:08 UTC
[R] Error in if (!length(fname) || !any(fname == zname)) { :
hongyuan cao wrote:> Dear R users, > > I tried to fit a cox proportional hazard model to get estimation of stratified survival probability. my R code is as follows: > > cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] +colon[,20]+colon[,9], surv=TRUE) > Error in if (!length(fname) || !any(fname == zname)) { : > missing value where TRUE/FALSE needed > Here colon[,13] is the one that I want to stratify and the others are all coefficients. How can I solve this problem? Thanks a lot!!!!! > > GraceThe Design package does not like you to have complex variable names like that, and in general storing your data in a matrix when you want to treat columns as separate variables is not the best approach. I would use something like S <- with(d, Surv( ) ) # d = data frame h <- as.data.frame(colon) # assumes colon is a matrix;make sure it had column names cph(S ~ strat(v1)+v2+v3+v4, data=h) -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University