drizopoulos / JM

Joint Models for Longitudinal & Survival Data under Maximum Likelihood
34 stars 7 forks source link

survfitJM error: Error in rowMeans(rr, na.rm = TRUE) : 'x' must be numeric #24

Closed BenGoudsmit closed 3 years ago

BenGoudsmit commented 3 years ago

Dear prof. Rizopoulos,

I want to calculate survival probabilities in a 100-patient sample. All JM functions work lovely, except surfitJM, which throws the abovementioned error. What does it imply?

survfitJM <- JM:::survfitJM.jointModel
sprobs <- survfitJM(JM,testdata,idVar="id",survTimes=c(28/365.25,90/365.25))

Error in rowMeans(rr, na.rm = TRUE) : 'x' must be numeric

drizopoulos commented 3 years ago

I cannot reproduce that.

—— Dimitris Rizopoulos Professor of Biostatistics Erasmus University Medical Center The Netherlands


From: Ben notifications@github.com Sent: Wednesday, November 4, 2020 4:30:03 PM To: drizopoulos/JM JM@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [drizopoulos/JM] survfitJM error: Error in rowMeans(rr, na.rm = TRUE) : 'x' must be numeric (#24)

Dear prof. Rizopoulos,

I want to calculate survival probabilities in a 100-patient sample. All JM functions work lovely, except surfitJM, which throws the abovementioned error. What does it imply?

survfitJM <- JM:::survfitJM.jointModel sprobs <- survfitJM(JM,testdata,idVar="id",survTimes=c(28/365.25,90/365.25))

Error in rowMeans(rr, na.rm = TRUE) : 'x' must be numeric

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdrizopoulos%2FJM%2Fissues%2F24&data=04%7C01%7Cd.rizopoulos%40erasmusmc.nl%7Cf4177e6696334ea8f5d808d880d68121%7C526638ba6af34b0fa532a1a511f4ac80%7C0%7C1%7C637401006060974233%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2Fykvuwk3Ilfmku9jpor7uFvloJdh1C6pn%2BHsGu7ZaXo%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADE7TT4YUWLG4YHJPZLK22LSOFXPXANCNFSM4TKGCOBA&data=04%7C01%7Cd.rizopoulos%40erasmusmc.nl%7Cf4177e6696334ea8f5d808d880d68121%7C526638ba6af34b0fa532a1a511f4ac80%7C0%7C1%7C637401006060984228%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=JZulgQyk2WJzMQct%2BXqe3%2BnrmUYe1bCux1dnxk42eKY%3D&reserved=0.

BenGoudsmit commented 3 years ago

I understand, to elaborate: if I do not specify survTimes, then sprobs are generated. However, when specifying certain survTimes it throws the error, which seems strange.

BenGoudsmit commented 3 years ago

I discovered that the last.time in the survfitJM function gives an error if the prediction sample is n>1999. So this works:

subsurvtest <- survtest[sample(nrow(survtest), **1999** ), ]
sublongtest <- longtest[longtest$id %in% subsurvtest$id, ]
sub_sprobs <- survfitJM(JM_spline_valslope,sublongtest,idVar="id",
                    last.time=sublongtest$labyrs[sublongtest$counter==1],
                    survTimes=c(2/365.25,7/365.25,28/365.25,90/365.25))
But this does not:
subsurvtest <- survtest[sample(nrow(survtest), **2000** ), ]
sublongtest <- longtest[longtest$id %in% subsurvtest$id, ]
sub_sprobs <- survfitJM(JM_spline_valslope,sublongtest,idVar="id",
                    last.time=sublongtest$labyrs[sublongtest$counter==1],
                    survTimes=c(2/365.25,7/365.25,28/365.25,90/365.25))

With:

Error in survfitJM: not appropriate value for 'last.time' argument.

Not specifying last.time does work, but again is not what I want.