Skip to content

Commit

Permalink
fix issue #1143
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed May 7, 2021
1 parent 98d0cc8 commit c06a7ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ to `posterior_epred(dpar = "mu")` and no longer deprecated.

* Fix an issue in the post-processing of non-normal ARMA models
thanks to Thomas Buehrens. (#1149)
* Fix an issue with default baseline hazard knots in `cox` models
thanks to Malcolm Gillies. (#1143)


# brms 2.15.0
Expand Down
17 changes: 8 additions & 9 deletions R/data-response.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,14 @@ bhaz_basis_matrix <- function(y, args = list(), integrate = FALSE,
args$intercept <- as_one_logical(args$intercept)
}
if (is.null(args$Boundary.knots)) {
if (isTRUE(args$intercept)) {
lower_knot <- min(y)
upper_knot <- max(y)
} else {
# we need a smaller lower boundary knot to avoid lp = -Inf
# the below choices are ad-hoc and may need further thought
lower_knot <- max(min(y) - mad(y, na.rm = TRUE) / 10, 0)
upper_knot <- max(y) + mad(y, na.rm = TRUE) / 10
}
# avoid 'knots' outside 'Boundary.knots' error (#1143)
# we also need a smaller lower boundary knot to avoid lp = -Inf
# the below choices are ad-hoc and may need further thought
min_y <- min(y, na.rm = TRUE)
max_y <- max(y, na.rm = TRUE)
diff_y <- max_y - min_y
lower_knot <- max(min_y - diff_y / 50, 0)
upper_knot <- max_y + diff_y / 50
args$Boundary.knots <- c(lower_knot, upper_knot)
}
if (integrate) {
Expand Down

0 comments on commit c06a7ea

Please sign in to comment.