drizopoulos / JM

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

plot.survfitJM in shiny app : comparison of these types is not implemented #2

Closed f-leborgne closed 7 years ago

f-leborgne commented 7 years ago

Dear Dimitris Rizopoulos,

I try to use your JM package in a shiny app to plot the predicted conditional probabilities of survival with the plot of my longitudinal marker. However, my shiny app display an error when executing the following line of code : plot.survfitJM(survPreds[[length(survPreds)]], estimator="median", conf.int=TRUE, include.y=TRUE) survPreds being survfitJM object. The displaying error is : comparison of these types is not implemented Note that without the option include.y=TRUE it work fine.

To investigate the error I saved the R environment in the shiny app just before the problematic call to plot function. Then I opened the obtained .Rdata in a standard R and I manually execute the previous plot function. In thiw way I obtained the desired graph without error !

Alltogather, I have no idea where this error came from... could you help me ? If necessary I could provide you the entire code of my shiny app.

Thanks a lot.

Kind regards, Florent

drizopoulos commented 7 years ago

Dear Florent,

It's a bit difficult to pinpoint where the problem occurs. Would it be possible to send a traceback()?

BTW, I have a working shiny app for dynamic predictions in JMbayes - you could have a look there.

Best, Dimitris

f-leborgne commented 7 years ago

Dear Dimitris,

Thanks for your quick answer.

The traceback given by the shiny app is the following : 101: Summary.difftime 100: plot.survfitJM 99: renderPlot [C:\Users\Florent\Dropbox\shiny\pred/server.R#119] 89: 78: plotObj 77: origRenderFunc 76: output$graph 1: runApp

Hope it help.

Kind regards, Florent

drizopoulos commented 7 years ago

Dear Florent,

According to the traceback the error seems to occur in the call to Summary.difftime(). However, unless I have missed something, nowhere in the code of plot.surfitJM() this function is called. Are you working with dates and calling summary() of difftime objects?

Best, Dimitris

f-leborgne commented 7 years ago

Dear Dimitris,

After further investigation I finally found that the error was at line 89 of the function plot.survfitJM.R : rng <- range(x$obs.times[[ii]], x$survTimes) My problem was the following, the vector x$obs.times[[ii]] was a "Time differences in days" obtained from the difference between different shiny dateInput while it is required a character or numeric object. I could simply solve the problem by adding the as.numeric() function to my difference of date when I create the initial data.frame from shiny Inputs.

Thanks a lot for your help. Best, Florent

drizopoulos commented 7 years ago

OK great that it is solved.

Best, Dimitris