Simulate a Relational Event History (REH)
generate_reh.RdThis function simulates a sequence of relational events based on a specified statistical model derived from a relational event model (REM). It uses covariates, a list of parameters, and the number of events to generate a relational event history (REH) with associated statistics.
Arguments
- parameters
A named list of parameters for the model. Each parameter represents a specific effect or term in the tie-oriented model (e.g.,
send_z1,difference_z2,inertia). The parameter names must align with those supported byremreg::generate_formula().- covar
A data frame of covariates containing at least the following columns:
name: Numeric or character identifiers for actors.z1: A numeric covariate representing some attribute of the actors.z2: A numeric covariate representing another attribute of the actors.time: The starting time for the simulation (default is usually0). Each row represents an actor in the network.
- M
An integer specifying the number of events to simulate.
- directed
A logical value indicating whether the network is directed (
TRUE) or undirected (FALSE).
Value
A data frame representing the simulated event history. The data frame contains the following columns:
time: The time of each event.actor1: The identifier of the first actor involved in the event.actor2: The identifier of the second actor involved in the event.
Details
The generate_reh() function simulates a series of relational events using the
specified model parameters and covariates. The simulation is based on a relational
event model (REM), a statistical framework for modeling and analyzing dynamic interactions
between actors over time.
It performs the following steps:
Formula Generation: The function uses
remreg::generate_formula()to create a formula for thetie_effectsargument ofremstats::remstats().Initialization: A dummy first event is created to initialize the simulation.
Simulation Loop: For each event:
The model parameters are applied to compute the event rates.
A new event is sampled based on the computed rates.
The event is added to the event history, and the model is updated.
Endogeneity Updates: The function computes endogeneity statistics for subsequent events using
remstats::remstats().
Standardization: All effects that allow scaling are standardized by default
(scaling = 'std'), ensuring consistent computation of statistics.
Note
This function is inspired by the work presented in the article:
Lakdawala, R., Mulder, J., & Leenders, R. (2024). Simulating Relational Event Histories–Why and How. arXiv preprint arXiv:2403.19329.
References
Lakdawala, R., Mulder, J., & Leenders, R. (2024). Simulating Relational Event Histories–Why and How. arXiv preprint arXiv:2403.19329.
See also
remstats::remstats() for calculating statistics for tie-oriented models.
generate_formula() for generating the formula used in this function.
Examples
# Define parameters
parameters <- list(
baseline = -5,
send_z1 = 0.5,
difference_z2 = 0.2,
inertia = 0.3
)
# Create covariate data
covar <- data.frame(
name = 1:50, time = 0,
z1 = rnorm(n = 50, mean = 0, sd = 1),
z2 = rnorm(n = 50, mean = 0, sd = 1)
)
# Simulate 10 events
events <- generate_reh(parameters, covar, M = 10, directed = TRUE)
#> 1
2
3
4
5
6
7
8
9
10
print(events$edgelist)
#> time actor1 actor2
#> 1 0.02037744 3 37
#> 2 0.02038913 3 37
#> 3 0.02041367 3 37
#> 4 0.02043817 3 37
#> 5 0.02048893 3 37
#> 6 0.02066064 3 37
#> 7 0.02070345 3 37
#> 8 0.02071180 3 37
#> 9 0.02076789 3 37
#> 10 0.02078205 3 37