| prior_predict | R Documentation |
Draw datasets from the prior predictive distribution: parameters are sampled from their priors (no data conditioning) and pushed through the model's linear predictor and the family's simulator.
Useful for checking whether priors imply plausible data ranges before fitting.
prior_predict(
formula,
family,
data,
priors = NULL,
n_draws = 100,
seed = NULL,
...
)
## S3 method for class 'tulpa_prior_predict'
print(x, ...)
formula |
A model formula (e.g., |
family |
A |
data |
Data frame containing covariates and grouping factors. Used for dimensions and design matrices; the response column may be absent or NA. |
priors |
Prior specification ( |
n_draws |
Number of prior parameter draws. Default 100. |
seed |
Optional integer seed for reproducibility. |
... |
Passed to |
x |
A |
A tulpa_prior_predict object: a list with
y: list of length n_draws, each element the simulated response for
that draw (matching whatever shape family$simulate_fn returns).
theta: list of length n_draws of parameter draws (beta, sigma,
RE coefficients u, family-specific extras).
linpred: list of length n_draws, each a list of linear predictor
vectors per process.
family: the family used.
n_draws, n_obs.
# Toy Gaussian family for illustration
fam <- tulpa_family(
name = "gaussian",
simulate_fn = function(eta, params, n_obs, ...) {
rnorm(n_obs, eta[[1]], params$sigma_y)
},
extra_params = list(sigma_y = prior_half_normal(1))
)
df <- data.frame(y = rep(0, 20), x = rnorm(20))
pp <- prior_predict(y ~ x, fam, df, n_draws = 50, seed = 1)
length(pp$y) # 50
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.