Skip to content

PPC/PPD functions don't accept posterior::draws objects as yrep/ypred #542

@ishaan-arora-1

Description

@ishaan-arora-1

While working on my GSoC prior vs posterior prototype (which accepts draws objects for both prior and posterior inputs), I noticed that mcmc_* functions handle posterior::draws objects fine — prepare_mcmc_array() checks posterior::is_draws(x) and coerces to array — but the PPC/PPD side doesn't.

validate_predictions() in helpers-ppc.R does:

stopifnot(is.matrix(predictions), is.numeric(predictions))

So passing a draws_matrix or draws_array as yrep to any ppc_* function fails immediately, even though these are standard outputs from cmdstanr and brms workflows. Users have to manually call as.matrix() first.

Seems like adding a draws check at the top of validate_predictions() (similar to what prepare_mcmc_array() already does) would fix this for all PPC/PPD functions at once. Happy to put up a PR if that sounds reasonable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions