Skip to contents

Simulate posterior distributions from fitted AME model

Usage

simulate_posterior(
  fit,
  component = c("UV", "ab", "beta", "Y"),
  n_samples = NULL,
  seed = NULL
)

Arguments

fit

Fitted ame model object

component

Character; which component to simulate: "UV", "ab", "beta", "Y"

n_samples

Number of posterior samples to return. Defaults to NULL, which uses every saved draw when the fit stores them (see posterior_options) and 100 otherwise. A smaller value draws a random subset, which widens Monte Carlo error in the tails of any interval computed from the result.

seed

Random seed for reproducibility

Value

Array or matrix of posterior samples

Details

This function can simulate posterior distributions even when they weren't saved during MCMC, by using the posterior means and variance components.

For more accurate posteriors, use posterior_options() during model fitting to save the actual MCMC samples.

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau

Examples

# \donttest{
# Fit a model with multiplicative effects
data(YX_nrm)
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 2,
           nscan = 100, burn = 10, odens = 1, verbose = FALSE)

# Get posterior samples of regression coefficients
beta_post <- simulate_posterior(fit, "beta", n_samples = 50)
#> Using saved MCMC samples for beta
# }