amorem

amorem — end-to-end simulation, sampling, feature engineering, model selection, and inference for relational event models (REMs) in R, in one consistent API.
The package consolidates four lines of recent methodological work:
- Dyadic REMs with timing / closure variants and one- or two-axis actor frailty, following Juozaitienė & Wit (2024, JRSS-A).
-
Relational Hyper Event Models (RHEMs) with set-valued sender/receiver hyperedges, subset-repetition covariates, and smooth effects (linear /
tv/nl/tvnl), following Boschi, Lerner & Wit (2025). - Global covariate effects — covariates varying in time but constant across pairs — via the time-shifted partial likelihood of Lembo, Juozaitienė, Vinciotti & Wit (2025, JRSS-C).
- Cumulative martingale-residual GOF tests, following Boschi & Wit (2025, Stat & Comp 36:4).
30-second tour
library(amorem)
# 1. Bundled datasets, ready to load
data(classroom_events) # 691 events, 20 actors (McFarland 2001)
data(social_evolution_calls) # 439 events, 54 actors (Madan et al. 2011)
data(radoslaw_email) # 82,927 emails, 167 actors (Michalski et al. 2014)
# 2. Compute endogenous features post-hoc from any (sender, receiver, time) log
feat <- compute_endogenous_features(
classroom_events, stats = c("reciprocity", "recency"))
# 3. Simulate a ready-to-fit case-1-control table with known structure ...
w <- simulate_relational_events(
n_events = 1500, senders = LETTERS[1:8], receivers = LETTERS[1:8],
n_controls = 1, endogenous_stats = "reciprocity_count",
endogenous_effects = c(reciprocity_count = 0.4), wide = TRUE)
# 4. ... and fit it with the default "gam" backend
fit <- rem(~ reciprocity_count, data = w, method = "gam")
summary(fit)What’s inside
-
rem()— the unified fitter for preprocessed case-control data, with a conditional-logit backend (case-k-control) and agambackend (case-1-control) supporting linear /tv/nl/tvnlsmooth effects andre()random effects, plussummary()/coef()/plot().widen_case_control()reshapes a long case-control log into the wide formrem()expects. -
simulate_relational_events()— exact Gillespie or τ-leap; composes exogenous, endogenous, and time-varying global covariates; withwide = TRUEemits a ready-to-fit case-1-control table. -
compute_endogenous_features()— the endogenous catalogue computed post-hoc from any(sender, receiver, time)log; viahistory_logit scores sampled non-events without polluting the event history. -
sample_non_events()— nested case-control sampling with appearance / citation / remove risk-set rules. -
Goodness of fit —
gof_global(),gof_multivariate(),gof_auxiliary(), and pointwisemartingale_residuals(). - The earlier
compare_models(),compare_models_smooth()andcompare_models_global()remain available (superseded byrem()).
Guides
| Guide | What you’ll find |
|---|---|
| Quick start | install + simulate-and-recover in a few lines |
| Simulation | the dyadic mechanisms, Gillespie vs τ-leap |
| Endogenous catalogue | the statistic catalogue and its variant axes |
| Estimation | case-control sampling, the three rem() backends — clogit (linear), gam (smooth tv/nl/tvnl/re effects), nn (neural conditional logit) — model comparison, GOF |
| Hyperedge models | the (I, J, time) data model and RHEM simulators |
| Datasets | the bundled REM datasets |
| Real-data analysis | sender-frailty flip, smooth effect curves |
| Validation experiments | recovery, smooth, scaling, parity, and the neural backend (gradient check + interaction recovery) |
Full per-function documentation is under Reference.
References
- Juozaitienė R., Wit E.C. (2024). It’s about time: revisiting reciprocity and triadicity in relational event analysis. JRSS-A 188(4), 1246–1262. doi:10.1093/jrsssa/qnae132.
- Boschi M., Lerner J., Wit E.C. (2025). Beyond Linearity and Time-Homogeneity: Relational Hyper Event Models with Time-Varying Non-Linear Effects. arXiv:2509.05289.
- Lembo M., Juozaitienė R., Vinciotti V., Wit E.C. (2025). Relational Event Models with Global Covariates. JRSS-C.
- Boschi M., Wit E.C. (2025). Goodness of fit in relational event models. Statistics and Computing 36(4).