remify: Process a Relational Event History

View source: R/remify2.R

remifyR Documentation

Process a Relational Event History

Description

A function that processes raw relational event history data and returns a S3 object of class 'remify' which is used as input in other functions inside 'remverse'.

Usage

remify(
  edgelist,
  directed = TRUE,
  ordinal = FALSE,
  model = c("tie", "actor"),
  actors = NULL,
  riskset = c("full", "active", "active_saturated", "manual"),
  manual_riskset = NULL,
  extend_riskset_by_type = FALSE,
  event_type = NULL,
  event_weight = NULL,
  origin = NULL,
  time_units = c("auto", "secs", "mins", "hours", "days", "weeks", "months", "years"),
  aggregate_time = 1,
  attach_riskset = TRUE,
  riskset_decode = c("labels", "ids", "none"),
  riskset_max_decode = 200000L,
  event_attributes = NULL,
  ncores = 1L,
  duration = FALSE,
  dur_directed_end = FALSE,
  dur_type_exclusive = FALSE
)

Arguments

edgelist

the relational event history. An object of class data.frame with first three columns corresponding to time, and actors forming the dyad. The first three columns will be re-named "time", "actor1", "actor2" (where, for directed networks, "actor1" corresponds to the sender and "actor2" to the receiver of the relational event). Optional columns that can be supplied are: 'type' and 'weight'. If one or both exist in edgelist, they have to be named accordingly.

directed

logical value indicating whether events are directed (TRUE) or undirected (FALSE). (default value is TRUE)

ordinal

logical value indicating whether only the order of events matters in the model (TRUE) or also the exact timing must be considered in the model (FALSE). (default value is FALSE). If TRUE, then the column "time" of edgelist is still used to extract the order.

model

either "tie" (default) or "actor" oriented modeling. For "tie", the riskset is at the dyad level. For "actor", the model has two sub-processes: a sender rate model (who sends next?) and a receiver choice model (who does the sender choose?). Actor-oriented modeling requires directed=TRUE. The returned object includes sender_riskset, receiver_riskset, and activeN (see @return).

actors

[optional] character vector of actors' names that may be observed interacting in the network. If NULL (default), actors' names will be taken from the input edgelist.

riskset

[optional] character value indicating the type of risk set to process: riskset = "full" (default) consists of all the possible dyadic events given the number of actors (and the number of event types) and it mantains the same structure over time. riskset = "active" considers at risk only the observed dyads and it mantains the same structure over time. riskset = "manual", allows the risk set to have a structure that is user-defined, and it is based on the instructions supplied via the argument manual_riskset. riskset = "active_saturated" extends the active riskset by adding the reverse direction for each observed dyad (if A->B is observed, B->A is also at risk) and includes all event types for each observed actor pair (type column is ignored). This reflects the assumption that observing any interaction between two actors implies both directions and all types are possible.

manual_riskset

[optional] When riskset = "manual", this argument of class data.frame specifies which dyadic riskset to consider through the entire sequence. If observed dyads from the edgelist are missing, they will be automatically be added.

extend_riskset_by_type

logical. FALSE (default). When event types are present (via event_type), controls whether the risk set is expanded over types. If TRUE (default when types are present), each actor pair is duplicated for each event type, so the risk set has size D = N(N-1) \times C (directed) or D = N(N-1)/2 \times C (undirected), and the type column appears in the decoded risk set. If FALSE, event type is treated as a mark on events only and does not expand the risk set: D = N(N-1) (directed) or D = N(N-1)/2 (undirected), and no type column appears in the decoded risk set. This argument is ignored when no event types are present.

event_type

Optional. Either NULL (default) or a single character string giving the name of the column in edgelist that contains event types (marks).

If event_type is NULL, remify() uses edgelist$type if it exists; otherwise events are treated as untyped.

If event_type is a column name, that column is used as the event-type mark. If a column named type already exists and event_type != "type", the existing edgelist$type is overridden (with a warning).

When event types are present (via edgelist$type or event_type), the dyadic risk set is extended over types, i.e., each dyad is duplicated for each event type (dyad \times type).

event_weight

Optional. Either NULL (default) or a single character string giving the name of the column in edgelist that contains event weights.

If event_weight is NULL, remify() uses edgelist$weight if it exists; otherwise events are treated as unweighted (uniform weight = 1).

If event_weight is a column name, that column is used as the event weight. If a column named weight already exists and event_weight != "weight", the existing edgelist$weight is overridden (with a warning). This argument behaves analogously to event_type and applies to both standard and duration (duration = TRUE) models.

origin

[optional] starting time point of the observation period (default is NULL). If it is supplied, it must have the same class of the 'time' column in the input edgelist. If unsupplied, the origin is set to the average waiting time in the sequence subtracted from the time of the first event.

time_units

Character string specifying the time unit for converting time values when 'edgelist$time' is of class Date or POSIXct; ignored for numeric or integer time. Default is "secs".

aggregate_time

Integer >= 1. Event-time aggregated based on unique time points. Keeps every aggregate_time-th unique event time (after time translation) and maps each event time to the next kept time point (i.e., ceiling to the kept grid). This reduces the number of unique time points (and thus memory/computation in later steps).

attach_riskset

Logical. If TRUE, attaches a list riskset_info to the returned remify object. The list contains the effective risk set representation used for estimation (e.g., riskset_idx, dyadIDactive, dictionaries, and basic risk set metadata). This is intended to make the returned object self-describing and easier to inspect/debug.

riskset_decode

Character. Controls how (and whether) the included risk set dyads are decoded and attached in riskset_info$included.

"labels"

Attach a decoded dyad table including actor (and type) labels (e.g., actor1, actor2, and optional type).

"ids"

Attach a decoded dyad table with integer IDs only (e.g., actor1ID, actor2ID, optional typeID, and dyadID).

"none"

Do not attach a decoded dyad table.

riskset_max_decode

Integer. Maximum number of included dyads (i.e., length(riskset_idx) / D_active) for which riskset_decode="labels" is allowed. If the included risk set exceeds this threshold, decoding to labels is skipped (typically falling back to "ids" with a warning) to avoid large memory usage.

event_attributes

Optional character vector of column names in edgelist to retain as additional event-level variables in the returned reh object.

These columns are stored as reh$event_attributes together with the corresponding time, actor1, and actor2 columns (and an internal .event_id). This is useful when downstream functions (e.g., in remstats) need access to event-level marks/attributes/covariates that are not part of the core reh$edgelist produced by remify().

Note: event_attributes does not affect risk set construction or type handling in remify(); it only preserves additional columns for later use. Currently there is no further support yet when event_attributes have been added.

ncores

[optional] number of cores used in the parallelization of the processing functions. (default is 1).

duration

Logical. If TRUE, the edgelist is treated as a duration edgelist (each event has both a start time and an end time) and a remify_durem object is returned instead of a standard remify object. The edgelist must contain an end column (or end_time / duration as alternatives; see .durem_normalize_edgelist). Default FALSE.

dur_directed_end

Logical. Only used when duration = TRUE. If FALSE (default), the end process is undirected: either actor can terminate the event and only a combined dyad-level end rate is modelled. If TRUE, the end process is directed: a who_ended column in the edgelist ("actor1" / "actor2" / NA) records which actor terminated each event, enabling actor-level end-rate models. When who_ended is absent and dur_directed_end = TRUE, actor1 is assumed to terminate all events and a message is issued.

dur_type_exclusive

Logical. Only used when duration = TRUE, when typed events are present and when extend_riskset_by_type = TRUE. If TRUE, an active event of any type is a hard block on starting events of all other types for the same dyad (e.g. two actors cannot start a text conversation while already in a face-to-face conversation). If FALSE (default), types are treated as independent processes and a dyad can be simultaneously active in events of different types. Has no effect when extend_riskset_by_type = FALSE.

Value

A remify S3 object (list) with the following elements:

  • M number of events (or unique time points if simultaneous events exist).

  • N number of actors.

  • C number of event types (1 if untyped).

  • D number of dyads in the riskset.

  • intereventTime vector of inter-event waiting times (NULL if ordinal=TRUE).

  • edgelist processed input edgelist as data.frame.

  • edgelist_id per-event integer ID summary.

  • edgelist_dual processed input edgelist with duration as data.frame.

  • meta list of metadata (model, directed, ordinal, riskset, dictionary, etc.).

  • ids list of per-event integer IDs (actor1, actor2, dyad, type).

  • index list of decoded riskset tables (dyad_map or dyad_map_active for tie model; sender_map for actor model).

  • activeD number of active dyads (tie model, riskset="active" or "manual" only).

  • riskset_info decoded riskset metadata (tie model only, when attach_riskset=TRUE).

  • durem list of metadata for events with duration.

For actor-oriented models (model="actor"), the following additional elements are returned:

  • sender_riskset integer vector of actor IDs allowed to send (all actors for "full"; observed senders for "active"; senders in manual_riskset for "manual"/"active_saturated").

  • receiver_riskset named list (actor names) of integer vectors of allowed receiver IDs per sender. Depends on the chosen riskset vie the argument riskset.

  • activeN number of active senders.

  • index\$sender_map data.frame with columns senderID and actorName for active senders.

Examples


# load package and random network 'randomREH'
library(remify)
data(randomREH)

# first events in the sequence
head(randomREH$edgelist)

# actor's names
randomREH$actors

# event type's names
randomREH$types

# start time of the study (origin)
randomREH$origin

# -------------------------------------- #
#  processing for tie-oriented modeling  #
# -------------------------------------- #

tie_randomREH <- remify(edgelist = randomREH$edgelist,
       directed = TRUE,
       ordinal = FALSE,
       model = "tie",
       origin = randomREH$origin)

# summary
summary(tie_randomREH)

# visualize descriptive measures of relational event data
plot(x = tie_randomREH)

# -------------------------------------- #
# processing for actor-oriented modeling #
# -------------------------------------- #

# loading network 'randomREHsmall'
data(randomREHsmall)

# processing small random network
actor_randomREH <- remify(edgelist = randomREHsmall$edgelist,
       directed = TRUE,
       ordinal = FALSE,
       model = "actor",
       actors = randomREHsmall$actors,
       origin = randomREHsmall$origin)

# summary
summary(actor_randomREH)

# visualize
plot(actor_randomREH)

# ------------------------------------ #
# for more information about remify()  #
# check: vignette(package="remify")    #
# ------------------------------------ #



remify documentation built on July 13, 2026, 5:08 p.m.