Skip to content
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# bayesplot (development version)

* Unified density-control argument defaults (`bw`, `adjust`, `kernel`, `n_dens`) to use `NULL` with internal fallbacks. No change in user-facing behavior.
* `prepare_mcmc_array()` now warns instead of erroring on `NA`s in the input.
* Fixed `validate_chain_list()` colnames check to compare all chains, not just the first two.
* Added test verifying `legend_move("none")` behaves equivalently to `legend_none()`.
Expand Down
20 changes: 12 additions & 8 deletions R/ppc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ ppc_dens_overlay <-
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
bw = NULL,
adjust = NULL,
kernel = NULL,
bounds = NULL,
n_dens = 1024) {
n_dens = NULL) {
check_ignored_arguments(...)
bw <- bw %||% "nrd0"
adjust <- adjust %||% 1
kernel <- kernel %||% "gaussian"
n_dens <- n_dens %||% 1024
bounds <- validate_density_bounds(bounds)

data <- ppc_data(y, yrep)
Expand Down Expand Up @@ -224,11 +228,11 @@ ppc_dens_overlay_grouped <- function(y,
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
bw = NULL,
adjust = NULL,
kernel = NULL,
bounds = NULL,
n_dens = 1024) {
n_dens = NULL) {
check_ignored_arguments(...)

p_overlay <- ppc_dens_overlay(
Expand Down
12 changes: 8 additions & 4 deletions R/ppc-loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ ppc_loo_pit_overlay <- function(y,
alpha = 0.7,
boundary_correction = TRUE,
grid_len = 512,
bw = "nrd0",
bw = NULL,
trim = FALSE,
adjust = 1,
kernel = "gaussian",
n_dens = 1024) {
adjust = NULL,
kernel = NULL,
n_dens = NULL) {
check_ignored_arguments(..., ok_args = list("moment_match"))
bw <- bw %||% "nrd0"
adjust <- adjust %||% 1
kernel <- kernel %||% "gaussian"
n_dens <- n_dens %||% 1024

data <-
ppc_loo_pit_data(
Expand Down
30 changes: 17 additions & 13 deletions R/ppd-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ ppd_data <- function(ypred, group = NULL) {
#' @rdname PPD-distributions
#' @export
ppd_dens_overlay <-
function(ypred,
show_marginal = FALSE,
...,
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
bounds = NULL,
n_dens = 1024) {
check_ignored_arguments(...)
bounds <- validate_density_bounds(bounds)
function(ypred,
show_marginal = FALSE,
...,
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = NULL,
adjust = NULL,
kernel = NULL,
bounds = NULL,
n_dens = NULL) {
check_ignored_arguments(...)
bw <- bw %||% "nrd0"
adjust <- adjust %||% 1
kernel <- kernel %||% "gaussian"
n_dens <- n_dens %||% 1024
bounds <- validate_density_bounds(bounds)

data <- ppd_data(ypred)
p <- ggplot(data, mapping = aes(x = .data$value)) +
Expand Down
3 changes: 2 additions & 1 deletion man-roxygen/args-density-controls.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @param bw,adjust,kernel,n_dens,bounds Optional arguments passed to
#' [stats::density()] (and `bounds` to [ggplot2::stat_density()]) to override
#' default kernel density estimation parameters or truncate the density
#' support. `n_dens` defaults to `1024`.
#' support. If `NULL` (default), `bw` is set to `"nrd0"`, `adjust` to `1`,
#' `kernel` to `"gaussian"`, and `n_dens` to `1024`.
3 changes: 2 additions & 1 deletion man/MCMC-distributions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/MCMC-intervals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions man/PPC-distributions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/PPC-loo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions man/PPD-distributions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading