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

dbarts: add standard error for interval predictions #978

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* `augment()` now works for censored regression models.

* For BART models with the `dbarts` engine, `predict()` can now also return the standard error for confidence and prediction intervals (#976).


# parsnip 1.1.0

This release of parsnip contains a number of new features and bug fixes, accompanied by several optimizations that substantially decrease the time to `fit()` and `predict()` with the package.
Expand Down
3 changes: 3 additions & 0 deletions R/bart.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ dbart_predict_calc <- function(obj, new_data, type, level = 0.95, std_err = FALS
)
)
}
if (std_err) {
res$.std_error <- apply(post_dist, 2, stats::sd, na.rm = TRUE)
}
}
res
}
Expand Down
18 changes: 12 additions & 6 deletions R/bart_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ set_pred(
obj = expr(object),
new_data = expr(new_data),
type = "conf_int",
level = expr(level)
level = expr(level),
std_err = expr(std_error)
)
)
)
Expand All @@ -158,7 +159,8 @@ set_pred(
obj = expr(object),
new_data = expr(new_data),
type = "pred_int",
level = expr(level)
level = expr(level),
std_err = expr(std_error)
)
)
)
Expand Down Expand Up @@ -215,7 +217,8 @@ set_pred(
obj = expr(object),
new_data = expr(new_data),
type = "conf_int",
level = expr(level)
level = expr(level),
std_err = expr(std_error)
)
)
)
Expand All @@ -233,7 +236,8 @@ set_pred(
obj = expr(object),
new_data = expr(new_data),
type = "pred_int",
level = expr(level)
level = expr(level),
std_err = expr(std_error)
)
)
)
Expand All @@ -248,7 +252,9 @@ set_pred(
post = NULL,
func = c(pkg = "parsnip", fun = "dbart_predict_calc"),
args =
list(obj = quote(object),
new_data = quote(new_data))
list(
obj = quote(object),
new_data = quote(new_data)
)
)
)