Closed huyendn closed 3 months ago
Check JMbayes2
—— Professor of Biostatistics Erasmus Medical Center Rotterdam The Netherlands
Από: huyendn @.> Στάλθηκε: Thursday, August 10, 2023 2:57:10 PM Προς: drizopoulos/JMbayes @.> Κοιν.: Subscribed @.***> Θέμα: [drizopoulos/JMbayes] issue with survfitJM (Issue #104)
Waarschuwing: Deze e-mail is afkomstig van buiten de organisatie. Klik niet op links en open geen bijlagen, tenzij u de afzender herkent en weet dat de inhoud veilig is. Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
I got this error when trying to fit the dynamic prediction Error in contrasts<-(tmp, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels I know this error occurs when the categorical only has 1 level. However, if we do prediction for one patient, a categorical could have only 1 level for that patient. In your example code (https://erandrinopoulou.github.io/EducationalCorner_JMpred/) , the data for the patient for prediction has some categorical with one level. Could you please help look into this?
— Reply to this email directly, view it on GitHubhttps://github.com/drizopoulos/JMbayes/issues/104, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADE7TTZPCIH7KSIKN6OYT4LXUUVINANCNFSM6AAAAAA3L5PS6Y. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thanks for the fast response. I just tried predict function in JMbayes2 with jm object and still got the same message error.
predSurv <- predict(jointm1.bayes, newdata = newdata_5, process = "event",
- return_newdata = TRUE) Error in
contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
Hello,
Do you know what might possibly cause this issue?
Thank you
Hi,
I encountered the same problem recently and solved by converting categorical variables to factors. You may also want to check if each of the factors is with 2 or more levels.
Hope this helps.
Make sure in "newdata_5" you are defining your factor variables to have two levels even if you're predicting with only one level. For example, if you have 2 time points and your categorical variable is gender, define it as:
newdata_5$gender <- factor(c('female','female'), levels = c('female','male'))
I got this error when trying to fit the dynamic prediction Error in
contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels I know this error occurs when the categorical only has 1 level. However, if we do prediction for one patient, a categorical could have only 1 level for that patient. In your example code (https://erandrinopoulou.github.io/EducationalCorner_JMpred/) , the data for the patient for prediction has some categorical with one level. Could you please help look into this?