Convenience wrapper around compress_posterior() that accepts either a cmdstanr::CmdStanMCMC fit or a vector of cmdstan CSV file paths.

compress_fit(
  fit,
  method = c("mclust", "mvdens_gmm", "mvdens_kde"),
  variables = NULL,
  n_components = 3L,
  model_name = NULL,
  verbose = FALSE,
  remove_csvs = FALSE,
  ...
)

Arguments

fit

Either a CmdStanMCMC object (from cmdstanr::sample()) or a character vector of cmdstan CSV file paths.

method

One of 'mclust', 'mvdens_gmm', 'mvdens_kde'. See compression_methods().

variables

Optional character vector of parameter names to keep. If NULL (default) all columns are used.

n_components

Integer number of mixture components (used by "mclust" and "mvdens_gmm"). Default 3.

model_name

mclust covariance structure (e.g. "VVV", "EEE", or a vector of allowed model names). Ignored by other methods. When NULL (default) poco auto-selects a sensible set: the spherical and diagonal models c("EII", "VII", "EEI", "EVI", "VEI", "VVI") are used when nrow(draws) <= ncol(draws) so covariances remain identifiable, otherwise mclust's full default set is used and BIC picks the best.

verbose

Logical; print backend progress. Default FALSE.

remove_csvs

Logical; if TRUE and fit is a CmdStanMCMC, delete the CSV output files after compression. Default FALSE.

...

Additional arguments forwarded to the backend (e.g. mclust::Mclust()).

Value

A posterior_compressed object (see compress_posterior()).

Examples

if (FALSE) { # \dontrun{
fit <- mod$sample(data = stan_data, chains = 4)
comp <- compress_fit(fit, method = "mclust", n_components = 5)
samples <- sample_posterior(comp, n_draws = 1000)
} # }