Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 29, 2024
1 parent 6aaa29a commit 88849be
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions R/check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,37 @@ check_predictions.stanreg <- function(object,
)

if (inherits(object, "brmsfit")) {
out <- bayesplot::pp_check(object, type = type, ndraws = iterations, ...)
out <- as.data.frame(bayesplot::pp_check(object, type = type, ndraws = iterations, ...))

Check warning on line 164 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L163-L164

Added lines #L163 - L164 were not covered by tests
} else {
out <- bayesplot::pp_check(object, type = type, nreps = iterations, ...)
out <- as.data.frame(bayesplot::pp_check(object, type = type, nreps = iterations, ...))

Check warning on line 166 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L166

Added line #L166 was not covered by tests
}

# bring data into shape, like we have for other models with `check_predictions()`
if (type == "density") {
d <- as.data.frame(out$data)
d_filter <- d[!d$is_y, ]
d_filter <- datawizard::data_to_wide(
d_filter,
id_cols = "y_id",
values_from = "value",
names_from = "rep_id"

Check warning on line 177 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L170-L177

Added lines #L170 - L177 were not covered by tests
)
d_filter$y_id <- NULL
colnames(d_filter) <- paste0("sim_", colnames(d_filter))
d_filter$y <- d$value[d$is_y, ]
out <- d_filter

Check warning on line 182 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L179-L182

Added lines #L179 - L182 were not covered by tests
} else {
colnames(out) <- c("x", "y", "CI_low", "Mean", "CI_high")

Check warning on line 184 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L184

Added line #L184 was not covered by tests
}

attr(out, "is_stan") <- TRUE
attr(out, "check_range") <- check_range
attr(out, "response_name") <- resp_string
attr(out, "bandwidth") <- bandwidth
attr(out, "model_info") <- minfo
attr(out, "type") <- type
class(out) <- c("performance_pp_check", "see_performance_pp_check", class(out))
out

Check warning on line 194 in R/check_predictions.R

View check run for this annotation

Codecov / codecov/patch

R/check_predictions.R#L187-L194

Added lines #L187 - L194 were not covered by tests
}

#' @export
Expand Down

0 comments on commit 88849be

Please sign in to comment.