Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stan_surv exits with an error because of changes in || (R≥4.3) #593

Closed
anddis opened this issue Jun 26, 2023 · 2 comments
Closed

stan_surv exits with an error because of changes in || (R≥4.3) #593

anddis opened this issue Jun 26, 2023 · 2 comments

Comments

@anddis
Copy link

anddis commented Jun 26, 2023

Summary:

stan_surv() exits with an error with R>=4.3 because of changes introduced to the default behavior of the || operator.

Description:

stan_surv() checks that the censoring indicator variable is not < 0 or > 3 using the || operator. The new behaviour of || makes stan_surv() exit with an error.

See: https://stat.ethz.ch/pipermail/r-announce/2023/000691.html

* Calling && or || with LHS or (if evaluated) RHS of length greater
      than one is now always an error, with a report of the form

          'length = 4' in coercion to 'logical(1)'

Reproducible Steps:

> library(survival)
> library(rstanarm)
> surv <- stan_surv(Surv(futime, death) ~ mspike, 
+                   data = mgus, 
+                   basehaz = "weibull",
+                   chains = 1, 
+                   seed = 1234)
Error in status < 0 || status > 3 : 
  'length = 241' in coercion to 'logical(1)'

RStanARM Version:

2.21.3 from the survival devel branch

R Version:

4.3.1

Operating System:

macOS 13.4.1

@anddis anddis changed the title stan_surv exits with an error because of new base::if() stan_surv exits with an error because of changes in || (R≥4.3) Jun 27, 2023
@anddis
Copy link
Author

anddis commented Jul 3, 2023

Substituting |for || in line 518 and 1796 of stan_surv.R seems to be all it's needed to fix this issue.

@sambrilleman
Copy link
Collaborator

Awesome, thanks @anddis for picking this up, and suggesting the fix! Yeah it looks like | should have probably been the appropriate choice in the first place, or perhaps ( any(status < 0) || any(status > 3) ).

I've merged your suggestion into the feature/survival branch: #594.

I believe we still don't any automated build / tests on that branch yet, which is horrendously discomforting 😅, but hopefully all is ok - so I'll close the issue, but we can reopen it if there are still problems! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants