Generates multiple network realizations from a fitted AME model. This function performs conditional posterior predictive simulation: it draws from stored MCMC samples when they are available and uses posterior means for latent components that were not retained.
Unlike print.ame, which only displays fitted quantities,
simulate.ame draws new networks from the posterior predictive
distribution.
# S3 method for ame
simulate(
object,
nsim = 100,
seed = NULL,
newdata = NULL,
burn_in = 0,
thin = 1,
return_latent = FALSE,
...
)A list with components:
list of nsim simulated networks in the same format as the original data
if return_latent=TRUE, list of nsim latent Z matrices
the family of the model (binary, normal, etc.)
network mode (unipartite or bipartite)
fitted model object of class "ame"
number of networks to simulate (default: 100)
random seed for reproducibility
optional list containing new covariate data:
dyadic covariates (n x n x p array or nA x nB x p for bipartite)
row/sender covariates (n x p matrix or nA x p for bipartite)
column/receiver covariates (n x p matrix or nB x p for bipartite)
If NULL, uses covariates from original model fit
number of initial MCMC samples to discard (default: 0, assumes burn-in already removed)
thinning interval for MCMC samples (default: 1, use every sample)
logical: return latent Z matrices in addition to Y? (default: FALSE)
additional arguments (not currently used)
Cassy Dorff, Shahryar Minhas, Tosin Salau
Model:
The AME model represents networks through a latent variable framework: $$Y_{ij} \sim F(Z_{ij})$$ where F is the observation model (e.g., probit for binary) and Z is the latent network: $$Z_{ij} = \beta^T x_{ij} + a_i + b_j + u_i^T v_j + \epsilon_{ij}$$
Components:
\(\beta\): regression coefficients for dyadic/nodal covariates
\(a_i, b_j\): additive sender and receiver random effects
\(u_i, v_j\): multiplicative latent factors (dimension R)
\(\epsilon_{ij}\): dyadic random effects with correlation \(\rho\)
Simulation:
For each simulated network k = 1, ..., nsim:
Parameter draw: Draw parameter set \(\theta^{(k)}\) from MCMC chains:
Sample iteration s uniformly from stored MCMC samples
Extract \(\beta^{(s)}\), variance components \((v_a^{(s)}, v_b^{(s)}, v_e^{(s)}, \rho^{(s)})\)
Random effects: Sample new random effects from posterior distributions:
\(a_i^{(k)} \sim N(0, v_a^{(s)})\) for i = 1, ..., n (row effects)
\(b_j^{(k)} \sim N(0, v_b^{(s)})\) for j = 1, ..., m (column effects)
Fresh draws from the posterior variance carry random-effect uncertainty into the simulated networks
Latent network: Build expected latent positions: $$E[Z_{ij}^{(k)}] = \beta^{(s)T} x_{ij} + a_i^{(k)} + b_j^{(k)} + \hat{u}_i^T \hat{v}_j$$ where \(\hat{u}_i, \hat{v}_j\) are posterior mean latent factors
Dyadic correlation: Add correlated noise structure: $$Z_{ij}^{(k)} = E[Z_{ij}^{(k)}] + \epsilon_{ij}^{(k)}$$ where \(\epsilon\) has covariance structure: $$Cov(\epsilon_{ij}, \epsilon_{ji}) = \rho^{(s)} v_e^{(s)}$$ $$Var(\epsilon_{ij}) = v_e^{(s)}$$
Observation model: Generate the observed network:
Binary: \(Y_{ij}^{(k)} = I(Z_{ij}^{(k)} > 0)\)
Normal: \(Y_{ij}^{(k)} = Z_{ij}^{(k)}\)
Poisson: \(Y_{ij}^{(k)} \sim Poisson(\exp(Z_{ij}^{(k)}))\)
Other families use appropriate link functions
Sources of uncertainty:
The simulation captures three types of uncertainty:
Parameter uncertainty: Different MCMC samples yield different \(\beta, v_a, v_b, v_e, \rho\)
Random effect uncertainty: Fresh draws from \(N(0, v_a), N(0, v_b)\) for each simulation
Dyadic uncertainty: Correlated random noise \(\epsilon_{ij}\)
The resulting simulations propagate uncertainty from the stored parameter draws and from fresh dyadic/random-effect draws. Latent components that were not stored as MCMC draws are held at their posterior means.
Latent-factor draws:
Multiplicative effects (U, V) use posterior means unless the fit retained compatible latent-factor draws. Storing full latent-factor chains can require substantial additional memory.
Symmetric Networks:
For symmetric networks, the model enforces \(a_i = b_i\) and \(u_i = v_i\), and the latent matrix Z is symmetrized before generating observations.
# \donttest{
# Fit a model
data(YX_bin)
fit <- ame(YX_bin$Y, Xdyad = YX_bin$X, burn = 10, nscan = 100, odens = 1,
family = "binary", verbose = FALSE)
# Simulate 10 networks from posterior
sims <- simulate(fit, nsim = 10)
# }
Run the code above in your browser using DataLab