Skip to content

Commit f9571e2

Browse files
committed
avoid a warning with the new rstanarm package
1 parent ee9f30c commit f9571e2

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export(show_call)
177177
export(show_engines)
178178
export(show_fit)
179179
export(show_model_info)
180+
export(stan_conf_int)
180181
export(surv_reg)
181182
export(svm_poly)
182183
export(svm_rbf)

R/linear_reg_data.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,11 @@ set_pred(
258258
res$.std_error <- apply(results, 2, sd, na.rm = TRUE)
259259
res
260260
},
261-
func = c(pkg = "rstanarm", fun = "posterior_linpred"),
261+
func = c(pkg = "parsnip", fun = "stan_conf_int"),
262262
args =
263263
list(
264264
object = expr(object$fit),
265-
newdata = expr(new_data),
266-
transform = TRUE,
267-
seed = expr(sample.int(10^5, 1))
265+
newdata = expr(new_data)
268266
)
269267
)
270268
)

R/logistic_reg_data.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,11 @@ set_pred(
518518
res$.std_error <- apply(results, 2, sd, na.rm = TRUE)
519519
res
520520
},
521-
func = c(pkg = "rstanarm", fun = "posterior_linpred"),
521+
func = c(pkg = "parsnip", fun = "stan_conf_int"),
522522
args =
523523
list(
524-
object = quote(object$fit),
525-
newdata = quote(new_data),
526-
transform = TRUE,
527-
seed = expr(sample.int(10^5, 1))
524+
object = expr(object$fit),
525+
newdata = expr(new_data)
528526
)
529527
)
530528
)

R/misc.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,28 @@ update_engine_parameters <- function(eng_args, ...) {
305305
ret
306306
}
307307

308+
# ------------------------------------------------------------------------------
309+
# Since stan changed the function interface
310+
#' Wrapper for stan confidence intervals
311+
#' @param object A stan model fit
312+
#' @param newdata A data set.
313+
#' @export
314+
#' @keywords internal
315+
stan_conf_int <- function(object, newdata) {
316+
check_installs(list(method = list(libs = "rstanarm")))
317+
if (utils::packageVersion("rstanarm") >= "2.21.1") {
318+
fn <- rlang::call2("posterior_epred", .ns = "rstanarm",
319+
object = expr(object),
320+
newdata = expr(newdata),
321+
seed = expr(sample.int(10^5, 1)))
322+
} else {
323+
fn <- rlang::call2("posterior_linpred", .ns = "rstanarm",
324+
object = expr(object),
325+
newdata = expr(newdata),
326+
transform = TRUE,
327+
seed = expr(sample.int(10^5, 1)))
328+
}
329+
rlang::eval_tidy(fn)
330+
}
331+
308332

man/stan_conf_int.Rd

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)