rstanarm icon indicating copy to clipboard operation
rstanarm copied to clipboard

Should stan_jm throw an error when the survival submodel has zero events?

Open tessaclarkson opened this issue 3 years ago • 3 comments

Summary:

Getting this error attempting to run stam_jm "error occurred during calling the sampler; sampling not done Error in check_stanfit(stanfit) : Invalid stanfit object produced please report bug"

Description:

Model attempting to run: mod1 <- stan_jm(formulaLong = dsmcc_sumanxiety ~ ses + race + time + (time | id), dataLong = longd, formulaEvent = survival::Surv(max.pt, attrit) ~ ses + race, dataEvent = eventd, time_var = "time", chains = 1, refresh = 2000, seed = 12345)

Getting this Error: Chain 1: Rejecting initial value: Chain 1: Error evaluating the log probability at the initial value. Chain 1: Exception: Exception: normal_lpdf: Random variable[9] is nan, but must not be nan! (in '/functions/mvmer_functions.stan' at line 291; included from 'model_jm' at line 12) (in 'model_jm' at line 119)

Chain 1: Chain 1: Initialization between (-2, 2) failed after 100 attempts. Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model. [1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed." error occurred during calling the sampler; sampling not done Error in check_stanfit(stanfit) : Invalid stanfit object produced please report bug

Reproducible Steps:

If applicable, the steps required to reproduce the issue. If you have a reproducible example, please include it. Screenshot of Data for Longitudinal model: Screen Shot 2021-03-24 at 5 50 41 PM

Screenshot of Data for Event Screen Shot 2021-03-24 at 5 50 47 PM model:

tried the following: xcode-select --install result: xcode-select: error: command line tools are already installed

install.packages("rstanarm", type = "source")

library(devtools) install_github("stan-dev/rstanarm")

and none of these fixed the problem.

RStanARM Version:

The version of the rstanarm package you are running (e.g., from packageVersion("rstanarm"))

R Version:

The version of R you are running (e.g., from getRversion()) RStudio Version 1.4.1106 R Version: ‘4.0.4’

Operating System:

Catalina, OS X 10.15.7

tessaclarkson avatar Mar 24 '21 23:03 tessaclarkson

following up the version of rstanarm is ‘2.21.1’

tessaclarkson avatar Mar 25 '21 01:03 tessaclarkson

seems like the fix was related to miss-coding my events model to the point where it censored out all of my subjects that had events rather than noting as events! once i change this the problem was resolved!

tessaclarkson avatar Mar 25 '21 18:03 tessaclarkson

Awesome, thanks for reporting back, that is good to hear! Perhaps it should be catching that at the data stage tho, rather than letting it get to the model fitting stage! 🤔

If that isn't happening, you could possibly leave the issue open and change the title to something like "Should stan_jm throw an error when the survival submodel has zero events"...

sambrilleman avatar Mar 25 '21 23:03 sambrilleman