Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in cph, when there is missing value and cluster #46

Closed
tamas-ferenci opened this issue Jul 27, 2017 · 2 comments
Closed

Problem in cph, when there is missing value and cluster #46

tamas-ferenci opened this issue Jul 27, 2017 · 2 comments

Comments

@tamas-ferenci
Copy link

Here is a minimal reproducible example:

set.seed(1)

RawData <- data.frame( time = runif( 100, 1, 5 ), event = sample( 0:1, 100, replace = TRUE ),
x1 = c( NA, rnorm( 99 ) ), x2 = as.factor( sample( 0:1, 100, replace = TRUE ) ),
ID = c( 1:70, 1:30 ) )

dd <- datadist( RawData )
options( datadist = "dd" )

cph( Surv( time, event ) ~ x1 + x2 + cluster( ID ), data = RawData )

It is not even an error, but a warning, but it nevertheless shouldn't be there. After some experimentation I think the problem is with the presence of a missing value and cluster().

The problem seems to occur at the very end of rms:::Design. I think the problem is that jz will index every right hand side term (including the cluster), but fname will only contain the explanatory variables (without the cluster). Thus
names(nmiss)[jz] <- fname[asm != 9]
will try to assign a length-2 vector to one of length 3.

@harrelfe
Copy link
Owner

harrelfe commented Sep 8, 2017

The rms package prefers for you to handling cluster after the fit using robcov or bootcov.

@tamas-ferenci
Copy link
Author

It works with
fit <- cph( Surv( time, event ) ~ x1 + x2, data = RawData )
fit <- robcov( fit, cluster = RawData$ID )

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants