remulateTie | R Documentation |
A function to simulate relational event data by sampling from a tie-oriented relational event model.
remulateTie(
effects,
actors,
endTime,
events = NULL,
startTime = 0,
initial = 0,
riskset = NULL,
memory = c("full", "window", "window_m", "decay"),
memoryParam = NULL
)
effects |
A |
actors |
A numeric or character vector representing the actor names. |
endTime |
A numeric value specifying the end time up to which the network should be simulated. |
events |
[Optional] An integer specifying the maximum number of events to simulate. |
startTime |
[Optional] A numeric value (default = 0) indicating the time at which the simulation should start. |
initial |
[Optional] A numeric or |
riskset |
[Optional] A |
memory |
[Optional] A string (default = "full") specifying the memory type used for computing statistics. '"full"' uses the entire event history. '"window"' considers only events occurring within a specified time window. '"window_m"' considers only a specified number of most recent events. '"decay"' applies an exponential decay, where older events contribute less based on elapsed time. |
memoryParam |
[Optional] A numeric value (> 0) defining the memory parameter based on the selected memory type. ‘"window"' defines the length of the time window. '"window_m"' specifies the number of past events to consider. '"decay"' represents the half-life (i.e., time until an event’s weight is reduced to half). |
If time is irrelevant and only a specific number of events are desired, set time to Inf. If both time and events are supplied then the function stops simulating whenever the first stop condition is met
If effects is a 'remstimate'
object, then the params are extracted automatically.
Furthermore if exogenous statistics are used, the data.frames corresponding to
the 'attr_actors' argument of the 'remstats'
formula must be loaded in the environment.
A list of available statistics. See remulateTieEffects for details:
baseline(param)
send()
receive()
dyad()
same()
difference()
average()
minimum()
maximum()
inertia()
reciprocity()
tie()
indegreeSender()
indegreeReceiver()
outdegreeSender()
outdegreeReceiver()
totaldegreeSender()
totaldegreeReceiver()
otp()
itp()
osp()
isp()
psABBA()
psABBY()
psABXA()
psABXB()
psABXY()
psABAY()
recencyContinue()
recencySendSender()
recencySendReceiver()
recencyReceiveSender()
recencyReceiveReceiver()
rrankSend()
rrankReceive()
interact()
An object of class "remulateTie"
. A data.frame containing the simulated event sequence with columns (time, sender, receiver).
The "remulateTie"
object has the following attributes:
An array with dimensions M x D x P
, where M
is the number of events,
D
is the number of dyads in the risk set, and P
is the number of computed statistics.
A matrix
containing the event list with columns (dyad, time),
where dyad
represents the index of the (sender, receiver) pair in the risk set.
A data.frame
mapping the actor names provided by the user
to the integer IDs used in internal computations.
A data.frame
with columns (sender, receiver) containing
the risk set used for dyad indices in the computed statistics and event list.
A A numeric or data.frame
object representing the network initialization,
which can be a number of random initialization events or
a data.frame
specifying pre-existing ties.
A formula
object specifying the effects included in the model.
A numeric value indicating the density of the generated network,
defined as the number of observed ties divided by N*(N-1)
, where
N
is the number of actors.
Lakdawala, R., Mulder, J., & Leenders, R. (2025). *Simulating Relational Event Histories: Why and How*. arXiv:2403.19329.
# To generate events up to time '50' in a network of 25 actors with
# 200 random initial events
# Exogenous attributes data.frame
cov <- data.frame(
id = 1:25,
time = rep(0, 25),
sex = sample(c(0, 1), 25, replace = TRUE, prob = c(0.4, 0.6)),
age = sample(20:30, 25, replace = TRUE)
)
#Effects specification
effects <- ~ remulate::baseline(-5) +
remulate::inertia(0.01) +
remulate::reciprocity(-0.04) +
remulate::itp(0.01, scaling = "std") +
remulate::same(0.02, variable = "sex", attr_actors = cov) +
remulate::interact(0.01, indices = c(2, 5))
# Calling remulateTie
remulate::remulateTie(
effects,
actors = 1:25,
endTime = 50,
events = 500,
initial = 200
)
# To predict events, given an edgelist of initial events
initialREH <- data.frame(
time = seq(0.5, 100, 0.5),
sender = sample(1:25, 200, TRUE),
receiver = sample(1:25, 200, TRUE)
)
remulate::remulateTie(
effects,
actors = 1:25,
endTime = 150,
events = 500,
initial = initialREH
)
# Custom risk set
rs <- as.matrix(expand.grid(1:25, 1:25))
rs <- rs[rs[, 1] != rs[, 2], ]
custom_rs <- rs[sample(1:90, 50), ]
remulate::remulateTie(
effects,
actors = 1:25,
endTime = 150,
events = 500,
riskset = custom_rs
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.