simulate_prior: Returns Priors of a Model as Empirical Distributions

View source: R/simulate_priors.R

simulate_priorR Documentation

Returns Priors of a Model as Empirical Distributions

Description

Transforms priors information to actual distributions.

Usage

simulate_prior(model, n = 1000, ...)

## S3 method for class 'brmsfit'
simulate_prior(
  model,
  n = 1000,
  effects = "fixed",
  component = "conditional",
  parameters = NULL,
  verbose = TRUE,
  ...
)

Arguments

model

A stanreg, stanfit, brmsfit, blavaan, or MCMCglmm object.

n

Size of the simulated prior distributions.

...

Currently not used.

effects

Should results for fixed effects ("fixed", the default), random effects ("random") or both ("⁠all"⁠) be returned? Only applies to mixed models. May be abbreviated.

component

Which type of parameters to return, such as parameters for the conditional model, the zero-inflated part of the model, the dispersion term, etc. See details in section Model Components. May be abbreviated. Note that the conditional component also refers to the count or mean component - names may differ, depending on the modeling package. There are three convenient shortcuts (not applicable to all model classes):

  • component = "all" returns all possible parameters.

  • If component = "location", location parameters such as conditional, zero_inflated, smooth_terms, or instruments are returned (everything that are fixed or random effects - depending on the effects argument - but no auxiliary parameters).

  • For component = "distributional" (or "auxiliary"), components like sigma, dispersion, beta or precision (and other auxiliary parameters) are returned.

parameters

Regular expression pattern that describes the parameters that should be returned. Meta-parameters (like lp__ or prior_) are filtered by default, so only parameters that typically appear in the summary() are returned. Use parameters to select specific parameters for the output.

verbose

Toggle off warnings.

See Also

unupdate() for directly sampling from the prior distribution (useful for complex priors and designs).

Examples


library(bayestestR)
if (require("rstanarm")) {
  model <- suppressWarnings(
    stan_glm(mpg ~ wt + am, data = mtcars, chains = 1, refresh = 0)
  )
  simulate_prior(model)
}


DominiqueMakowski/bayestestR documentation built on March 29, 2025, 4:17 p.m.