Skip to contents

This function estimates Relational Event Models (REMs) using Maximum Likelihood Estimation (MLE) and Approximate Bayesian Regularization (ABR) with various priors. It processes a relational event history (REH) generated by generate_reh() and computes tie-oriented statistics to fit the specified model.

Usage

estimate_rems(
  edgelist,
  methods = c("mle", "abr_horseshoe", "abr_ridge", "abr_lasso"),
  seed = 123
)

Arguments

edgelist

A list output from generate_reh(), containing:

  • edgelist: A data frame of simulated events with columns time, actor1, and actor2.

  • parameters: A named list of model parameters.

  • covar: A data frame of actor covariates.

  • directed: Logical indicating whether the network is directed.

methods

A character vector specifying the estimation methods. Options include:

  • "mle": Maximum Likelihood Estimation.

  • "abr_horseshoe": ABR with Horseshoe prior.

  • "abr_ridge": ABR with Ridge prior.

  • "abr_lasso": ABR with Lasso prior. Defaults to all methods.

seed

An integer for reproducibility of random processes. Defaults to 123.

Value

A list with the following elements:

  • coefs_mle: Coefficients from the MLE model (if computed).

  • coefs_abr_horseshoe: ABR summary with Horseshoe prior (if computed).

  • coefs_abr_ridge: ABR summary with Ridge prior (if computed).

  • coefs_abr_lasso: ABR summary with Lasso prior (if computed).

  • abr: Raw ABR results for each prior type used.

  • parameters: Model parameters used for estimation.

  • covar: Actor covariates from the input REH.

  • methods: Methods used for estimation.

  • directed: Indicates whether the network is directed.

  • seed: Random seed used during the process.

Details

The estimate_rems() function performs the following steps:

  1. Formula Generation: It generates a formula for tie effects using generate_formula() based on the input parameters.

  2. Statistics Computation: Computes tie-oriented statistics using remstats::remstats() on the input REH.

  3. MLE Estimation: If "mle" is included in methods, the function estimates the model using remstimate::remstimate() and extracts the coefficients and covariance matrix for further processing.

  4. ABR Estimation: If "abr_horseshoe", "abr_ridge", or "abr_lasso" are included in methods, the function performs Approximate Bayesian Regularization using shrinkem::shrinkem() with the specified priors.

MLE Method: Estimates model parameters using maximum likelihood and calculates their covariance matrix. These estimates serve as priors for ABR methods.

ABR Method: Incorporates prior distributions to shrink model parameters. Three priors are supported:

  • Horseshoe: Enforces sparsity in model coefficients.

  • Ridge: Applies global shrinkage to all coefficients.

  • Lasso: Promotes sparsity for interpretable results.

Methods not included in methods are skipped.

Note

This function assumes that the input REH is correctly formatted and generated by generate_reh(). Providing invalid inputs may result in errors.

See also

generate_reh() for generating relational event histories. remstats::remstats() for computing tie-oriented statistics. remstimate::remstimate() for estimating REMs using MLE. shrinkem::shrinkem() for Approximate Bayesian Regularization.

Examples

# Simulate a REH using generate_reh
parameters <- list(
  baseline = -5,
  send_z1 = 0.5,
  difference_z2 = 0.2,
  inertia = 0.3
)
covar <- data.frame(
  name = 1:10, time = 0,
  z1 = rnorm(10),
  z2 = rnorm(10)
)
reh <- generate_reh(parameters, covar, M = 20, directed = TRUE)
#> 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 


# Estimate REMs
results <- estimate_rems(reh, methods = c("mle", "abr_horseshoe"))
#> Relational Event Model (tie oriented) 
#> 
#> Call:
#> ~1 + send("z1", scaling = "std") + difference("z2", scaling = "std") +     inertia(scaling = "std")
#> 
#> 
#> Coefficients (MLE with interval likelihood):
#> 
#>                  Estimate    Std. Err     z value Pr(>|z|)    Pr(=0)
#> baseline       -4.6776275   0.2446160 -19.1223322   0.0000 < 2.2e-16
#> send_z1         0.1824137   0.2436099   0.7487943   0.4540  0.771627
#> difference_z2   0.0095353   0.2452002   0.0388880   0.9690  0.817143
#> inertia         0.3576846   0.0969201   3.6905085   0.0002  0.004908
#> Null deviance: 221.6393 on 20 degrees of freedom
#> Residual deviance: 212.5321 on 16 degrees of freedom
#> Chi-square: 9.107194 on 4 degrees of freedom, asymptotic p-value 0.05847529 
#> AIC: 220.5321 AICC: 223.1988 BIC: 224.515
#> MCMC burnin
#> MCMC sampling
#> Call:
#> shrinkem.default(x = estimates, Sigma = cov, type = "horseshoe")
#> 
#>               input.est shrunk.mean shrunk.median shrunk.mode shrunk.lower
#> baseline         -4.678      -4.627        -4.627      -4.613       -5.109
#> send_z1           0.182       0.113         0.113       0.005       -0.254
#> difference_z2     0.010       0.000         0.000       0.002       -0.401
#> inertia           0.358       0.335         0.335       0.332        0.139
#>               shrunk.upper nonzero
#> baseline            -4.143       1
#> send_z1              0.560       0
#> difference_z2        0.406       0
#> inertia              0.526       1

# View results
print(results$coefs_mle)                # MLE coefficients
#>                   Estimate   Std. Err      z value     Pr(>|z|)       Pr(=0)
#> baseline      -4.677627513 0.24461595 -19.12233222 0.0000000000 1.768787e-79
#> send_z1        0.182413674 0.24360986   0.74879429 0.4539812035 7.716268e-01
#> difference_z2  0.009535336 0.24520020   0.03888796 0.9689797132 8.171430e-01
#> inertia        0.357684607 0.09692014   3.69050852 0.0002238062 4.907552e-03
print(results$coefs_abr_horseshoe)      # ABR Horseshoe summary
#>               input.est shrunk.mean shrunk.median shrunk.mode shrunk.lower
#> baseline         -4.678      -4.627        -4.627      -4.613       -5.109
#> send_z1           0.182       0.113         0.113       0.005       -0.254
#> difference_z2     0.010       0.000         0.000       0.002       -0.401
#> inertia           0.358       0.335         0.335       0.332        0.139
#>               shrunk.upper nonzero
#> baseline            -4.143       1
#> send_z1              0.560       0
#> difference_z2        0.406       0
#> inertia              0.526       1