rstanarm icon indicating copy to clipboard operation
rstanarm copied to clipboard

Running stan_surv() with example data crashes both R and RStudio

Open fsdias opened this issue 3 years ago • 5 comments

RStanARM Version:

2.21.2

R Version/Operating System:

R version 4.0.5 Ubuntu 20.04

I installed rstarnarm with:

install.packages("rstanarm", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Running the following code causes both R an RStudio to crash. No error messages are reported. I have fresh installation of both R, rstan and rstanarm.

library(rstanarm)
library(simsurv)
covs <- data.frame(id  = 1:200, 
                   trt = stats::rbinom(200, 1L, 0.5))
d1 <- simsurv(lambdas = 0.1, 
              gammas  = 1.5, 
              betas   = c(trt = -0.5),
              x       = covs, 
              maxt    = 5)
d1 <- merge(d1, covs)
f1 <- Surv(eventtime, status) ~ trt
m1a <- stan_surv(f1, d1, basehaz = "ms",       chains=1,refresh=0,iter=600)

fsdias avatar Apr 15 '21 17:04 fsdias

Same issue, anyone has found a solution to the problem? In my case I installed same version of Rstanarm (2.21.2). R version 4.0.5, Windows 10 as OS

chiar11 avatar Apr 21 '21 13:04 chiar11

Interesting, I can reproduce it with a new install of R 4.0.5, I get:

> library(simsurv)
> covs <- data.frame(id  = 1:200, 
+                    trt = stats::rbinom(200, 1L, 0.5))
> d1 <- simsurv(lambdas = 0.1, 
+               gammas  = 1.5, 
+               betas   = c(trt = -0.5),
+               x       = covs, 
+               maxt    = 5)
> d1 <- merge(d1, covs)
> f1 <- Surv(eventtime, status) ~ trt
> m1a <- stan_surv(f1, d1, basehaz = "ms",       chains=1,refresh=0,iter=600)

==== C stack trace ===============================

	RaiseException [0x0x7ffd25864b59+105]
	(No symbol) [0x0x6af02fd1]
	(No symbol) [0x0x288e81d7f10]
	(No symbol) [0x0x6b059230]
	(No symbol) [0x0x6b0c82a0]
	(No symbol) [0x0x288e81d7f10]
	(No symbol) [0x0x288e23f2b68]
	(No symbol) [0x0x6b08f145]
	(No symbol) [0x0x288e81d7ed0]
	(No symbol) [0x0x6b05918d]
	(No symbol) [0x0xb7da1f9640]
	R_NilValue [0x0x6e62fa40+0]
	(No symbol) [0x0xb7da1f9640]
	R_NilValue [0x0x6e62fa40+0]
	(No symbol) [0x0xb7da1f9410]
	(No symbol) [0x0x6af2ace6]
	(No symbol) [0x0x200000018]
	(No symbol) [0x0x288d3550000]
	(No symbol) [0x0x288eacdd6d8]

and then R crashes. Same with a new install of R 4.0.4.

But with my previously existing install of R 4.0.3 it works fine.

Must be something with the new version of R. No idea what though...

At a guess we may have built that rstanarm feature/survival branch binary using R 4.0.3.

Is it possible we'd just need to (re)build the rstanarm binary again using the new version of R? Or more likely to be an incompatibility between something in the actual rstanarm codebase and R 4.0.5? @rok-cesnovar @jgabry @bgoodri @andrjohns might have more expertise to comment on that.

I'd suggest downgrading R to 4.0.3 until someone knows the problem/solution I guess, if that is possible for you (at least for these stan_surv analyses).

sambrilleman avatar Apr 24 '21 07:04 sambrilleman

I can replicate the crash under rstan 2.21, but there's no crash under the 2.26 preview. The tricky part is that the rstanarm Makevars files need to be patched so that it can build against rstan 2.26 (they just need -DUSE_STANC3 added). I've opened a PR against the survival branch(here) which adds the flags.

Once those are merged and the packages are rebuilt, then you can install alongside the rstan 2.26 preview and the stan_surv models will work without crashing

andrjohns avatar Apr 24 '21 08:04 andrjohns

Thanks @andrjohns! Do we know when rstan 2.26 will be on CRAN?

sambrilleman avatar Apr 24 '21 09:04 sambrilleman

Hi all

Is this issue fixed anywhere yet? I had this problem this morning but curiously my models work when random effects are specified?

Is there no way to make the models run with cmdstan and would that solve the problems with using rstan that seemed to plague lots of different installs?

padpadpadpad avatar May 17 '21 08:05 padpadpadpad