Generates networks from aligned joint posterior draws. A fit that did not
save them can use the conditional approximation by asking for it with
type = "approximate"; see Details.
Arguments
- object
fitted model object of class "ame"
- nsim
number of networks to simulate (default: 100)
- seed
Optional random seed. An explicit seed is local to this call: the caller's RNG state is restored on return or error. With NULL, the caller's current RNG stream advances normally.
- newdata
optional list containing new covariate data:
- Xdyad
dyadic covariates (n x n x p array or nA x nB x p for bipartite)
- Xrow
row/sender covariates (n x p matrix or nA x p for bipartite)
- Xcol
column/receiver covariates (n x p matrix or nB x p for bipartite)
If NULL, uses covariates from original model fit
- burn_in
number of initial MCMC samples to discard (default: 0, assumes burn-in already removed)
- thin
thinning interval for MCMC samples (default: 1, use every sample)
- return_latent
logical: return latent Z matrices in addition to Y? (default: FALSE)
- type
simulation route:
"posterior"(default) replicates the network from aligned saved posterior draws;"approximate"is the conditional approximation. See Details.- ...
additional arguments (not currently used)
Value
A list with components:
- Y
list of nsim simulated networks in the same format as the original data
- method
joint posterior or conditional approximation
- draw_index
sampled coefficient-row indices for joint replication
- Z
if return_latent=TRUE, list of nsim latent Z matrices
- family
the family of the model (binary, normal, etc.)
- mode
network mode (unipartite or bipartite)
Details
With type = "posterior", every replicate uses the same saved MCMC
iteration for coefficients, actor effects, positions, coupling and observation
variance. Saved blocks may be thinned differently when their iteration indices
are available; only shared iterations are sampled. Missing joint storage is an
error (class lame_simulate_draws) that names type = "approximate".
Store effects and positions with posterior_options(save_ab = TRUE,
save_UV = TRUE, thin_ab = 1, thin_UV = 1) when fitting.
type = "approximate" is the conditional approximation: it substitutes
posterior summaries for the latent trajectories and does not propagate their
joint posterior uncertainty. It runs only when requested. The returned method identifies the route.
Ordinal fits with explicit cutpoints use the corresponding saved cutpoint draw. Data-induced ordinal fits match the observed category frequencies, so these replications assess dependence conditional on those frequencies.
Examples
# \donttest{
# Fit a model
data(YX_bin)
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- ame(YX_bin$Y, Xdyad = YX_bin$X, burn = 50, nscan = 250, odens = 5,
family = "binary", verbose = FALSE,
posterior_opts = posterior_options(save_ab = TRUE, save_UV = TRUE), chains = 1)
# Simulate 10 networks from posterior
sims <- simulate(fit, nsim = 10)
# }