stan-dev / stan-dev/rstanarm

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

Open
#506 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

joint models
Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the stan_jm entry point and inspect the generated model_jm code, including the failure reported from functions/mvmer_functions.stan around line 291. Check how a survival submodel with zero events reaches Stan initialization and identify the existing validation tests or model-fitting tests. Done means the case produces a clear, intentional error rather than an invalid stanfit error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.