Generates multiple longitudinal network realizations from a fitted LAME (Longitudinal AME) model. This function performs conditional posterior predictive simulation for dynamic networks: it draws from stored MCMC samples when available and uses posterior means for latent components that were not retained.
# S3 method for lame
simulate(
object,
nsim = 100,
seed = NULL,
newdata = NULL,
n_time = NULL,
burn_in = 0,
thin = 1,
return_latent = FALSE,
start_from = "posterior",
...
)A list with components:
list of nsim simulated longitudinal network trajectories, each element is a list of T networks
if return_latent=TRUE, list of nsim latent Z trajectories
the family of the model (binary, normal, etc.)
network mode (unipartite or bipartite)
number of time periods
fitted model object of class "lame"
number of network trajectories to simulate (default: 100)
random seed for reproducibility
optional list containing new covariate data:
list of T dyadic covariate arrays (n x n x p or nA x nB x p)
list of T row/sender covariate matrices (n x p or nA x p)
list of T column/receiver covariate matrices (n x p or nB x p)
If NULL, uses covariates from original model fit
number of time periods to simulate. If NULL, uses same as original data
number of initial MCMC samples to discard (default: 0)
thinning interval for MCMC samples (default: 1, use every sample)
logical: return latent Z matrices in addition to Y? (default: FALSE)
character: how to initialize the simulation
start from posterior mean (default)
random initialization
use first time point from original data
additional arguments (not currently used)
Shahryar Minhas
Mathematical Framework for Longitudinal Networks:
The LAME model extends AME to multiple time periods T with potential temporal dependencies. For each time t = 1, ..., T: $$Y_{ij,t} \sim F(Z_{ij,t})$$ where the latent network evolves as: $$Z_{ij,t} = \beta^T x_{ij,t} + a_{i,t} + b_{j,t} + u_{i,t}^T v_{j,t} + \epsilon_{ij,t}$$
Temporal Dynamics:
LAME can incorporate three types of temporal dependencies:
Static Effects: Parameters constant over time
\(a_{i,t} = a_i\), \(b_{j,t} = b_j\) for all t
\(u_{i,t} = u_i\), \(v_{j,t} = v_j\) for all t
Dynamic Additive Effects: AR(1) process for random effects $$a_{i,t} = \rho_{ab} a_{i,t-1} + \eta_{i,t}, \quad \eta_{i,t} \sim N(0, \sigma_a^2(1-\rho_{ab}^2))$$ $$b_{j,t} = \rho_{ab} b_{j,t-1} + \xi_{j,t}, \quad \xi_{j,t} \sim N(0, \sigma_b^2(1-\rho_{ab}^2))$$ where \(\rho_{ab}\) is the temporal correlation parameter
Dynamic Multiplicative Effects: AR(1) for latent factors $$u_{i,t} = \rho_{uv} u_{i,t-1} + \omega_{i,t}$$ $$v_{j,t} = \rho_{uv} v_{j,t-1} + \psi_{j,t}$$
Uncertainty Quantification Process for Trajectories:
For each simulated trajectory k = 1, ..., nsim:
Step 1: Parameter Sampling
Draw MCMC iteration s uniformly from stored posterior samples
Extract static parameters: \(\beta^{(s)}\), variance components
Extract temporal parameters if applicable: \(\rho_{ab}^{(s)}\), \(\rho_{uv}^{(s)}\)
Step 2: Initialize at t = 1
Depending on start_from parameter:
"posterior": Use posterior means as starting values
"random": Draw from stationary distribution
For additive effects: \(a_{i,1}^{(k)} \sim N(0, \sigma_a^2)\)
For multiplicative effects: Initialize from prior
Step 3: Evolve Through Time
For each t = 2, ..., T:
a) Update Dynamic Effects (if applicable): $$a_{i,t}^{(k)} = \rho_{ab}^{(s)} a_{i,t-1}^{(k)} + \eta_{i,t}^{(k)}$$ where \(\eta_{i,t}^{(k)} \sim N(0, \sigma_a^2(1-[\rho_{ab}^{(s)}]^2))\)
The innovation variance \(\sigma_a^2(1-\rho_{ab}^2)\) ensures stationarity
b) Construct Latent Network: $$E[Z_{ij,t}^{(k)}] = \beta^{(s)T} x_{ij,t} + a_{i,t}^{(k)} + b_{j,t}^{(k)} + u_{i,t}^T v_{j,t}$$
c) Add Dyadic Noise: $$Z_{ij,t}^{(k)} = E[Z_{ij,t}^{(k)}] + \epsilon_{ij,t}^{(k)}$$ with correlation structure preserved from AME model
d) Generate Observations: Apply appropriate link function based on family
Sources of Uncertainty in Longitudinal Context:
Cross-sectional uncertainty (as in AME):
Parameter uncertainty from MCMC
Random effect variability
Dyadic noise
Temporal uncertainty:
Uncertainty in temporal correlation parameters \(\rho_{ab}, \rho_{uv}\)
Innovation noise in AR(1) processes
Propagation of uncertainty through time (compounds over periods)
Initial condition uncertainty:
Different starting values lead to different trajectories
Captured through start_from options
Interpretation of Multiple Trajectories:
Each simulated trajectory represents one possible evolution of the network conditional on the stored fit. Variation across trajectories captures:
Model parameter uncertainty
Stochastic variation in temporal evolution
Accumulated uncertainty over time periods
The ensemble of trajectories provides prediction intervals that widen over time, reflecting increasing uncertainty in longer-term forecasts.
Special Considerations:
Temporal Correlation: Higher \(\rho\) values create smoother trajectories with more persistence
Stationarity: The AR(1) innovation variance is scaled to maintain stationary marginal distributions
Missing Time Points: If simulating beyond observed data (n_time > T_observed), covariates are recycled or set to zero with appropriate warnings
Limitations:
As with simulate.ame, multiplicative effects use posterior means unless the fit retained compatible latent-factor draws. Storing complete MCMC chains for \(u_{i,t}, v_{j,t}\) at all time points is memory-intensive for large networks and long time series.
# \donttest{
# Create simple longitudinal network data
set.seed(1)
n <- 10
nms <- paste0("n", 1:n)
Y_list <- list(
matrix(rnorm(n * n), n, n, dimnames = list(nms, nms)),
matrix(rnorm(n * n), n, n, dimnames = list(nms, nms))
)
diag(Y_list[[1]]) <- diag(Y_list[[2]]) <- NA
fit <- lame(Y_list, family = "normal",
nscan = 50, burn = 10, odens = 1, verbose = FALSE, plot = FALSE)
# Simulate 10 network trajectories from posterior
sims <- simulate(fit, nsim = 10)
# }
Run the code above in your browser using DataLab