Skip to contents

The $unconstrain_draws() method transforms all parameter draws to the unconstrained scale. If called with no arguments, then the draws within the fit object are unconstrained. Alternatively, either an existing draws object or a character vector of paths to CSV files can be passed. A zero-size variable has no columns and is skipped.

Usage

unconstrain_draws(
  files = NULL,
  draws = NULL,
  format = getOption("cmdstanr_draws_format", "draws_array"),
  inc_warmup = FALSE
)

Arguments

files

(character vector) The paths to the CmdStan CSV files. These can be files generated by running CmdStanR or running CmdStan directly.

draws

A posterior::draws_* object.

format

(string) The format of the returned draws. Must be a valid format from the posterior package. Defaults to getOption("cmdstanr_draws_format", "draws_array").

inc_warmup

(logical) Should warmup draws be included when using draws from the fit object or CSV files? Defaults to FALSE. If draws is supplied, inc_warmup is ignored with a message.

Value

A posterior::draws_* object in the format specified by format.

Examples

# \dontrun{
fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)

# Unconstrain all internal draws
unconstrained_internal_draws <- fit_mcmc$unconstrain_draws()

# Unconstrain external CmdStan CSV files
unconstrained_csv <- fit_mcmc$unconstrain_draws(files = fit_mcmc$output_files())

# Unconstrain existing draws object
unconstrained_draws <- fit_mcmc$unconstrain_draws(draws = fit_mcmc$draws())
# }