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

Issue with predictions when stratifying in Cox Model #105

Closed
ellenerickson opened this issue Sep 6, 2023 · 3 comments
Closed

Issue with predictions when stratifying in Cox Model #105

ellenerickson opened this issue Sep 6, 2023 · 3 comments

Comments

@ellenerickson
Copy link

Hello! I have come across an issue that I haven't been able to find a solution for. I am trying to stratify by gender in my survival model, and I have no issues getting my jointModelBayes function to work with this. However, when I try to use survfitJM to make predictions, I get the following error:
image

I know this isn't an issue with how I am creating my factor variables and naming them because when I run the exact same code but just put gender as a normal predictor, the survfitJM function runs fine. Not sure if something is happening to the factor levels of the stratified variable once it has gone through jointModelBayes or if the prediction function isn't able to handle stratified variables?

Here is some example code:

lmeFit <- lme(diameter ~ time+type, random = ~1|id, data = lme.mod2)

coxFit <- coxph(Surv(tte, ae) ~ type + age10 + strata(gender), data = cox.mod2, x = TRUE)
coxFit2 <- coxph(Surv(tte, ae) ~ type + age10 + gender, data = cox.mod2, x = TRUE)

jointFit2 <- jointModelBayes(lmeFit, coxFit, timeVar = "time")
summary(jointFit4)

jointFit4 <- jointModelBayes(lmeFit, coxFit2, timeVar = "time")
summary(jointFit2)

id <- c(1,1)
diameter <- c(40,50)
age10 <- c(5,5)
type <- factor(c("A", "A"), levels = c("A", "B"))
time <- c(0,15)
gender <- factor(c('female','female'), levels = c('female','male'))

patientdata <- data.frame(id, diameter, age10, type, time, gender)

survfitJM(jointFit2, newdata = patientdata, idVar = 'id')
#this returns an error

survfitJM(jointFit4, newdata = patientdata, idVar = 'id')
#this works just fine

@joepiekos
Copy link

I'm not sure and I use the updated package JMbayes2, but when I've had this error it's because I'm not predicting on enough new patients. I think it's because you only have females in your newdata. Maybe try do some more patients and have a mix of male and female?

@ellencravero
Copy link

@joepiekos I have tried predicting with the entire dataset (which has both males and females) and I get the same error, so I don't think it's that.

@drizopoulos
Copy link
Owner

Try JMbayes2.

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

4 participants