Skip to content

Commit

Permalink
Merge pull request #1735 from danielinteractive/1734_fix_step_mismatch
Browse files Browse the repository at this point in the history
Align step() with Stan and add int_step()
  • Loading branch information
paul-buerkner authored Feb 1, 2025
2 parents e10ab04 + d131557 commit b1ec0be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Fit extended-support Beta models via family `xbeta`
thanks to Ioannis Kosmidis. (#1698)
* Add a `seed` argument to `loo_R2` thanks to Marco Colombo. (#1713)
* Add the `int_step` R function to match the corresponding Stan
function. (#1734)

### Bug Fixes

Expand All @@ -15,6 +17,8 @@ in parallel even on Unix systems. To avoid potential speed loss for small
models, `log_lik` will not use `option(mc.cores)` anymore.
These changes may be reverted once the underlying causes of this
issue have been fixed. (#1658)
* Align the definition of the R function `step()` with the definition in Stan,
such that `step(0) == 1` (#1734)

### Other Changes

Expand Down
10 changes: 10 additions & 0 deletions R/numeric-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ log1m <- function(x) {
}

step <- function(x) {
if (is.logical(x)) {
warning2(
"Consider using int_step() instead of step(), ",
"because step(FALSE) = step(TRUE) = 1 in Stan."
)
}
ifelse(x >= 0, 1, 0)
}

int_step <- function(x) {
ifelse(x > 0, 1, 0)
}

Expand Down

0 comments on commit b1ec0be

Please sign in to comment.