stan-dev / stan-dev/posterior

.args in summarise draws incompatible with summary functions without ellipses

Open
#341 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
171
Forks
26
Avg merge
2d 18h
Merged PRs (30d)
3

Description

The .args argument in summarise draws is passed to all summary functions as additional arguments. This fails if the summary function does not handle ... or the keyword arguments specified in .args. Common functions that don't handle ... include stats::sd and stats::var.

I'd like to be able to do something like the following:

x <- example_draws()
summarise_draws(x, mean, sd, quantile2, mcse_quantile) #q5 and q95 by default
#> [Output as expected]

# change the quantiles of interest to q1 and q99
additional_args <- list(probs = c(0.01, 0.99))
summarise_draws(x, mean, sd, quantile2, mcse_quantile, .args = additional_args)

#> Error in stats::sd(x, ...) : unused argument (probs = c(0.01, 0.99))

One option would be to make aliases of these common summary functions that handle ..., but perhaps there is a more sensible way to only pass the keywords to functions that handle them?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the summarise_draws entry point and reproduce the example with example_draws(), sd, quantile2, and mcse_quantile, confirming how .args reaches each summary function. Done means probs is accepted by functions that use it without being sent to stats::sd or stats::var, with coverage for the reported failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.