Package {remstats}


Type: Package
Title: Computes Statistics for Relational Event History Data
Version: 4.1.0
Date: 2026-07-15
Maintainer: Joris Mulder <j.mulder3@tilburguniversity.edu>
Description: Computes a variety of statistics for relational event models (Meijerink et al., 2022, <doi:10.3758/s13428-022-01821-8>). Relational event models enable researchers to investigate exogenous and endogenous factors, and interactions, influencing the evolution of a time-ordered sequence of events. These models are categorized into tie-oriented models (Butts, C., 2008, <doi:10.1111/j.1467-9531.2008.00203.x>), where the probability of a dyad interacting next is modeled in a single step, and actor-oriented models (Stadtfeld, C., & Block, P., 2017, <doi:10.15195/v4.a14>), which first model the probability of a sender initiating an interaction and subsequently the probability of the sender's choice of receiver. The package is designed to compute a variety of statistics that summarize exogenous and endogenous influences on the event stream for both types of models.
License: MIT + file LICENSE
URL: https://tilburgnetworkgroup.github.io/remstats/
BugReports: https://github.com/TilburgNetworkGroup/remstats/issues
LazyData: true
Encoding: UTF-8
RoxygenNote: 7.3.3
Depends: R (≥ 4.0.0), remify (≥ 4.1.0)
Imports: Rcpp (≥ 1.0.8.3), stats, graphics, grDevices
LinkingTo: Rcpp, RcppArmadillo, RcppProgress
Suggests: tinytest, knitr, rmarkdown, remdata
VignetteBuilder: knitr
LazyDataCompression: gzip
NeedsCompilation: yes
Packaged: 2026-07-15 10:06:07 UTC; jorismulder
Author: Giuseppe Arena ORCID iD [aut], Marlyne Meijerink-Bosman [aut], Joris Mulder [aut, cre], Diana Karimova [ctb], Rumana Lakdawala [ctb], Mahdi Shafiee Kamalabad [ctb], Fabio Generoso Vieira [ctb], Roger Leenders [ctb]
Repository: CRAN
Date/Publication: 2026-07-15 12:20:02 UTC

Build the riskset matrix for active-state stats

Description

Uses the exported C++ helpers get_riskset and convert_to_risksetMatrix with 0-based actor IDs, matching the convention used internally by tomstats.

Usage

.build_riskset_matrix(N, directed, C = 1L)

Arguments

N

Number of actors.

directed

Logical.

C

Number of event types (default 1).

Value

Numeric matrix of dyad IDs (0-based, -999 for absent dyads). Dimensions N × N when C = 1; N*C × N*C when C > 1.


Compute active-state statistics for a single sub-model

Description

Compute active-state statistics for a single sub-model

Usage

.compute_active_stats(
  effect_configs,
  reh,
  directed,
  start,
  stop,
  suffix,
  display_progress
)

Arguments

effect_configs

A list of effect config lists, each with $effect, $scaling, and $consider_type (output of .parse_active_effects).

reh

A remify_durem object.

directed

Logical. Whether the sub-model is directed.

start

First time-point index (0-based).

stop

Last time-point index (0-based).

suffix

".start" or ".end".

display_progress

Logical.

Value

3-D array \[M × D × P\] or NULL if no effects.


Prepend a baseline column of 1s to a 3-D stats array

Description

Checks whether the formula includes an intercept (no -1). If so, prepends a baseline{suffix} slice of 1s along dim 3.

Usage

.maybe_prepend_baseline(arr, formula, suffix)

Arguments

arr

3-D array \[M × D × P\] or NULL.

formula

Formula that produced the array.

suffix

".start" or ".end".

Value

Updated array with P+1 slices, or the original if no intercept.


Evaluate terms in a duremstats formula into effect config lists

Description

Evaluate terms in a duremstats formula into effect config lists

Usage

.parse_active_effects(formula)

Arguments

formula

Formula such as ~ activeTie() + activeOutdegreeSender(scaling = "std")

Value

A list of named lists, each with $effect, $scaling, and $consider_type.


Prepare the dual edgelist for calculate_active_stats

Description

Converts actor names to 0-based integer IDs and status to 0/1. Remify stores actor IDs as 1-based integers; C++ expects 0-based.

Usage

.prepare_dual_edgelist(edgelist_dual, actor_ids)

Arguments

edgelist_dual

The $edgelist_dual data.frame from a remify_durem object.

actor_ids

Named integer vector mapping actor name → 0-based ID.

Value

A numeric matrix with columns [time, actor1_id, actor2_id, status].


Internal remstats dispatch for remify_durem objects

Description

Called by remstats when reh inherits from "remify_durem". Builds a dual-event edgelist (one "start" row and one "end" row per event), applies psi weighting, and calls tomstats twice — once for the start model, once for the end model.

Usage

.remstats_durem(
  reh,
  start_effects = NULL,
  end_effects = NULL,
  psi_start = 1,
  psi_end = 1,
  attr_actors = NULL,
  attr_dyads = NULL,
  memory = c("full", "window", "decay", "interval"),
  memory_value = NA,
  start = 2,
  stop = Inf,
  display_progress = FALSE
)

Arguments

reh

A remify_durem object.

start_effects

Formula for start-model statistics (remstats syntax).

end_effects

Formula for end-model statistics.

psi_start

Numeric. Duration exponent for start-model history weighting. Event weight is w * (end - time + 1)^psi_start. Default 1.

psi_end

Numeric. Duration exponent for end-model history weighting. Default 1.

attr_actors

optionally, an object of class "data.frame" that contains exogenous attributes for actors (see Details).

attr_dyads

optionally, an object of class data.frame or matrix containing attribute information for dyads (see Details).

memory

The memory to be used. See ‘Details’.

memory_value

Numeric value indicating the memory parameter. Default is NA, which is only valid for memory = "full" (no memory parameter required). See ‘Details’.

display_progress

should a progress bar for the computation of the endogenous statistics be shown (TRUE) or not (FALSE)?

Value

A remstats_durem object.


Internal dispatch for remify_durem objects

Description

Called by remstats when reh inherits from "remify_durem". Each formula is inspected term-by-term:

Usage

.remstats_durem_dispatch(
  reh,
  start_effects = NULL,
  end_effects = NULL,
  psi_start = 1,
  psi_end = 1,
  attr_actors = NULL,
  attr_dyads = NULL,
  memory = c("full", "window", "decay", "interval"),
  memory_value = NA,
  start = 2,
  stop = Inf,
  display_progress = FALSE
)

Arguments

reh

A remify_durem object.

start_effects

Formula for start-model statistics.

end_effects

Formula for end-model statistics.

psi_start

Duration exponent for start-model history weighting (forwarded to .remstats_durem; ignored for active-state effects).

psi_end

Duration exponent for end-model history weighting.

attr_actors

Actor-level attribute data frame (forwarded to tomstats; ignored for active-state effects).

attr_dyads

Dyad-level attribute data frame (forwarded to tomstats; ignored for active-state effects).

memory

Memory type forwarded to tomstats.

memory_value

Memory value forwarded to tomstats.

start

First time-point index.

stop

Last time-point index.

display_progress

Logical.

Details

Value

A remstats_durem object.


Normalise and validate consider_type for active-state effects

Description

Accepts TRUE/FALSE aliases: TRUE -> "separate", FALSE -> "ignore".

Usage

.validate_consider_type_durem(consider_type)

Value

The normalised character value.


FEtype

Description

Specifies the statistic for fixed effects for event types in the tie-oriented model.

Usage

FEtype()

Details

Fixed effects for event types capture the variation in event rate across different event types (e.g., see Butts, 2008). The specification of FEtype results in the creation of C-1 statistics, were C is the number of different event types in the riskset. Let one of the event types, e.g. c = 1, represent the reference category. Than, for every event type c = 2, ..., C, a statistic is created that at timepoint t for dyad (i,j,c) is equal to 1 if c is equal to the respective event type and equal to 0 otherwise (i.e., dummy variables are created). Note that specifying fixed effects for event types is only available when event types are modeled in the dependent variable.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

event

Examples

history$type <- history$setting
reh_tie <- remify::remify(history, model = "tie")
effects <- ~ FEtype()
remstats(reh = reh_tie, tie_effects = effects)


Active-state statistics for Duration Relational Event Models

Description

Constructor functions for active-state effects used inside formulas passed to remstats (when reh is a remify_durem object). They capture properties of the currently active event network — events that have started but not yet ended — at each time point in a duration relational event sequence.

Usage

activeTie(scaling = c("none", "std"), consider_type = "ignore")

activeReciprocalTie(scaling = c("none", "std"), consider_type = "ignore")

activeOutdegreeSender(scaling = c("none", "std"), consider_type = "ignore")

activeIndegreeReceiver(scaling = c("none", "std"), consider_type = "ignore")

activeTotaldegreeSender(scaling = c("none", "std"), consider_type = "ignore")

activeTotaldegreeReceiver(scaling = c("none", "std"), consider_type = "ignore")

activeTotaldegreeDyad(scaling = c("none", "std"), consider_type = "ignore")

activeSharedPartners_otp(scaling = c("none", "std"), consider_type = "ignore")

activeSharedPartners_itp(scaling = c("none", "std"), consider_type = "ignore")

activeSharedPartners_osp(scaling = c("none", "std"), consider_type = "ignore")

activeSharedPartners_isp(scaling = c("none", "std"), consider_type = "ignore")

activeDegreeMin(scaling = c("none", "std"), consider_type = "ignore")

activeDegreeMax(scaling = c("none", "std"), consider_type = "ignore")

activeDegreeDyad(scaling = c("none", "std"), consider_type = "ignore")

activeSharedPartners(scaling = c("none", "std"), consider_type = "ignore")

Arguments

scaling

Scaling applied to the raw statistic before returning:

"none"

Raw counts (default).

"std"

Per-time-point standardisation: (x - \bar{x}) / \mathrm{sd}(x), computed over the D dyads in the fixed risk set.

consider_type

Character (or logical). How event types are handled:

"ignore" or FALSE

Aggregate over all event types (default). Counts all currently active events regardless of type.

"separate" or TRUE

Compute one statistic per event type. Only active events of that type contribute. Output effect names are suffixed with the type label, e.g. activeOutdegreeSender.X.start.

"interact"

Compute one statistic per (past-event type x dyad type) combination (C^2 slices). Requires extend_riskset_by_type = TRUE in the remify call; otherwise silently coerced to "separate".

Details

Each function returns a configuration list consumed internally. The functions are passed inside a formula:

  remstats(reh,
    start_effects = ~ activeTie() + activeOutdegreeSender(scaling = "std"),
    end_effects   = ~ activeOutdegreeSender())

Directed-network effects:

activeTie()

Whether there is currently an active event from actor i to actor j (binary, 0/1). Note: in end_effects this is always 1 by definition (only currently active dyads are at risk of ending) and should not be included as a predictor.

activeReciprocalTie()

Whether there is currently an active event from actor j to actor i (binary, 0/1). Captures reciprocity in the active network.

activeOutdegreeSender()

Number of currently active events in which actor i (sender) is involved as sender (out-degree in the active-event network).

activeIndegreeReceiver()

Number of currently active events in which actor j (receiver) is involved as receiver.

activeTotaldegreeSender()

Total active degree of actor i: active events in which i appears as either sender or receiver.

activeTotaldegreeReceiver()

Total active degree of actor j.

activeTotaldegreeDyad()

Sum of the total active degrees of actors i and j: \deg(i) + \deg(j).

activeSharedPartners_otp()

(Advanced) Number of actors h for whom i \to h and h \to j are both currently active (outgoing two-path). Rarely informative when the active network is sparse.

activeSharedPartners_itp()

(Advanced) Incoming two-path: actors h with h \to i and j \to h both active.

activeSharedPartners_osp()

(Advanced) Outgoing shared partners: actors h with i \to h and j \to h both active.

activeSharedPartners_isp()

(Advanced) Incoming shared partners: actors h with h \to i and h \to j both active.

Undirected-network effects:

activeTie()

Whether there is currently an active event between actors i and j. Note: in end_effects this is always 1 by definition and should not be included as a predictor.

activeDegreeMin()

Minimum of the active degrees of i and j: \min(\deg(i), \deg(j)).

activeDegreeMax()

Maximum of the active degrees of i and j: \max(\deg(i), \deg(j)).

activeDegreeDyad()

Sum of the active degrees of i and j: \deg(i) + \deg(j).

activeSharedPartners()

(Advanced) Number of actors h for whom both (i,h) and (j,h) are currently active. Rarely informative when the active network is sparse.

Value

A named list with elements effect, scaling, and consider_type, consumed by duremstats.

See Also

remstats for computing the statistics, and tie_effects / actor_effects for the standard (non-duration) effect overviews. Active-state effects are only available for the tie-oriented model of events with a duration.


actor_effects

Description

Overview of statistics in the actor-oriented model, see Details.

Usage

actor_effects(step = NULL)

Arguments

step

outputs all statistics in the sender activity step (if 'step = sender') or receiver choice step (if 'step = receiver').

Details

Overview of statistics in the actor-oriented model.

A list of available effects and their corresponding statistics for the sender activity rate step:

A list of available effects and their corresponding statistics for the receiver choice step:

Value

Returns a list of available effects and their corresponding statistics based on the specified 'step' (sender or receiver).

See Also

tie_effects for the tie-oriented model. Note that models of events with a duration (and the associated active_effects) are only supported for the tie-oriented model.

Examples

# List of available effects for both the sender and receiver step
actor_effects()

# List of available effects for the sender step
actor_effects(step = "sender")

# List of available effects for the receiver step
actor_effects(step = "receiver")


aomstats

Description

Computes statistics for the sender activity rate step and receiver choice step in actor-oriented relational event models (e.g., see Stadtfeld & Block, 2017).

Usage

aomstats(
  reh,
  sender_effects = NULL,
  receiver_effects = NULL,
  memory = c("full", "window", "decay", "interval"),
  memory_value = NA,
  first = 2,
  last = Inf,
  display_progress = FALSE,
  attr_actors = NULL,
  attr_dyads = NULL
)

Arguments

reh

an object of class "remify" characterizing the relational event history. May also be a remify_durem object for duration relational event models.

sender_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the effects in the sender activity rate step of the actor-oriented model for which statistics are computed, see ‘Details’

receiver_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the effects in the receiver choice step of model for which statistics are computed, see ‘Details’

memory

The memory to be used. See ‘Details’.

memory_value

Numeric value indicating the memory parameter. Default is NA, which is only valid for memory = "full" (no memory parameter required). See ‘Details’.

first

an optional integer value, specifying the index of the first unique time point event in the relational event history for which statistics must be computed (see 'Details'). Default is 2: the first event has no history and is used only to initialize statistics, not to fit the model.

last

an optional integer value, specifying the index of the last unique time point in the relational event history for which statistics must be computed (see 'Details')

display_progress

should a progress bar for the computation of the endogenous statistics be shown (TRUE) or not (FALSE)?

attr_actors

optionally, an object of class "data.frame" that contains exogenous attributes for actors (see Details).

attr_dyads

optionally, an object of class data.frame or matrix containing attribute information for dyads (see Details).

Value

An object of class 'aomstats'. List with in the first element the statistics for the sender activity rate step and in the second element the statistics for the receiver choice step. Statistics are computed once per unique time point (per-timepoint "pt" method), so the number of rows in the output equals reh$M (the number of unique time points), which may be less than the total number of observed events when simultaneous events are present. The 'aomstats' object has the following attributes:

model

Type of model that is estimated.

formula

Model formula(s), obtained from the formula(s) inputted to 'sender_effects' and/or 'receiver_effects'.

actors

The set of actors used to construct the statistics, obtained from the remify object inputted to 'reh'.

Effects

The statistics to be computed are defined symbolically and should be supplied to the sender_effects and/or receiver_effects arguments in the form ~ effects. The terms are separated by + operators. For example: receiver_effects = ~ inertia() + otp(). Interactions between two effects can be included with * or : operators. For example: receivereffects = ~ inertia():otp(). A list of available effects can be obtained with actor_effects().

The majority of the statistics can be scaled in some way, see the documentation of the scaling argument in the separate effect functions for more information on this.

Memory

The default 'memory' setting is '"full"', which implies that at each time point $t$ the entire event history before $t$ is included in the computation of the statistics. Alternatively, when 'memory' is set to '"window"', only the past event history within a given time window is considered (see Mulders & Leenders, 2019). This length of this time window is set by the 'memory_value' parameter. For example, when 'memory_value = 100' and 'memory = "window"', at time point $t$ only the past events that happened at most 100 time units ago are included in the computation of the statistics. A third option is to set 'memory' to '"interval"'. In this case, the past event history within a given time interval is considered. For example, when '"memory_value" = c(50, 100)' and 'memory = "interval"', at time point $t$ only the past events that happened between 50 and 100 time units ago are included in the computation of the statistics. Finally, the fourth option is to set 'memory' to '"decay"'. In this case, the weight of the past event in the computation of the statistics depend on the elapsed time between $t$ and the past event. This weight is determined based on an exponential decay function with half-life parameter 'memory_value' (see Brandes et al., 2009).

Event weights

Note that if the relational event history contains a column that is named “weight”, it is assumed that these affect the endogenous statistics. These affect the computation of all endogenous statistics with a few exceptions that follow logically from their definition (e.g., the recenyContinue statistic does depend on time since the event and not on event weights).

Subset of the relational event history

Optionally, statistics can be computed for a slice of the relational event sequence - but based on the entire history. This is achieved by setting the first and last values equal to the index of the first and last event for which statistics are requested. For example, first = 5 and last = 5 computes the statistics for only the 5th event in the relational event sequence, based on the history that consists of events 1-4.

References

Stadtfeld, C., & Block, P. (2017). Interactions, actors, and time: Dynamic network actor models for relational events. Sociological Science, 4, 318–352. doi:10.15195/v4.a14

Meijerink-Bosman, M., Back, M., Geukes, K., Leenders, R., & Mulder, J. (2023). Discovering trends of social interaction behavior over time: An introduction to relational event modeling: Trends of social interaction. Behavior Research Methods, 55(3), 997-1023. doi:10.3758/s13428-022-01821-8

Examples

library(remstats)

# Load the data
data(history)
data(info)

# Prepare the data
reh <- remify::remify(edgelist = history, model = "actor")

# Define the sender effects
seff <- ~ send("extraversion")

# Define the receiver_effects
reff <- ~ receive("agreeableness") + inertia() + otp()

# Compute the statistics
aomstats(
  reh = reh, sender_effects = seff, receiver_effects = reff,
  attr_actors = info
)


average

Description

Specifies the statistic for an "average" effect in the tie-oriented model or the receiver choice step of the actor-oriented model. An "average" effect refers to an exogenous actor attribute that affects dyad (i,j)'s rate of interacting (tie-oriented model) or actor j's probability of being chosen as a receiver for the event send by the active sender i at time t (actor-oriented model) based on the average of the values of actors i and j on this attribute.

Usage

average(variable, attr_actors = NULL, scaling = c("none", "std"), attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t for dyad (i,j) is equal to the average of the values of actor i and j on the attribute at timepoint t.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ average("extraversion")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects, attr_actors = info)


baseline

Description

Specifies an intercept for the tie-oriented model or the sender activity rate step of the actor-oriented model in the same manner as in lm (see Details).

Details

A baseline effect is automatically specified for the tie-oriented model and the sender activity rate step of the actor-oriented model when the ordinal argument in remstats, tomstats, aomstats is set to FALSE (default) and automatically removed when this argument is set to TRUE. Alternatively, a baseline effect can be explicitly specified by adding '1' to the equation or explicitly removed by adding '-1' to the equation.

The baseline effect refers to the baseline tendency to interact. In the tie-oriented model, the log-inverse of the estimated parameter translates to the average number of observed events per time unit per dyad. In the actor-oriented model, the log-inverse of the estimated parameter translates to the average number of observed events per time unit per actor. The statistic is equal to one for all dyads resp. actors in the riskset at all timepoints.

Examples

reh_tie <- remify::remify(history, model = "tie")
remstats(reh = reh_tie, tie_effects = ~1)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = ~1)

Combine two or more remstats objects

Description

Function to bind any number of remstats objects into one while duplicated statistics in the combined object are removed based on their name.

Usage

bind_remstats(...)

Arguments

...

Any number of remstats objects. All the remstats objects must have matching dimensions, except for the third dimension. Note that duplicated statistics in the combined object are removed based on their name.

Value

statistics array with the combined statistics, where rows refer to time points, columns refer to potential relational event (i.e., potential edges) in the risk set and slices refer to statistics

Examples

library(remstats)

# Load the data
data(history)
data(info)

# Prepare the data
reh <- remify::remify(edgelist = history, model = "actor")

# Obtain two different statistics objects
effects1 <- ~ inertia():receive("extraversion") + otp()
stats1 <- remstats(receiver_effects = effects1, reh = reh, attr_actors = info)
effects2 <- ~ reciprocity()
stats2 <- remstats(receiver_effects = effects2, reh = reh, attr_actors = info)

# Bind the two statistics objects
statsC <- bind_remstats(stats1, stats2)


Exogenous Dyad Attribute in Long Format: both_male_long

Description

A data frame representing exogenous attributes of dyads in a social network in long format. Each row indicates whether a dyad consists of two male actors (sex=0) in the original matrix 'info_both_male_wide'.

Usage

data(both_male_long)

Format

A data frame with the following columns:

actor1

Numeric id of the first actor in the dyad.

actor2

Numeric id of the second actor in the dyad.

both_male

Binary indicator (1 for male-male dyads, 0 otherwise).

Source

Simulated exogenous information on actors in a social network.

See Also

tie for the function using this data, both_male_wide for the data in wide format, and info for an overview of the actor exogenous attributes.

Examples

data(both_male_long)
head(both_male_long)


Exogenous Dyad Attribute Matrix: both_male_wide

Description

A matrix representing exogenous attributes of dyads in a social network. The matrix indicates whether a dyad consists of two male actors (sex=0). Rows and columns correspond to actor IDs, and cells contain binary values (1 for male-male dyads, 0 otherwise).

Usage

data(both_male_wide)

Format

A square matrix with dimensions equal to the number of unique actors.

Source

Simulated exogenous information on actors in a social network.

See Also

tie for the function using this data, both_male_long for the data in long format, and info for an overview of the actor exogenous attributes.

Examples

data(both_male_wide)
print(both_male_wide)


Plotting Relational Event Network Statistics

Description

Generate boxplots for a specified effect in a aomstats object.

Usage

## S3 method for class 'aomstats'
boxplot(
  x,
  effect,
  model,
  by = "timepoints",
  subset = NULL,
  outliers = TRUE,
  ...
)

Arguments

x

An object of class aomstats containing relational event network statistics.

effect

A string specifying the name of the effect in 'x' or an integer indicating the index of the effect to be plotted.

model

A string indicating whether the effect is in the 'sender' model or the 'receiver' model.

by

A string indicating whether the statistic is plotted across 'timepoints' (default) or 'actors'.

subset

An optional vector specifying a subset of timepoints or actors to be used for plotting. Per default, a maximum of 20 unique timepoints or actors are plotted.

outliers

A logical value specifying whether to include outliers in the plot.

...

additional arguments passed to bxp().

Details

This function produces boxplots to visually represent the distribution of a specified effect in a relational event network, as captured by a aomstats object. The 'effect' parameter allows the user to choose a specific effect for visualization, either by providing the effect's name or its index within the 'aomstats' object. The 'model' parameter indicates whether the respective effect is in the 'sender' model or the 'receiver' model. The 'by' parameter determines whether the boxplots are created across different 'timepoints' or 'actors'. At the moment, by 'actors' is only supported for the sender model. Additionally, an optional 'subset' parameter allows the user to focus on specific timepoints or actors. If 'subset' is not specified, a default maximum of 20 unique timepoints or actors are plotted. The 'outliers' argument, when set to TRUE, includes the representation of outliers in the boxplots. If set to FALSE, outliers are omitted from the visualization.

The boxplots are based on the following summary statistics of the data: The box in the middle represents the interquartile range (IQR) between the first (Q1) and third quartile (Q3), and the line inside the box represents the median. The whiskers extend from the box to the minimum and maximum values within 1.5 times the IQR below Q1 or above Q3. Outliers beyond the whiskers are plotted individually.

Examples

library(remstats)
# Load data
data(history)
# Prepare data
reh <- remify::remify(edgelist = history[,1:3], model = "actor")
# Compute effects
stats <- remstats(reh, sender_effects = ~ outdegreeSender())
# Plot the 'outdegreeSender' distribution for 20 timepoints
boxplot(stats, effect = "outdegreeSender", model = "sender")
# Plot the 'inertia' distribution for all 10 actors
boxplot(stats, effect = "outdegreeSender", model = "sender", by = "actors")


Plotting Relational Event Network Statistics Distributions

Description

Generate boxplots for a specified effect in a tomstats object.

Usage

## S3 method for class 'tomstats'
boxplot(x, effect, by = "timepoints", subset = NULL, outliers = TRUE, ...)

Arguments

x

An object of class tomstats containing relational event network statistics.

effect

A character string specifying the name of the effect in 'x' or an integer indicating the index of the effect to be plotted.

by

A string indicating whether the statistic is plotted across 'timepoints' (default) or 'dyads'.

subset

An optional vector specifying a subset of timepoints or dyads to be used for plotting. Per default, a maximum of 20 unique timepoints or dyads are plotted.

outliers

A logical value specifying whether to include outliers in the plot.

...

Additional arguments passed to bxp().

Details

This function produces boxplots to visually represent the distribution of a specified effect in a relational event network, as captured by a tomstats object. The 'effect' parameter allows the user to choose a specific effect for visualization, either by providing the effect's name or its index within the 'tomstats' object. The 'by' parameter determines whether the boxplots are created across different 'timepoints' or 'dyads'. Additionally, an optional 'subset' parameter allows the user to focus on specific timepoints or dyads. If 'subset' is not specified, a default maximum of 20 unique timepoints or dyads are plotted. The 'outliers' argument, when set to TRUE, includes the representation of outliers in the boxplots. If set to FALSE, outliers are omitted from the visualization.

The boxplots are based on the following summary statistics of the data: The box in the middle represents the interquartile range (IQR) between the first (Q1) and third quartile (Q3), and the line inside the box represents the median. The whiskers extend from the box to the minimum and maximum values within 1.5 times the IQR below Q1 or above Q3. Outliers beyond the whiskers are plotted individually.

Value

no return value

Examples

library(remstats)
# Load data
data(history)
# Prepare data
reh <- remify::remify(edgelist = history[,1:3], model = "tie")
# Compute effects
stats <- remstats(reh, tie_effects = ~ inertia())
# Plot the 'inertia' distribution for 20 timepoints
boxplot(stats, effect = "inertia")
# Plot the 'inertia' distribution for 20 dyads
boxplot(stats, effect = "inertia", by = "dyads")
# Plot the 'inertia' distribution for dyads 2:5
boxplot(stats, effect = "inertia", by = "dyads", subset = 2:5)


degreeDiff

Description

Specifies the statistic for a 'degreeDiff' effect in the tie-oriented model.

Usage

degreeDiff(scaling = c("none", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, standardization of the degree difference per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

A degreeDiff effect refers to the tendency for dyads to increase their interaction rate if the absolute difference in degree for the two actors in the pair increases. The statistic at timepoint t for dyad (i,j) is equal to the difference between the following two values: the number of events before timepoint t that involved actor i and actor j, respectively. The degreeDiff effect is only defined for undirected events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

degreeMin, degreeMax or totaldegreeDyad for other types of degree effects for undirected events.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ degreeDiff()
remstats(reh = reh_tie, tie_effects = effects)


degreeMax

Description

Specifies the statistic for an 'degreeMax' effect in the tie-oriented model with undirected events.

Usage

degreeMax(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by two times the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An degreeMax effect refers to the tendency for dyads to increase their interaction rate if the total degree of the most active actor in the pair increases. The statistic at timepoint t for dyad (i,j) is equal to the maximum of the following two values: the number of events before timepoint t that involved actor i and actor j, respectively. Note that the degreeMax effect is only defined for undirected events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that the most active actor was involved in. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to be involved in an event and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

degreeDiff, degreeMin or totaldegreeDyad for other types of degree effects for undirected events.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ degreeMax()
remstats(reh = reh_tie, tie_effects = effects)


degreeMin

Description

Specifies the statistic for an 'degreeMin' effect in the tie-oriented model with undirected events.

Usage

degreeMin(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by two times the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An degreeMin effect refers to the tendency for dyads to increase their interaction rate if the total degree of the least active actor in the pair increases. The statistic at timepoint t for dyad (i,j) is equal to the minimum of the following two values: the number of events before timepoint t that involved actor i and actor j, respectively. Note that the degreeMin effect is only defined for undirected events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that the least active actor was involved in. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to be involved in an event and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

degreeDiff, degreeMax or totaldegreeDyad for other types of degree effects for undirected events.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ degreeMin()
remstats(reh = reh_tie, tie_effects = effects)


difference

Description

Specifies the statistic for a "difference" effect in the tie-oriented model or the receiver choice step of the actor-oriented model. A difference effect refers to an exogenous actor attribute that affects dyad (i,j)'s rate of interacting (tie-oriented model) or actor j's probability of being chosen as a receiver for the event send by the active sender i at time t (actor-oriented model) based on the difference between the values of actors i and j on this attribute.

Usage

difference(
  variable,
  attr_actors = NULL,
  scaling = c("none", "std"),
  absolute = TRUE,
  attr_data
)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

absolute

Logical value indicating whether the difference values should be converted to the absolute difference (default is TRUE).

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t is equal to the (absolute) difference between the values of actor i and j on the attribute at timepoint t.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

# Example for tie-oriented model
reh_tie <- remify::remify(history, model = "tie")
effects <- ~ difference("extraversion", absolute = TRUE)
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)

# Example for actor-oriented model
reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects, attr_actors = info)


Compute active-state statistics for a remify_durem object

Description

Computes statistics that capture the current state of the active event network at each time point. These complement the history-weighted statistics returned by remstats and cannot be derived from weighted event history alone.

Usage

duremstats(
  reh,
  start_effects = NULL,
  end_effects = NULL,
  start = 2L,
  stop = Inf,
  display_progress = FALSE
)

Arguments

reh

A remify_durem object.

start_effects

Formula of active-state effects for the start model, e.g. ~ activeTie() + activeOutdegreeSender().

end_effects

Formula of active-state effects for the end model.

start

Integer. Index of first time point to compute (default 2).

stop

Integer. Index of last time point to compute (default Inf).

display_progress

Logical. Show progress messages.

Details

See active_effects for the full list of available effects and their descriptions.

Value

A list with $start_stats and $end_stats: 3-D arrays \[M x D x P\] with effect names suffixed .start / .end, and attr(., "reh") set to reh. The same shape as a remstats_durem object so the two can be combined at estimation time.


event

Description

Specifies the statistic for an "event" effect in the tie-oriented model. An "event" effect refers to an exogenous event attribute that affects the waiting time between events.

Usage

event(variable, event_attr)

Arguments

variable

string with the name of the column in the event_attr object for which the statistic has to be computed.

event_attr

an object of class data.frame that contains the attribute

Details

Because the statistics array is indexed by unique timepoint rather than by event, multiple events occurring at the same time must be collapsed to a single value; the average of the event attribute is taken over these events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

FEtype

Examples


  reh_tie <- remify::remify(history, model = "tie", event_attr = "setting")
  data(history, package = "remstats")
  history$work <- ifelse(history$setting == "work", 1, 0)
  effects <- ~ event("work", event_attr = history)
  remstats(reh = reh_tie, tie_effects = effects)



Simulated relational event history

Description

A dataset containing a small example of a relational event history. Data is simulated.

Usage

data(history)

Format

A dataframe with 115 rows and 5 variables:

time

time of the event since onset of observation (e.g., in minutes)

actor1

the first actor involved in the event

actor2

the second actor involved in the event

setting

the setting for the event

weight

the intensity of the event (e.g., based on the duration)

Source

Simulated relational event history for actors in a social network.

See Also

info for exogenous information on the actors in the social network.

Examples

data(history)


indegreeReceiver

Description

Specifies the statistic for an 'indegreeReceiver' effect in the tie-oriented model or the receiver choice step of the actor-oriented model.

Usage

indegreeReceiver(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An indegree of the receiver effect refers to the tendency for actors to receive events if they have received more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or receiver j (actor-oriented model) is equal to the number of events received by actor j before timepoint t. Note that the 'indegreeReceiver' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that were received by actor j. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to receive a message and the statistic is set equal to 1/ n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeSender, outdegreeSender, outdegreeReceiver, totaldegreeSender, or totaldegreeReceiver for other types of degree effects.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ indegreeReceiver()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


indegreeSender

Description

Specifies the statistic for an 'indegreeSender' effect in the tie-oriented model or the sender activity rate step of the actor-oriented model.

Usage

indegreeSender(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An indegree of the sender effect refers to the tendency for actors to send events if they have received more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or sender i (actor-oriented model) is equal to the number of events received by actor i before timepoint t. Note that the 'indegreeSender' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that were received by actor i. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to send a message and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeReceiver, outdegreeSender, outdegreeReceiver, totaldegreeSender, or totaldegreeReceiver for other types of degree effects.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ indegreeSender()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = effects)


inertia

Description

Specifies the statistic for an inertia effect in the tie-oriented model or the receiver choice step of the actor-oriented model.

Usage

inertia(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the inertia statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, the statistics can be scaled by specifying 'prop', in which raw counts are divided by the outdegree of the sender at time t (see 'details') or standardization of the raw counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An inertia effect refers to the tendency for dyads to repeatedly interact with each other (tie-oriented model) or for actors to repeatedly choose the same actor as receiver of their events (actor-oriented model). The statistic at timepoint t for dyad (i,j) resp. receiver j is equal to the number of (i,j) events before timepoint t.

Optionally, a scaling method can be set with scaling. By scaling the inertia count by the outdegree of the sender ("prop"), the statistic refers to the fraction of messages send by actor i that were send to actor j. If actor i hasn't send any messages yet it can be assumed that every actor is equally likely to receive a message from i and the statistic is set equal to 1/(n-1), where n refers to the number of actors. The resulting statistic is similar to the "FrPSndSnd" statistic in the R package 'relevent', or the persistence statistic in Section 2.2.2 of Butts (2008). Note that this scaling method is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ inertia()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


Simulated exogenous information on actors in a social network.

Description

A dataset containing exogenous information on the actors in the social network of a relational event history. Data is simulated.

Usage

data(info)

Format

A dataframe with 10 rows and 5 variables:

id

numeric id of the actor

time

numeric value, describes when the value of the covariate changes, if it changes

age

dichotomized age of the actor (e.g., 0 = below 25, 1 = 25 or older)

sex

dichotomized sex of the actor (e.g., 0 = male, 1 = female)

extraversion

standardized extraversion score of the actor

agreeableness

standardized agreeableness score of the actor

Source

Simulated exogenous information on actors in a social network.

See Also

history for the relational event history.

Examples

data(info)


Test whether an object is a remstats_durem

Description

Test whether an object is a remstats_durem

Usage

is.remstats_durem(x)

Arguments

x

Any R object.

Value

TRUE if x inherits from "remstats_durem".


isp

Description

Specifies the statistic for an incoming shared partners effect.

Usage

isp(unique = FALSE, scaling = c("none", "std"), consider_type = "ignore")

Arguments

unique

A logical value indicating whether to sum the minimum of events with third actors (FALSE, default) or the number of third actors that create a new, unique shared partner (TRUE). See details for more information.

scaling

the method for scaling the triad statistic. Default is to not scale the statistic but keep the raw 'counts'. Alternatively, standardization of the raw counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The incoming shared partners effect describes the propensity of dyads to interact based on the number of past incoming shared partners between them. By default, the statistic at timepoint t for the dyad (i,j) is computed as the sum of the minimum occurrences of past (h,i) and (h,j) events across all actors h.

When the unique parameter is set to TRUE, a different approach is taken. In this case, the statistic counts the number of actors h that contribute to the creation of a new, distinct shared partner between actors i and j.

Additionally, it is possible to specify a scaling method using the scaling parameter.

Please note that the incoming shared partners effect, 'isp', is exclusively defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

References

Butts, C. (2008). A relational event framework for social action. Sociological Methodology.

See Also

otp, itp, or osp for other types of triadic effects for directed relational events and sp for triadic effects for undirected relational events.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ isp()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


itp

Description

Specifies the statistic for an incoming two-path effect.

Usage

itp(unique = FALSE, scaling = c("none", "std"), consider_type = "ignore")

Arguments

unique

A logical value indicating whether to sum the minimum of events with third actors (FALSE, default) or the number of third actors that create a new, unique two-path (TRUE). See details for more information.

scaling

The method for scaling the triad statistic. The default value is "none", which means the statistic is not scaled. Alternatively, you can set it to "std" to request standardization of the raw counts per time point.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The incoming two-path effect describes the propensity of dyads to interact based on the number of past incoming two-paths between them. By default, the statistic at timepoint t for the dyad (i,j) is computed as the sum of the minimum occurrences of past (j,h) and (h,i) events across all actors h.

When the unique parameter is set to TRUE, a different approach is taken. In this case, the statistic counts the number of actors h that contribute to the creation of a new, distinct two-path between actors i and j.

Additionally, it is possible to specify a scaling method using the scaling parameter.

Please note that the incoming two-path effect, 'itp', is exclusively defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

References

Butts, C. (2008). A relational event framework for social action. Sociological Methodology.

See Also

otp, osp, or isp for other types of triadic effects for directed relational events and sp for triadic effects for undirected relational events.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ itp()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


maximum

Description

Specifies the statistic for a "maximum" effect in the tie-oriented model. A "maximum" effect refers to an exogenous actor attribute that affects dyad (i,j)'s rate of interacting based on the maximum of the values of actors i and j on this attribute.

Usage

maximum(variable, attr_actors = NULL, scaling = c("none", "std"), attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t for dyad (i,j) is equal to the maximum of the values of actor i and j on the attribute at timepoint t.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ maximum("extraversion")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)


minimum

Description

Specifies the statistic for a "minimum" effect in the tie-oriented model. A "minimum" effect refers to an exogenous actor attribute that affects dyad (i,j)'s rate of interacting based on the minimum of the values of actors i and j on this attribute.

Usage

minimum(variable, attr_actors = NULL, scaling = c("none", "std"), attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t for dyad (i,j) is equal to the minimum of the values of actor i and j on the attribute at timepoint t.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ minimum("extraversion")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)


osp

Description

Specifies the statistic for an outgoing shared partners effect.

Usage

osp(unique = FALSE, scaling = c("none", "std"), consider_type = "ignore")

Arguments

unique

A logical value indicating whether to sum the minimum of events with third actors (FALSE, default) or the number of third actors that create a new, unique shared partner (TRUE). See details for more information.

scaling

the method for scaling the triad statistic. Default is to not scale the statistic but keep the raw 'counts'. Alternatively, standardization of the raw counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The outgoing shared partners effect describes the propensity of dyads to interact based on the number of past outgoing shared partners between them. By default, the statistic at timepoint t for the dyad (i,j) is computed as the sum of the minimum occurrences of past (i,h) and (j,h) events across all actors h.

When the unique parameter is set to TRUE, a different approach is taken. In this case, the statistic counts the number of actors h that contribute to the creation of a new, distinct shared partner between actors i and j.

Additionally, it is possible to specify a scaling method using the scaling parameter.

Please note that the outgoing shared partners effect, 'osp', is exclusively defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

References

Butts, C. (2008). A relational event framework for social action. Sociological Methodology.

See Also

otp, itp, or isp for other types of triadic effects for directed relational events and sp for triadic effects for undirected relational events.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ osp()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


otp

Description

Specifies the statistic for an outgoing two-path effect.

Usage

otp(unique = FALSE, scaling = c("none", "std"), consider_type = "ignore")

Arguments

unique

A logical value indicating whether to sum the minimum of events with third actors (FALSE, default) or the number of third actors that create a new, unique two-path (TRUE). See details for more information.

scaling

The method for scaling the triad statistic. The default value is "none", which means the statistic is not scaled. Alternatively, you can set it to "std" to request standardization of the raw counts per time point.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The outgoing two-path effect describes the propensity of dyads to interact based on the number of past outgoing two-paths between them. By default, the statistic at timepoint t for the dyad (i,j) is computed as the sum of the minimum occurrences of past (i,h) and (h,j) events across all actors h.

When the unique parameter is set to TRUE, a different approach is taken. In this case, the statistic counts the number of actors h that contribute to the creation of a new, distinct two-path between actors i and j.

Additionally, it is possible to specify a scaling method using the scaling parameter.

Please note that the outgoing two-path effect, 'otp', is exclusively defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

References

Butts, C. (2008). A relational event framework for social action. Sociological Methodology.

See Also

itp, osp, or isp for other types of triadic effects for directed relational events and sp for triadic effects for undirected relational events.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ otp()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


outdegreeReceiver

Description

Specifies the statistic for an 'outdegreeReceiver' effect in the tie-oriented model or the receiver choice step of the actor-oriented model.

Usage

outdegreeReceiver(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An outdegree of the receiver effect refers to the tendency for actors to receive events if they have send more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or receiver j (actor-oriented model) is equal to the number of events send by actor j before timepoint t. Note that the 'outdegreeReceiver' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that were send by actor j. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to receive a message and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeSender, indegreeReceiver, outdegreeSender, totaldegreeSender, or totaldegreeReceiver for other types of degree effects.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ outdegreeReceiver()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


outdegreeSender

Description

Specifies the statistic for an 'outdegreeSender' effect in the tie-oriented model or the sender activity rate step of the actor-oriented model.

Usage

outdegreeSender(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

An outdegree of the sender effect refers to the tendency for actors to send events if they have send more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or sender i (actor-oriented model) is equal to the number of events send by actor i before timepoint t. Note that the 'outdegreeSender' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events, the statistic refers to the fraction of past events that were send by actor i. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to send a message and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeSender, indegreeReceiver, outdegreeReceiver, totaldegreeSender, or totaldegreeReceiver for other types of degree effects.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ outdegreeSender()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = effects)


Plotting Relational Event Network Statistics Trajectories

Description

Generate line plots to visualize the trajectories of a specified effect in the sender model of a aomstats object.

Usage

## S3 method for class 'aomstats'
plot(x, effect, subset = NULL, ...)

Arguments

x

An object of class aomstats containing relational event network statistics.

effect

A character string specifying the name of the effect in 'x' or an integer indicating the index of the effect to be plotted.

subset

An optional vector specifying a subset of actors to be used for plotting. By default, a maximum of 5 unique actors are used for plotting.

...

Additional arguments passed to plot().

Details

This function creates line plots to illustrate the temporal trajectories of a specified effect in a relational event network, as captured in the sender model by a aomstats object. The 'effect' parameter allows users to choose a specific effect for visualization, either by providing the effect's name or its index within the 'aomstats' object. An optional 'subset' parameter enables users to focus on specific actors. If 'subset' is not specified, a default maximum of 5 unique actors is plotted. These actors are randomly selected to represent trajectories across the range of different endpoints for the effect (excluding zero).

Examples

library(remstats)
# Load data
data(history)
# Prepare data
reh <- remify::remify(edgelist = history[,1:3], model = "actor")
# Compute effects
stats <- remstats(reh, sender_effects = ~ outdegreeSender())
# Plot the 'outdegreeSender' trajectories 5 actors
plot(stats, effect = "outdegreeSender")
# Plot the 'outdegreeSender' trajectory for a specific actor
plot(stats, effect = "outdegreeSender", subset = 10)


Plotting Relational Event Network Statistics Trajectories

Description

Generate line plots to visualize the trajectories of a specified effect in a tomstats object.

Usage

## S3 method for class 'tomstats'
plot(x, effect, subset = NULL, ...)

Arguments

x

An object of class tomstats containing relational event network statistics.

effect

A character string specifying the name of the effect in 'x' or an integer indicating the index of the effect to be plotted.

subset

An optional vector specifying a subset of dyads to be used for plotting. By default, a maximum of 5 unique dyads are used for plotting.

...

Additional arguments passed to plot().

Details

This function creates line plots to illustrate the temporal trajectories of a specified effect in a relational event network, as captured by a tomstats object. The 'effect' parameter allows users to choose a specific effect for visualization, either by providing the effect's name or its index within the 'tomstats' object. An optional 'subset' parameter enables users to focus on specific dyads. If 'subset' is not specified, a default maximum of 5 unique dyads is plotted. These dyads are randomly selected to represent trajectories across the range of different endpoints for the effect (excluding zero).

Examples

library(remstats)
# Load data
data(history)
# Prepare data
reh <- remify::remify(edgelist = history[,1:3], model = "tie")
# Compute effects
stats <- remstats(reh, tie_effects = ~ inertia())
# Plot the 'inertia' trajectories for 5 dyads
plot(stats, effect = "inertia")
# Plot the 'inertia' trajectory for a specific dyad
plot(stats, effect = "inertia", subset = 60)


Printing Relational Event Network Statistics

Description

Print a remstats object in a user-friendly format.

Usage

## S3 method for class 'remstats'
print(x, ...)

Arguments

x

object of class remstats.

...

further arguments passed to or from other methods.

Value

The function prints formatted information about the remstats object to the console, presenting details about the relational event network statistics in a user-friendly format.

Examples

rehObject <- remify::remify(edgelist = history, model = "tie")
remstatsObject <- remstats::remstats(reh = rehObject, tie_effects = ~ remstats::inertia())
print(remstatsObject)

rehObject <- remify::remify(edgelist = history, model = "actor")
remstatsObject <- remstats::remstats(reh = rehObject, receiver_effects = ~ inertia())
print(remstatsObject)


Print method for remstats_durem

Description

Print method for remstats_durem

Usage

## S3 method for class 'remstats_durem'
print(x, ...)

Arguments

x

A remstats_durem object.

...

Ignored.


psABA

Description

Specifies the statistic for a participation shift AB-A in the sender step of the actor-oriented model.

Usage

psABA()

Details

Refers to the tendency for the same actor to keep initiating events: The next sender is equal to the previous sender. For each timepoint t, the psABA statistic is equal to one for the actor that will create the participation shift if they would occur in the edgelist as the sender at time t and equal to zero for the actors that will not create this participation shift. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABB or psABX for exploring alternative participation shifts in the sender step of the actor-oriented model.

Examples

reh_actor <- remify::remify(history, model = "actor")
remstats(sender_effects = ~ psABA(), reh = reh_actor)


psABAB

Description

Specifies the statistic for a pshift AB-AB effect.

Usage

psABAB(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

Refers to the tendency for the same dyads to keep interacting. For directed events, the next sender and receiver are equal to the previous sender and receiver. For undirected events, the next actor pair is equal to the current actor pair. For each timepoint t, the psABAB statistic is equal to one for the dyads that will create the participation shift if they would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the two subsequent AB events have to be equal. If it is set to FALSE, the participation shift is set to one for every AB event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABBY, psABXA, psABXB, psABXY or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ psABAB()
remstats(tie_effects = effects, reh = reh_tie)


psABAY

Description

Specifies the statistic for a participation shift AB-AY.

Usage

psABAY(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

One of Gibson's (2003) dyadic participation shifts. The AB-AY participation shift refers to a tendency for turn continuing. For directed events, the sender (A) in the current event is the same as the sender in the previous event (A), and the receiver (Y) is different from the previous receiver (B). In undirected events, one of the current actors (A) matches one of the actors in the previous events (A or B), while the other actor (Y) is different.

To identify these shifts, a statistic 'psABAY' is calculated for each pair of actors at a given timepoint (t). If the pair's interaction follows the AB-AY pattern, the statistic is set equal to one; otherwise, it's set to zero.

Additionally, the types of the AB and AY events can be taken into account. If 'consider_type' is 'TRUE', the type of the AB event and the type of the AY event must match for the shift to occur. If 'consider_type' is 'FALSE', the shift happens for every AY event, regardless of the event type.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABBY, psABXA, psABXB, psABXY or psABAB for other dyadic participation shifts.

Examples

reh <- remify::remify(history, model = "tie")
effects <- ~ psABAY()
remstats(reh = reh, tie_effects = effects)


psABB

Description

Specifies the statistic for a participation shift AB-B in the sender step of the actor-oriented model.

Usage

psABB()

Details

The AB-B participation shift refers to the tendency for immediate reciprocation (the next sender is the previous receiver). For each timepoint t, the psABBA statistic is equal to one for the actor (i.e, the previous event receiver) that will create the participation shift if it would occur as sender in the edgelist at time t and equal to zero for the actors that will not create this participation shift. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABA or psABX for exploring alternative participation shifts in the sender step of the actor-oriented model.

Examples

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = ~ psABB())


psABBA

Description

Specifies the statistic for a participation shift AB-BA.

Usage

psABBA(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The AB-BA pshift effect refers to one of Gibson's (2003) dyadic participation shifts. The AB-BA pshift refers to the tendency for immediate reciprocation (the next sender is the previous receiver and the next receiver is the previous sender). For each timepoint t, the psABBA statistic is equal to one for the dyad that will create the participation shift if it would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the AB event and the type of the BA event have to be equal. If it is set to FALSE, the participation shift is set to one for every BA event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed. Note that the AB-BA pshift is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBY, psABXA, psABXB, psABXY or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ psABBA()
remstats(reh = reh_tie, tie_effects = effects)


psABBY

Description

Specifies the statistic for a participation shift AB-BY.

Usage

psABBY(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The AB-BY participation shift refers to one of Gibson's (2003) dyadic participation shifts. The AB-BY pshift refers to a tendency for turn receiving (here, the next sender is the previous receiver and the next receiver is not in the current previous). For each timepoint t, the psABBY statistic is equal to one for the dyads that will create the participation shift if they would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the AB event and the type of the BY events have to be equal. If it is set to FALSE, the participation shift is set to one for every BY event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed. Note that the AB-BY pshift is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABXA, psABXB, psABXY or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ psABBY()
remstats(reh = reh_tie, tie_effects = effects)


psABX

Description

Specifies the statistic for a participation shift AB-X in the sender step of the actor-oriented model.

Usage

psABX()

Details

The AB-X participation shift refers to a tendency for turn usurping (here, the next sender is not in the previous event). For each timepoint t, the psABX statistic is equal to one for the actors that will create the participation shift if they would occur as the sender in the edgelist at time t and equal to zero for the actors that will not create this participation shift. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABA or psABB for exploring alternative participation shifts in the sender step of the actor-oriented model.

Examples

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = ~ psABX())


psABXA

Description

Specifies the statistic for a participation shift AB-XA.

Usage

psABXA(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The AB-XA participation shift refers to one of Gibson's (2003) dyadic participation shifts. The AB-XA pshift refers to a tendency for turn usurping (here, the next sender is not in the previous event and the next receiver is the previous sender). For each timepoint t, the psABXA statistic is equal to one for the dyads that will create the participation shift if they would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the AB event and the type of the XA events have to be equal. If it is set to FALSE, the participation shift is set to one for every XA event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the pshift is observed. Note that the AB-XA pshift is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABBY, psABXB, psABXY or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ psABXA()
remstats(reh = reh_tie, tie_effects = effects)


psABXB

Description

Specifies the statistic for a participation shift AB-XB.

Usage

psABXB(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The AB-XB participation shift refers to one of Gibson's (2003) dyadic participation shifts. The AB-XB pshift refers to a tendency for turn usurping (here, the next sender is not in the previous event and the next receiver is the previous receiver). For each timepoint t, the psABXB statistic is equal to one for the dyads that will create the participation shift if they would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the AB event and the type of the XB events have to be equal. If it is set to FALSE, the participation shift is set to one for every XB event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed. Note that the AB-XB pshift is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABBY, psABXA, psABXY or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ psABXB()
remstats(reh = reh_tie, tie_effects = effects)


psABXY

Description

Specifies the statistic for a participation shift AB-XY.

Usage

psABXY(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The AB-XY participation shift refers to one of Gibson's (2003) dyadic participation shifts. The AB-XY pshift refers to a tendency for turn usurping (here, the next sender and the next receiver are not in the previous event). For each timepoint t, the psABXY statistic is equal to one for the dyads that will create the participation shift if they would occur in the edgelist at time t and equal to zero for the dyads that will not create this participation shift. If consider_type is set to TRUE, the type of the AB event and the type of the XY events have to be equal. If it is set to FALSE, the participation shift is set to one for every XY event, regardless of the event type. If multiple events in the edgelist occur at the same time point, the order of these events determines whether the p-shift is observed. Note that the AB-XY pshift is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

psABBA, psABBY, psABXA, psABXB or psABAY for other dyadic participation shifts.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ psABXY()
remstats(reh = reh_tie, tie_effects = effects)


receive

Description

Specifies the statistic for a "receive" effect in the tie-oriented model or the receiver choice step of the actor-oriented model. A "receive" effect refers to an exogenous actor attribute that affects actor i's rate of receiving events.

Usage

receive(variable, attr_actors = NULL, scaling = c("none", "std"), attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t is equal to the value of the exogenous attribute for actor i at time t for all dyads in the riskset that have actor i as receiver. Note that a "receive" effect is only defined for directed relational events.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

data(history)
data(info)

# Tie-oriented model
reh_tie <- remify::remify(history, model = "tie")
effects <- ~ receive("extraversion")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)

# Actor-oriented model
reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects, attr_actors = info)


recencyContinue

Description

Specifies the statistic for a recency continue effect in the effects argument of tomstats or the receiver_effects argument of aomstats.

Usage

recencyContinue(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The recencyContinue effect refers to a recency statistic similar to what is described in Vu et al. (2017) and Mulder and Leenders (2019). For each timepoint t, for directed dyad (i,j) the statistic is equal to 1/(the time that has past since the dyad was last active + 1).

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, rrankReceive, recencySendSender, recencyReceiveSender, recencyReceiveSender and recencyReceiveReceiver for other type of recency effects

Examples

effects <- ~ recencyContinue()
reh_tie <- remify::remify(history, model = "tie")
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(receiver_effects = effects, reh = reh_actor)


recencyReceiveReceiver

Description

Specifies the statistic for a recency receive of receiver effect in the effects argument of tomstats or the receiver_effects argument of aomstats.

Usage

recencyReceiveReceiver(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The recencyReceiveReceiver effect refers to a recency statistic similar to what is described in Vu et al. (2017) and Mulder and Leenders (2019). For each timepoint t, for directed dyad (i,j) the statistic is equal to 1/(the time that has past since receiver j was last active as receiver + 1). Note that the 'recencyReceiveReceiver' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, rrankReceive, recencySendSender, recencyReceiveSender, recencyReceiveSender and recencyContinue for other type of recency effects

Examples

effects <- ~ recencyReceiveReceiver()
reh_tie <- remify::remify(history, model = "tie")
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(receiver_effects = effects, reh = reh_actor)


recencyReceiveSender

Description

Specifies the statistic for a recency receive of sender effect in the effects argument of tomstats or the sender_effects argument of aomstats.

Usage

recencyReceiveSender(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The recencyReceiveSender effect refers to a recency statistic similar to what is described in Vu et al. (2017) and Mulder and Leenders (2019). For each timepoint t, for directed dyad (i,j) the statistic is equal to 1/(the time that has past since sender i was last active as receiver + 1). Note that the 'recencyReceiveSender' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, rrankReceive, recencySendSender, recencySendReceiver, recencyReceiveReceiver and recencyContinue for other type of recency effects

Examples

effects <- ~ recencyReceiveSender()
reh_tie <- remify::remify(history, model = "tie")
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(sender_effects = effects, reh = reh_actor)


recencySendReceiver

Description

Specifies the statistic for a recency send of receiver effect in the effects argument of tomstats or the receiver_effects argument of aomstats.

Usage

recencySendReceiver(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The recencySendReceiver effect refers to a recency statistic similar to what is described in Vu et al. (2017) and Mulder and Leenders (2019). For each timepoint t, for directed dyad (i,j) the statistic is equal to 1/(the time that has past since receiver j was last active as sender + 1). Note that the 'recencySendReceiver' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, rrankReceive, recencySendSender, recencyReceiveSender, recencyReceiveReceiver and recencyContinue for other type of recency effects

Examples

effects <- ~ recencySendReceiver()
reh_tie <- remify::remify(history, model = "tie")
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(receiver_effects = effects, reh = reh_actor)


recencySendSender

Description

Specifies the statistic for a recency send of sender effect in the effects argument of tomstats or the sender_effects argument of aomstats.

Usage

recencySendSender(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The recencySendSender effect refers to a recency statistic similar to what is described in Vu et al. (2017) and Mulder and Leenders (2019). For each timepoint t, for directed dyad (i,j) the statistic is equal to 1/(the time that has past since sender i was last active as sender + 1). Note that the 'recencySendSender' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, rrankReceive, recencySendReceiver, recencyReceiveSender, recencyReceiveReceiver and recencyContinue for other type of recency effects

Examples

effects <- ~ recencySendSender()
reh_tie <- remify::remify(history, model = "tie")
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(sender_effects = effects, reh = reh_actor)


reciprocity

Description

Specifies the statistic for a reciprocity effect in the tie-oriented model or the receiver choice step of the actor-oriented model.

Usage

reciprocity(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the reciprocity statistic. Default is to not scale the statistic but keep the raw 'counts'. Alternatively, the statistics can be scaled by 'prop', in which raw counts are divided by the indegree of the sender at time t (see 'details') or standardization of the raw counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

A reciprocity effect refers to the tendency for actors to reciprocate past interactions. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or receiver j (actor-oriented model) is equal to the number of (j,i) events before timepoint t. Note that a reciprocity effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the reciprocity count by the indegree of the sender, the statistic refers to the fraction of messages received by actor i that were received from actor j. If actor i hasn't received any messages yet it can be assumed that actor i is equally likely to receive a message from every actor and the statistic is set equal to 1/(n-1), where n refers to the number of actors. The resulting statistic is similar to the "FrRecSnd" statistic in the R package 'relevent'.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ reciprocity()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


remstats

Description

Computes statistics for modeling relational events with a tie-oriented or actor-oriented approach.

Usage

remstats(
  reh,
  tie_effects = NULL,
  sender_effects = NULL,
  receiver_effects = NULL,
  start_effects = NULL,
  end_effects = NULL,
  memory = c("full", "window", "decay", "interval"),
  memory_value = NA,
  psi_start = 1,
  psi_end = 1,
  first = 2,
  last = Inf,
  display_progress = FALSE,
  sampling = FALSE,
  samp_num = 10L,
  seed = NULL,
  attr_actors = NULL,
  attr_dyads = NULL
)

Arguments

reh

an object of class "remify" characterizing the relational event history. May also be a remify_durem object for duration relational event models.

tie_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the effects in the tie-oriented model for which statistics are computed, see 'Details' for the available effects and their corresponding statistics

sender_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the effects in the sender activity rate step of the actor-oriented model for which statistics are computed, see ‘Details’

receiver_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the effects in the receiver choice step of model for which statistics are computed, see ‘Details’

start_effects

Formula for the start sub-model statistics. Only used when reh is a remify_durem object (i.e. when remify(..., duration = TRUE) was called). Equivalent to tie_effects but applied to the start process. Only supported for the tie-oriented model.

end_effects

Formula for the end sub-model statistics. Only used when reh is a remify_durem object. Only supported for the tie-oriented model.

memory

The memory to be used. See ‘Details’.

memory_value

Numeric value indicating the memory parameter. Default is NA, which is only valid for memory = "full" (no memory parameter required). See ‘Details’.

psi_start

Numeric. Duration exponent for start-model history weighting. The weight of each past event in the start statistics is event_weight * (end - time + 1)^psi_start. Default 1. Only used when reh is a remify_durem object.

psi_end

Numeric. Duration exponent for end-model history weighting. The weight of each past event in the end statistics is event_weight * (end - time + 1)^psi_end. Default 1. Only used when reh is a remify_durem object.

first

an optional integer value, specifying the index of the first unique time point event in the relational event history for which statistics must be computed (see 'Details'). Default is 2: the first event has no history and is used only to initialize statistics, not to fit the model.

last

an optional integer value, specifying the index of the last unique time point in the relational event history for which statistics must be computed (see 'Details')

display_progress

should a progress bar for the computation of the endogenous statistics be shown (TRUE) or not (FALSE)?

sampling

Logical. If TRUE, statistics are computed using case–control (dyad) sampling rather than the full risk set. Default FALSE. Only supported for a tie model.

samp_num

Integer. Number of dyads to include per event when sampling = TRUE. Must be smaller than or equal to the size of the active risk set. Ignored when sampling = FALSE. Only supported for a tie model.

seed

Optional integer. Random seed used for dyad sampling. Setting this ensures reproducible sampling across calls. If NULL, the current RNG state is used.

attr_actors

optionally, an object of class "data.frame" that contains exogenous attributes for actors (see Details).

attr_dyads

optionally, an object of class data.frame or matrix containing attribute information for dyads (see Details).

Value

An object of class 'remstats'. In case of the tie-oriented model, an array with the computed statistics, where rows refer to time points, columns refer to potential relational event (i.e., potential edges) in the risk set and slices refer to statistics. In case of the actor-oriented model, list with in the first element the statistics for the sender activity rate step and in the second element the statistics for the receiver choice step, where rows refer to time points, columns refer to potential senders or receivers, respectively. Statistics are computed once per unique time point (per-timepoint "pt" method), so the number of rows in the output equals reh$M (the number of unique time points), which may be less than the total number of observed events when simultaneous events are present. The 'remstats' object has the following attributes:

model

Type of model that is estimated, obtained from the remify object inputted to 'reh'.

formula

Model formula, obtained from the formula inputted to 'tie_effects', 'sender_effects' and/or 'receiver_effects', depending on the model.

riskset

For the tie-oriented model, the risk set used to construct the statistics.

actors

For the actor-oriented model, the set of actors used to construct the statistics, obtained from the remify object inputted to 'reh'.

Effects

The statistics to be computed are defined symbolically and should be supplied to the tie_effects (for the tie-oriented model), sender_effects and/or receiver_effects (for the actor-oriented model) argument in the form ~ effects. In case of events with a duration (where reh is a remify_durem object, created with remify(..., duration = TRUE)), statistics should instead be supplied to start_effects and end_effects; note that events with a duration are only supported for the tie-oriented model. The statistics terms are separated by + operators. For example: effects = ~ inertia() + otp(). Interactions between two effects can be included with * or : operators. For example: effects = ~ inertia():otp(). A list of the available effects can be obtained with tie_effects() (tie-oriented model), actor_effects() (actor-oriented model), and, for models of events with a duration, active_effects() (statistics that depend on which actors or dyads are currently active).

The majority of the statistics can be scaled in some way, see the documentation of the scaling argument in the separate effect functions for more information on this.

The majority of the statistics can account for the event type included as a dependent variable, see the documentation of the consider_type argument in the separate effect functions for more information on this. Note that this option is only available for the tie-oriented model.

Note that events in the relational event history can be directed or undirected. Some statistics are only defined for either directed or undirected events (see the documentation of the statistics). Note that undirected events are only available for the tie-oriented model.

Memory

The default 'memory' setting is '"full"', which implies that at each time point $t$ the entire event history before $t$ is included in the computation of the statistics. Alternatively, when 'memory' is set to '"window"', only the past event history within a given time window is considered (see Mulders & Leenders, 2019). This length of this time window is set by the 'memory_value' parameter. For example, when 'memory_value = 100' and 'memory = "window"', at time point $t$ only the past events that happened at most 100 time units ago are included in the computation of the statistics. A third option is to set 'memory' to '"interval"'. In this case, the past event history within a given time interval is considered. For example, when '"memory_value" = c(50, 100)' and 'memory = "interval"', at time point $t$ only the past events that happened between 50 and 100 time units ago are included in the computation of the statistics. Finally, the fourth option is to set 'memory' to '"decay"'. In this case, the weight of the past event in the computation of the statistics depend on the elapsed time between $t$ and the past event. This weight is determined based on an exponential decay function with half-life parameter 'memory_value' (see Brandes et al., 2009).

Event weights

Note that if the relational event history contains a column that is named “weight”, it is assumed that these affect the endogenous statistics. These affect the computation of all endogenous statistics with a few exceptions that follow logically from their definition (e.g., the recenyContinue statistic does depend on time since the event and not on event weights).

Subset the event history using 'first' and 'last'

It is possible to compute statistics for a segment of the relational event sequence, based on the entire event history. This is done by specifying the 'first' and 'last' values as the indices for the first and last event times for which statistics are needed. For instance, setting 'first = 5' and 'last = 5' calculates statistics for the 5th event in the relational event sequence, considering events 1-4 in the history. Note that in cases of simultaneous events 'first' and 'last' refer to indices of unique time points.

References

Butts, C. T. (2008). A relational event framework for social action. Sociological Methodology, 38(1), 155–200. doi:10.1111/j.1467-9531.2008.00203.x, Stadtfeld, C., & Block, P. (2017). Interactions, actors, and time: Dynamic network actor models for relational events. Sociological Science, 4, 318–352. doi:10.15195/v4.a14

Examples

library(remstats)

# Tie-oriented model
eff <- ~ inertia():send("extraversion", attr_actors = info) + otp()
reh_tie <- remify::remify(edgelist = history, model = "tie")
remstats(reh = reh_tie, tie_effects = eff)

# Actor-oriented model
seff <- ~ send("extraversion", attr_actors = info)
reff <- ~ receive("agreeableness", attr_actors = info) + inertia() + otp()
reh_actor <- remify::remify(edgelist = history, model = "actor")
remstats(reh = reh_actor, sender_effects = seff, receiver_effects = reff)

# Model for events with a duration (tie-oriented only)
# (the baboons dataset is provided by the 'remdata' package)
if (requireNamespace("remdata", quietly = TRUE)) {
  data(baboons_obs, package = "remdata")
  reh_dur <- remify::remify(baboons_obs$edgelist[1:1000,], model = "tie",
  directed = FALSE, duration = TRUE)
  remstats(reh_dur,
    start_effects = ~ inertia(scaling = "std") +
      activeDegreeDyad(scaling = "std"),
    end_effects = ~ totaldegreeDyad(scaling = "std"),
    first = 50)
}


rrankReceive

Description

Specifies the statistic for a recency rank receive effect in the effects argument of tomstats or the receiver_effects argument of aomstats.

Usage

rrankReceive(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The rrankSend effect refers to a rank-based recency effect, as described in section 2.2.5 of Butts (2008). For each timepoint t, for directed dyad (i,j) the statistic is equal to the inverse of the rank of receiver j among the actors from which sender i has most recently received past events. Note that the 'rrankReceive' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankSend, recencySendSender, recencySendReceiver, recencyReceiveSender, recencyReceiveReceiver and recencyContinue for other type of recency effects

Examples


reh_tie <- remify::remify(history, model = "tie")
effects <- ~ rrankReceive()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(receiver_effects = effects, reh = reh_actor)


rrankSend

Description

Specifies the statistic for a recency rank send effect in the effects argument of tomstats or the receiver_effects argument of aomstats.

Usage

rrankSend(consider_type = "ignore")

Arguments

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The rrankSend effect refers to a rank-based recency effect, as described in section 2.2.5 of Butts (2008). For each timepoint t, for directed dyad (i,j) the statistic is equal to the inverse of the rank of receiver j among the actors to which sender i has most recently send past events. Note that the 'rrankSend' effect is only defined for directed events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

rrankReceive, recencySendSender, recencySendReceiver, recencyReceiveSender, recencyReceiveReceiver and recencyContinue for other type of recency effects

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ rrankSend()
remstats(tie_effects = effects, reh = reh_tie)

reh_actor <- remify::remify(history, model = "actor")
remstats(receiver_effects = effects, reh = reh_actor)


same

Description

Specifies the statistic for a "same" effect in the tie-oriented model or the receiver choice step of the actor-oriented model. A "same" effect refers to an exogenous actor attribute that affects dyad (i,j)'s rate of interacting (tie-oriented model) or actor j's probability of being chosen as a receiver for the event send by the active sender i at time t (actor-oriented model) based on whether actors i and j have the same value (or not) on this attribute.

Usage

same(variable, attr_actors = NULL, attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t is equal to one for dyads (i,j) that have the same value on the attribute at timepoint t (tie-oriented model) or one for receivers j that have the same value on the attribute as the active sender i at timepoint t (actor-oriented model) and equal to 0 for dyads and receivers that do not have the same value.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ same("age")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects, attr_actors = info)


Select a subset of statistics from a remstats object

Description

Select a subset of statistics from a remstats object

Usage

select_stats(
  object,
  tie_effects = NULL,
  sender_effects = NULL,
  receiver_effects = NULL,
  start_effects = NULL,
  end_effects = NULL
)

Arguments

object

a remstats object (of class tomstats, aomstats, or remstats_durem)

tie_effects

character vector of statistic names to keep (tomstats only)

sender_effects

character vector of statistic names to keep (aomstats only)

receiver_effects

character vector of statistic names to keep (aomstats only)

start_effects

character vector of statistic names to keep (remstats_durem only)

end_effects

character vector of statistic names to keep (remstats_durem only)

Value

a remstats object of the same class with only the selected statistics


send

Description

Specifies the statistic for a "send" effect in the tie-oriented model or the actor activity rate step of the actor-oriented model. A "send" effect refers to an exogenous actor attribute that affects actor i's rate of sending events.

Usage

send(variable, attr_actors = NULL, scaling = c("none", "std"), attr_data)

Arguments

variable

string with the name of the column in the attr_actors object for which the statistic has to be computed.

attr_actors

optionally, an object of class data.frame that contains the attribute, see 'Details.'

scaling

the method for scaling the statistic. Default is to not scale the statistic. Alternatively, standardization of the statistic per time point can be requested with "std".

attr_data

Deprecated argument. Please use 'attr_actors' instead.

Details

The statistic at timepoint t is equal to the value of the exogenous attribute for actor i at time t for all dyads in the risk set that have actor i as sender. Note that a "send" effect is only defined for directed relational events.

Construct the 'attr_actors' object as a data frame where each row represents the attribute value of actor i at timepoint t:

Note that it is possible to omit the 'attr_actors' object in the call of difference() and, instead, supply it in the call of remstats() for multiple exogenous effects.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

data(history)
data(info)

# Tie-oriented model
reh_tie <- remify::remify(history, model = "tie")
effects <- ~ send("extraversion")
remstats(reh = reh_tie, tie_effects = effects, attr_actors = info)

# Actor-oriented model
reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = effects, attr_actors = info)


sp

Description

Specifies the statistic for a shared partners effect for undirected events.

Usage

sp(unique = FALSE, scaling = c("none", "std"), consider_type = "ignore")

Arguments

unique

A logical value indicating whether to sum the minimum of events with third actors (FALSE, default) or the number of third actors that create a new, unique shared partner (TRUE). See details for more information.

scaling

the method for scaling the triad statistic. Default is to not scale the statistic but keep the raw 'counts'. Alternatively, standardization of the raw counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The shared partners effect describes the propensity of dyads to interact based on the number of past shared partners between them. By default, the statistic at timepoint t for the undirected dyad (i,j) is computed as the sum of the minimum occurrences of past undirected (i,h) and undirected (j,h) events across all actors h.

When the unique parameter is set to TRUE, a different approach is taken. In this case, the statistic counts the number of actors h that contribute to the creation of a new, distinct shared partner between actors i and j.

Additionally, it is possible to specify a scaling method using the scaling parameter.

Please note that the shared partners effect, 'sp', is exclusively defined for undirected events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

otp, itp, osp, or isp for triadic effects for directed relational events.

Examples

reh_tie <- remify::remify(history, model = "tie", directed = FALSE)
effects <- ~ sp()
remstats(tie_effects = effects, reh = reh_tie)


spUnique

Description

Deprecated. Use sp.

Usage

spUnique()

Value

Warning.


Stack remstats for model fitting

Description

Stack a tomstats object into long format suitable for fitting with standard R model functions. Each row corresponds to one dyad in the risk set at one event time point.

Usage

stack_stats(stats, reh, add_actors = TRUE)

Arguments

stats

A tomstats object (output of remstats() or tomstats()).

reh

A remify object (output of remify::remify()).

add_actors

Logical (default TRUE). When TRUE, two extra columns actor1 (sender label) and actor2 (receiver label) are appended by looking up reh$index$dyad_map_active (or reh$riskset_info$included as a fallback). Set to FALSE to suppress this lookup, e.g. when the riskset has not yet been resolved or for performance reasons.

Details

For interval timing (ordinal = FALSE), the stacked data can be fitted with a Poisson GLM using log_interevent as an offset: glm(obs ~ -1 + . - time - dyad - log_interevent, offset = log_interevent, family = poisson, data = stacked$remstats_stack)

For ordinal timing (ordinal = TRUE), use conditional logistic regression stratified by time point: survival::clogit(obs ~ -1 + . - time - dyad + strata(time), data = stacked$remstats_stack)

Value

A list with elements:

remstats_stack

Data frame in long format with columns: time (time-point index matching attr(stats, "subset") sequence), all statistic columns, log_interevent (log inter-event time; interval timing only), obs (1 = observed event, 0 = non-event), dyad (active dyad index 1..D), and — when add_actors = TRUE and the riskset is available — actor1 (sender label) and actor2 (receiver label).

subset

Integer vector of length 2: first and last event index.

D

Number of dyads in the risk set.

E

Number of events (time points).

ordinal

Logical: whether the ordinal likelihood applies.


Relational Event Network Statistics Summaries

Description

Produce summaries of each statistic from a remstats object.

Usage

## S3 method for class 'remstats'
summary(object, ...)

Arguments

object

object of class remstats.

...

additional arguments affecting the summary produced.

Value

The summaries provide information for each statistic included in the remstats object, offering insights into the distribution and characteristics of the data.

Examples

rehObject <- remify::remify(edgelist = history, model = "tie")
remstatsObject <- remstats::remstats(reh = rehObject, tie_effects = ~ remstats::inertia())
summary(remstatsObject)

rehObject <- remify::remify(edgelist = history, model = "actor")
remstatsObject <- remstats::remstats(reh = rehObject, receiver_effects = ~ inertia())
summary(remstatsObject)


Summary method for remstats_durem

Description

Summary method for remstats_durem

Usage

## S3 method for class 'remstats_durem'
summary(object, ...)

Arguments

object

A remstats_durem object.

...

Ignored.


tie

Description

Specifies the statistic for a "tie" (or, "dyad") effect.

Usage

tie(variable, attr_dyads = NULL, scaling = c("none", "std"), x, variableName)

Arguments

variable

A string specifying the attribute to compute the statistic. If attr_dyads is a data.frame, this refers to the column name in attr_actors. If attr_dyads is a matrix, this corresponds to the name of the exogenous attribute, used to label the statistic in the resulting remstats object.

attr_dyads

A data.frame or matrix containing attribute information for dyads. If attr_dyads is a data.frame, the first two columns should represent "actor1" and "actor2" (for directed events, "actor1" corresponds to the sender, and "actor2" corresponds to the receiver). Additional columns can represent dyads' exogenous attributes. If attributes vary over time, include a column named "time". If attr_dyads is a matrix, the rows correspond to "actor1", columns to "actor2", and cells contain dyads' exogenous attributes.

scaling

The method for scaling the statistic. The default is no scaling. Alternatively, standardization of the statistic per time point can be requested with "std".

x

Deprecated argument. Please use 'attr_dyads' instead.

variableName

Deprecated argument. Please use 'variable' instead.

Details

The "tie" effect or "dyad" effect refers to an exogenous dyad attribute that influences dyad (i,j)'s interaction rate (in tie-oriented models) or the probability of actor j being chosen as a receiver for the event sent by the active sender i (in actor-oriented models). The statistic represents the value of the exogenous attribute for dyad (i,j) in the attr_dyads data.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

data(history)
data(both_male_long)
effect <- ~ tie(variable = "both_male", attr_dyads = both_male_long)
reh <- remify::remify(history, model = "tie")
remstats(reh = reh, tie_effects = effect)

data(both_male_wide)
effect <- ~ tie(variable = "both_male", attr_dyads = both_male_wide)
reh <- remify::remify(history, model = "tie")
remstats(reh = reh, tie_effects = effect)


tie_effects

Description

Overview of statistics in the tie-oriented model, see Details.

Usage

tie_effects(directed = NULL, endogenous = NULL)

Arguments

directed

logical value. The function outputs all statistics in the tie-oriented model for directed events if true, or all statistics in the tie-oriented model for undirected events if false.

endogenous

logical value. The function outputs all endogenous statistics in the tie-oriented model if true, or all exogenous statistics if false

Details

Overview of statistics in the tie-oriented model.

Baseline:

Exogenous statistics:

Endogenous statistics:

Directed vs. undirected availability The set of available effects depends on whether events are directed. Use tie_effects(directed = TRUE) or tie_effects(directed = FALSE) to obtain the authoritative list for the current package version.

For undirected events (directed = FALSE), the available tie-model effects are:

Value

Returns a list of available effects and their corresponding statistics.

See Also

actor_effects for the actor-oriented model, and active_effects for the additional active-state statistics available in models of events with a duration.

Examples

# List of available effects 
tie_effects()

# List of available effects for undirected networks
tie_effects(directed = FALSE)

# List of available endogenous effects for undirected networks
tie_effects(directed = FALSE, endogenous = TRUE)


tomstats

Description

Computes statistics for modeling relational event history data with the tie-oriented relational event model.

Usage

tomstats(
  tie_effects,
  reh,
  memory = c("full", "window", "decay", "interval"),
  memory_value = NA,
  first = 2,
  last = Inf,
  display_progress = FALSE,
  sampling = FALSE,
  samp_num = 10L,
  seed = NULL,
  attr_actors = NULL,
  attr_dyads = NULL
)

Arguments

tie_effects

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the tie_effects in the model for which statistics are computed, see 'Details' for the available effects and their corresponding statistics

reh

an object of class "remify" characterizing the relational event history. May also be a remify_durem object for duration relational event models.

memory

The memory to be used. See ‘Details’.

memory_value

Numeric value indicating the memory parameter. Default is NA, which is only valid for memory = "full" (no memory parameter required). See ‘Details’.

first

an optional integer value, specifying the index of the first unique time point event in the relational event history for which statistics must be computed (see 'Details'). Default is 2: the first event has no history and is used only to initialize statistics, not to fit the model.

last

an optional integer value, specifying the index of the last unique time point in the relational event history for which statistics must be computed (see 'Details')

display_progress

should a progress bar for the computation of the endogenous statistics be shown (TRUE) or not (FALSE)?

sampling

Logical. If TRUE, statistics are computed using case–control (dyad) sampling rather than the full risk set. Default FALSE.

samp_num

Integer. Number of dyads to include per event when sampling = TRUE. Must be smaller than or equal to the size of the active risk set. Ignored when sampling = FALSE.

seed

Optional integer. Random seed used for dyad sampling. Setting this ensures reproducible sampling across calls. If NULL, the current RNG state is used.

attr_actors

optionally, an object of class "data.frame" that contains exogenous attributes for actors (see Details).

attr_dyads

optionally, an object of class data.frame or matrix containing attribute information for dyads (see Details).

Value

An object of class 'tomstats'. Array with the computed statistics, where rows refer to time points, columns refer to potential relational event (i.e., potential edges) in the risk set and slices refer to statistics. Statistics are computed once per unique time point (per-timepoint "pt" method), so the number of rows in the output equals reh$M (the number of unique time points), which may be less than the total number of observed events when simultaneous events are present. The 'tomstats' object has the following attributes:

model

Type of model that is estimated.

formula

Model formula, obtained from the formula inputted to 'tie_effects'.

riskset

The risk set used to construct the statistics.

Effects

The statistics to be computed are defined symbolically and should be supplied to the effects argument in the form ~ effects. The terms are separated by + operators. For example: tie_effects = ~ inertia() + otp(). Interactions between two effects can be included with * operators. For example: tie_effects = ~ inertia()*otp(). A list of available effects can be obtained with tie_effects().

The majority of the statistics can be scaled in some way, see the documentation of the scaling argument in the separate effect functions for more information on this.

The majority of the statistics can account for the event type included as a dependent variable, see the documentation of the consider_type argument in the separate effect functions for more information on this.

Note that events in the relational event history can be directed or undirected. Some statistics are only defined for either directed or undirected events (see the documentation of the statistics). Note that undirected events are only available for the tie-oriented model.

Memory

The default 'memory' setting is '"full"', which implies that at each time point $t$ the entire event history before $t$ is included in the computation of the statistics. Alternatively, when 'memory' is set to '"window"', only the past event history within a given time window is considered (see Mulders & Leenders, 2019). This length of this time window is set by the 'memory_value' parameter. For example, when 'memory_value = 100' and 'memory = "window"', at time point $t$ only the past events that happened at most 100 time units ago are included in the computation of the statistics. A third option is to set 'memory' to '"interval"'. In this case, the past event history within a given time interval is considered. For example, when '"memory_value" = c(50, 100)' and 'memory = "interval"', at time point $t$ only the past events that happened between 50 and 100 time units ago are included in the computation of the statistics. Finally, the fourth option is to set 'memory' to '"decay"'. In this case, the weight of the past event in the computation of the statistics depend on the elapsed time between $t$ and the past event. This weight is determined based on an exponential decay function with half-life parameter 'memory_value' (see Brandes et al., 2009).

Event weights

Note that if the relational event history contains a column that is named “weight”, it is assumed that these affect the endogenous statistics. These affect the computation of all endogenous statistics with a few exceptions that follow logically from their definition (e.g., the recenyContinue statistic does depend on time since the event and not on event weights).

Subset the event history using 'first' and 'last'

It is possible to compute statistics for a segment of the relational event sequence, based on the entire event history. This is done by specifying the 'first' and 'last' values as the indices for the first and last event times for which statistics are needed. For instance, setting 'first = 5' and 'last = 5' calculates statistics for the 5th event in the relational event sequence. Note that in cases of simultaneous events, 'first' and 'last' correspond to the indices of the first and last unique event timepoints. unique event timepoints for which statistics are needed. For example, if 'first = 5' and 'last = 5', statistics are computed for the 5th unique timepoint in the relational event sequence, considering all events occurring at unique timepoints 1-4.

Examples

library(remstats)

# Tie-oriented model
eff <- ~ inertia():send("extraversion", attr_actors = info) + otp()
reh_tie <- remify::remify(edgelist = history, model = "tie")
remstats(reh = reh_tie, tie_effects = eff)

# Tie-oriented model with case control sampling
eff <- ~ inertia():send("extraversion", attr_actors = info) + otp()
reh_tie <- remify::remify(edgelist = history, model = "tie")
remstats(reh = reh_tie, tie_effects = eff, sampling = TRUE, samp_num = 5L)


totaldegreeDyad

Description

Specifies the statistic for a 'totaldegreeDyad' effect.

Usage

totaldegreeDyad(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by two times the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

The 'totaldegreeDyad' effect refers to the tendency of pairs of actors (dyads) to increase their interaction rate as the total degree (number of interactions) of both actors in the pair goes up. To calculate this effect for a specific pair (i,j) at a given timepoint (t), we sum the degrees of the two actors in the dyad (i,j).

Additionally, there is an optional scaling method, which can be chosen using the 'scaling' method. When the 'prop' scaling method is applied, the degree count is divided by two times the total number of past events. This scaling converts the statistic into a fraction, representing the proportion of past events in which at least one actor in the dyad was involved. For the first timepoint, where no events have previously occurred, it is assumed that each actor is equally likely to be involved in an event. In this case, the statistic is set to 1 divided by the total number of actors (N).

The totaldegreeDyad effect is defined for the tie-oriented model and is applicable to both directed and undirected events.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ totaldegreeDyad()
remstats(reh = reh_tie, tie_effects = effects)


totaldegreeReceiver

Description

Specifies the statistic for an 'totaldegreeReceiver' effect in the tie-oriented model or the receiver choice step of the actor-oriented model.

Usage

totaldegreeReceiver(
  scaling = c("none", "prop", "std"),
  consider_type = "ignore"
)

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by two times the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

A total degree of the receiver effect refers to the tendency for actors to receive events if they have send and received more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or receiver j (actor-oriented model) is equal to the number of events send and received by actor j before timepoint t. Note that the 'totaldegreeReceiver' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events times two, the statistic refers to the fraction of past events times two that involved actor j. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to receive a message and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeSender, indegreeReceiver, outdegreeSender, outdegreeReceiver, or totaldegreeSender for other types of degree effects.

Examples

reh_tie <- remify::remify(history, model = "tie")
effects <- ~ totaldegreeReceiver()
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, receiver_effects = effects)


totaldegreeSender

Description

Specifies the statistic for an 'totaldegreeSender' effect in the tie-oriented model or the sender activity rate step of the actor-oriented model.

Usage

totaldegreeSender(scaling = c("none", "prop", "std"), consider_type = "ignore")

Arguments

scaling

the method for scaling the degree statistic. Default is to not scale the statistic (scaling = "none"). Alternatively, scaling of the raw degree counts by two times the number of past events at time t can be requested with 'prop' or standardization of the raw degree counts per time point can be requested with 'std'.

consider_type

character. Controls how event types are handled: "ignore" (default): aggregate over all event types (one statistic); "separate": compute C type-specific statistics, where the type-c statistic for a dyad reflects past type-c events on that actor pair ; "interact": compute C^2 statistics capturing past-event-type x dyad-type interactions (only meaningful with extend_riskset_by_type=TRUE in remify object). Also accepts FALSE (-> "ignore") and TRUE (-> "separate") for backward compatibility.

Details

A total degree of the sender effect refers to the tendency for actors to send events if they have send and received more past events. The statistic at timepoint t for dyad (i,j) (tie-oriented model) or sender i (actor-oriented model) is equal to the number of events send and received by actor i before timepoint t. Note that the 'totaldegreeSender' effect is only defined for directed events.

Optionally, a scaling method can be set with scaling. By scaling the degree count by the total number of past events times two, the statistic refers to the fraction of past events times two that involved actor i. At the first time point, when no events did previously occur, it is assumed that every actor is equally likely to send a message and the statistic is set equal to 1/n, where n refers to the number of actors.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

See Also

indegreeSender, indegreeReceiver, outdegreeSender, outdegreeReceiver, or totaldegreeReceiver for other types of degree effects.

Examples

effects <- ~ totaldegreeSender()
reh_tie <- remify::remify(history, model = "tie")
remstats(reh = reh_tie, tie_effects = effects)

reh_actor <- remify::remify(history, model = "actor")
remstats(reh = reh_actor, sender_effects = effects)


userStat

Description

Allows the user to add its own pre-computed statistic to the statistics object and, optionally, interact this statistic with other statistics in the formula.

Usage

userStat(x, variableName = NULL)

Arguments

x

Matrix with number of rows equal to the number of events and number of columns equal to the number of dyads in the network (tie-oriented model) or the number of actors in the network (actor-oriented model)

variableName

Optionally, a string with the name of the statistic.

Value

List with all information required by 'remstats::remstats()' to compute the statistic.

Examples


 reh <- remify::remify(history, model = "tie")
 actor101Events <- which(history$actor1 == "101" | history$actor2 == "101")
 actor101_stat <- t(sapply(seq_len(nrow(history)), function(i) {
   rep(i %in% actor101Events, reh$D)
 }))
 
 # Main effects only
 effects <- ~ userStat(x = actor101_stat, variableName = "actor101event")
 remstats(reh = reh, tie_effects = effects)
 
 # Model with interaction effects
 interaction_effects <- ~ inertia() *
   userStat(x = actor101_stat, variableName = "actor101event")
 remstats(reh = reh, tie_effects = interaction_effects)

mirror server hosted at Truenetwork, Russian Federation.