simulateRESeq: Simulate a Random One-Mode Relational Event Sequence

View source: R/rem_simulate.R

simulateRESeqR Documentation

Simulate a Random One-Mode Relational Event Sequence

Description

The function allows users to simulate a random one-mode relational event sequence between n actors for k events. Importantly, this function follows the methods discussed in Butts (2008), Amati, Lomi, and Snijders (2024), and Scheter and Quintane (2021). See the details for more information on this algorithm. Critically, this function can be used to simulate a random event sequence, to assess the goodness of fit for ordinal timing relational event models (see Amati, Lomi, and Snijders 2024), and simulate random outcomes for relational outcome models.

Usage

simulateRESeq(
  n_actors,
  n_events,
  inertia = FALSE,
  inertia_p = 0,
  recip = FALSE,
  recip_p = 0,
  sender_outdegree = FALSE,
  sender_outdegree_p = 0,
  sender_indegree = FALSE,
  sender_indegree_p = 0,
  target_outdegree = FALSE,
  target_outdegree_p = 0,
  target_indegree = FALSE,
  target_indegree_p = 0,
  assort = FALSE,
  assort_p = 0,
  trans_trips = FALSE,
  trans_trips_p = 0,
  three_cycles = FALSE,
  three_cycles_p = 0,
  starting_events = NULL,
  returnStats = FALSE
)

Arguments

n_actors

The number of potential actors in the event sequence.

n_events

The number of simulated events for the relational event sequence.

inertia

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

inertia_p

If inertia = TRUE, the numerical value that corresponds to the parameter weight for the inertia statistic.

recip

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

recip_p

If recip = TRUE, the numerical value that corresponds to the parameter weight for the reciprocity statistic.

sender_outdegree

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

sender_outdegree_p

If sender_outdegree = TRUE, the numerical value that corresponds to the parameter weight for the outdegree statistic.

sender_indegree

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

sender_indegree_p

If sender_indegree = TRUE, the numerical value that corresponds to the parameter weight for the indegree statistic.

target_outdegree

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

target_outdegree_p

If target_outdegree = TRUE, the numerical value that corresponds to the parameter weight for the outdegree statistic.

target_indegree

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

target_indegree_p

If target_indegree = TRUE, the numerical value that corresponds to the parameter weight for the indegree statistic.

assort

Boolean. TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

assort_p

If assort = TRUE, the numerical value that corresponds to the parameter weight for the assortativity statistic.

trans_trips

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

trans_trips_p

If trans_trips = TRUE, the numerical value that corresponds to the parameter weight for the transitive triplets statistic.

three_cycles

TRUE/FALSE. True indicates the effect will be included (see the details section). FALSE indicates the effect will not be included.

three_cycles_p

If three_cycles = TRUE, the numerical value that corresponds to the parameter weight for the three cycles statistic.

starting_events

A n x 2 dataframe with n starting events and 2 columns. The first column should be the sender and the second should be the target.

returnStats

TRUE/FALSE. TRUE indicates that the requested network statistics will be returned alongside the simulated relational event sequence. FALSE indicates that only the simulated relational event sequence will be returned. Set to FALSE by default.

Details

Following the authors listed in the descriptions section, the probability of selecting a new event for t+1 based on the past relational history, H_{t}, from 0<t<t+1 is given by:

p(e_{t}) = \frac{\lambda{ij}(t;\theta)}{\sum_{(u,v)\in R_{t}} \lambda_{uv}(t;\theta)}

where (i,j,t) is the triplet that corresponds to the dyadic pair with sender i and target j at time t contained in the full risk set, R_{t}, based on the past relational history. \lambda_{ij}(t;\theta) is formulated as:

\lambda_{ij}(t;\theta) = e^{\sum_{p}\theta_{p} X_{ijp}(H_{t})}

where \theta_{p} corresponds to the specific parameter weight given by the user, and X_{ijp} represents the value of the specific statistic based on the current past relational history H_{t}.

Following Scheter and Quintane (2021) and Amati, Lomi, and Snijders (2024), the algorithm for simulating the random relational sequence for k events is:

  • 1. Initialize the full risk set, R_{t}, which is the full Cartesian plot of actors.

  • 2. Randomly sample the first event e_{1} and add that event into the relational history, H_{t}.

  • 3. Until i = k, compute the sufficient statistics for each event in the risk set, sample a new event e_{i} based on the probability function specified above, and add that element into the relational history.

  • 4. End when i > k.

Currently, the function supports 6 statistics for one-mode networks. These are:

  • Inertia: {n}_{ijt}

  • Reciprocity: {n}_{jit}

  • Target Indegree: \sum_{k} {n}_{kjt}

  • Target Outdegree: \sum_{k} {n}_{jkt}

  • Sender Outdegree: \sum_{k} {n}_{ikt}

  • Sender Indegree: \sum_{k} {n}_{kit}

  • Assortativity: \sum_{k} {n}_{kit} \cdot \sum_{k} {n}_{ikt}

  • Transitive Triplets: \sum_{k} {n}_{ikt} \cdot {n}_{kjt}

  • Three Cycles: \sum_{k} {n}_{jkt} \cdot {n}_{kit}

Where n represents the counts of past events, i is the event sender, and j is the event target. See Scheter and Quintane (2021) and Butts (2008) for a further discussion of these statistics.

Users are allowed to insert a starting event sequence to base the simulation on. A few things are worth nothing. The starting event sequence should be a matrix with n rows indicating the number of starting events and 2 columns, with the first representing the event senders and the second column representing the event targets. Internally, the number of actors is ignored, as the number of possible actors in the risk set is based only on the actors present in the starting event sequence. Finally, the sender and target actor IDs should be numerical values.

Value

A data frame that contains the simulated relational event sequence with the sufficient statistics (if requested).

Author(s)

Kevin A. Carson kacarson@arizona.edu, Diego F. Leal dflc@arizona.edu

References

Amati, Viviana, Alessandro Lomi, and Tom A.B. Snijders. 2024. "A goodness of fit framework for relational event models." Journal of the Royal Statistical Society Series A: Statistics in Society 187(4): 967-988.

Butts, Carter T. "A Relational Framework for Social Action." Sociological Methodology 38: 155-200.

Schecter, Aaron and Eric Quintane. 2021 "The Power, Accuracy, and Precision of the Relational Event Model." Organizational Research Methods 24(4): 802-829.

Examples

#Creating a random relational sequence with 5 actors and 25 events
rem1<- simulateRESeq(n_actors = 25,
                     n_events = 1000,
                     inertia = TRUE,
                     inertia_p = 0.12,
                     recip = TRUE,
                     recip_p = 0.08,
                     sender_outdegree = TRUE,
                     sender_outdegree_p = 0.09,
                     target_indegree = TRUE,
                     target_indegree_p = 0.05,
                     assort = TRUE,
                     assort_p = -0.01,
                     trans_trips = TRUE,
                     trans_trips_p = 0.09,
                     three_cycles = TRUE,
                     three_cycles_p = 0.04,
                     starting_events = NULL,
                     returnStats = TRUE)
rem1

#Creating a random relational sequence with 100 actors and 1000 events with
#only inertia and reciprocity
rem2 <- simulateRESeq(n_actors = 100,
                     n_events = 1000,
                     inertia = TRUE,
                     inertia_p = 0.12,
                     recip = TRUE,
                     recip_p = 0.08,
                     returnStats = TRUE)
rem2

#Creating a random relational sequence based on the starting sequence with
#only inertia and reciprocity
rem3 <- simulateRESeq(n_actors = 100, #does not matter can be any value, this is
                                    #overridden by the starting event sequence
                    n_events = 100,
                    inertia = TRUE,
                    inertia_p = 0.12,
                    recip = TRUE,
                    recip_p = 0.08,
                    #a random starting event sequence
                    starting_events = matrix(c(1:10, 10:1),
                    nrow = 10, ncol = 2,  byrow = FALSE),
                    returnStats = TRUE)
rem3

dream documentation built on Aug. 8, 2025, 6:36 p.m.

Related to simulateRESeq in dream...