error message in cox regression cph()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

error message in cox regression cph()

May, Roel
Hi,
 
I have been trying to get the cph() function of the Design package to work but get an error message I don't understand:
 
Error in if (!length(fname) || !any(fname == zname)) { :
        missing value where TRUE/FALSE needed

I have tried the same for a dummy dataset I made, and than it seems to work fine. However, it doesn't do it for my own data. Does anyone have a clue as to what this message means, whether I have made a mistake somewhere(although it seems ok to me?) and especially how to solve this problem. I know I could have used coxph() instead, but I'd like to predict the outcome on another dataset and coxph() does not allow for interaction terms...
 
I hope anyone can help me here. Underneath is the code I used for my data, if it's of any use...
 
Thanks, cheers Roel
 
Roel May
NINA, Norway
modeldata <- as.data.frame(modeldata)

survchoice<-Surv(2-modeldata$USED,is.element(modeldata$USED,1))

d <- datadist(modeldata$ID,modeldata$ASP_NW,modeldata$ALT,modeldata$SLOPE,modeldata$PLACEMENT,modeldata$DTL,modeldata$TRACK,modeldata$PRIVATE,modeldata$BUSH,modeldata$ROCK,modeldata$GRASS,modeldata$WATER,modeldata$RUGGED,modeldata$CABIN,data=modeldata)

options(datadist="d")

options(contrasts=c("contr.treatment","contr.treatment"))

interactmodel <- cph(survchoice~(ASP_NW+RUGGED+SLOPE+GRASS:PLACEMENT+PRIVATE+BUSH:ROCK+RUGGED:ROCK+DTL)+strat(ID),data=modeldata,method="breslow",y=TRUE,x=TRUE,surv=TRUE)


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: error message in cox regression cph()

Frank Harrell
May, Roel wrote:

> Hi,
>  
> I have been trying to get the cph() function of the Design package to work but get an error message I don't understand:
>  
> Error in if (!length(fname) || !any(fname == zname)) { :
>         missing value where TRUE/FALSE needed
>
> I have tried the same for a dummy dataset I made, and than it seems to work fine. However, it doesn't do it for my own data. Does anyone have a clue as to what this message means, whether I have made a mistake somewhere(although it seems ok to me?) and especially how to solve this problem. I know I could have used coxph() instead, but I'd like to predict the outcome on another dataset and coxph() does not allow for interaction terms...
>  
> I hope anyone can help me here. Underneath is the code I used for my data, if it's of any use...
>  
> Thanks, cheers Roel
>  
> Roel May
> NINA, Norway
> modeldata <- as.data.frame(modeldata)
>
> survchoice<-Surv(2-modeldata$USED,is.element(modeldata$USED,1))


>
> d <- datadist(modeldata$ID,modeldata$ASP_NW,modeldata$ALT,modeldata$SLOPE,modeldata$PLACEMENT,modeldata$DTL,modeldata$TRACK,modeldata$PRIVATE,modeldata$BUSH,modeldata$ROCK,modeldata$GRASS,modeldata$WATER,modeldata$RUGGED,modeldata$CABIN,data=modeldata)
>

Don't use $ in input arguments to datadist.  Use the whole data frame or
use with( ).


> options(datadist="d")
>
> options(contrasts=c("contr.treatment","contr.treatment"))

Remove.  This is the default.

>
> interactmodel <- cph(survchoice~(ASP_NW+RUGGED+SLOPE+GRASS:PLACEMENT+PRIVATE+BUSH:ROCK+RUGGED:ROCK+DTL)+strat(ID),data=modeldata,method="breslow",y=TRUE,x=TRUE,surv=TRUE)

Use * for interactions and to make sure your model follows the hierarchy
principle.

Next time please also give the version of Design you are using.

Frank

>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>


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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Frank Harrell
Department of Biostatistics, Vanderbilt University