Skip to contents

This function selects variables that meet specified significance criteria from the results of Relational Event Models (REMs) estimated using estimate_rems(). It supports significance selection for both Maximum Likelihood Estimation (MLE) and Approximate Bayesian Regularization (ABR) methods with various priors.

Usage

select_variables(
  estimates,
  criterion_mle = c("p<0.05", "p<0.01", "p<0.001"),
  criterion_abr = c("95% hdi", "99% hdi", "mean>0.1", "median>0.1", "mode>0.1")
)

Arguments

estimates

A list output from estimate_rems(), containing REM results, including:

  • coefs_mle: Coefficients from MLE (if computed).

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

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

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

  • Other metadata such as parameters, covar, methods, directed, and seed.

criterion_mle

A character vector specifying the criterion for selecting variables from MLE results. Options include:

  • "p<0.05": Select variables with p-values less than 0.05.

  • "p<0.01": Select variables with p-values less than 0.01.

  • "p<0.001": Select variables with p-values less than 0.001. Must specify exactly one criterion.

criterion_abr

A character vector specifying the criterion for selecting variables from ABR results. Options include:

  • "95% hdi": Select variables whose 95% highest density interval (HDI) does not include 0.

  • "99% hdi": Select variables whose 99% HDI does not include 0.

  • "mean>0.1": Select variables whose absolute shrunk mean exceeds 0.1.

  • "median>0.1": Select variables whose absolute shrunk median exceeds 0.1.

  • "mode>0.1": Select variables whose absolute shrunk mode exceeds 0.1. Must specify exactly one criterion.

Value

A list containing:

  • mle: Variables selected from MLE results (if applicable).

  • abr_horseshoe: Variables selected from ABR results with Horseshoe prior (if applicable).

  • abr_ridge: Variables selected from ABR results with Ridge prior (if applicable).

  • abr_lasso: Variables selected from ABR results with Lasso prior (if applicable).

  • Original metadata from the estimates input: parameters, covar, methods, directed, and seed.

Details

The function performs the following steps:

  1. MLE Selection: Variables are selected based on the p-values in coefs_mle for the specified criterion (p<0.05, p<0.01, or p<0.001).

  2. ABR Selection: For each ABR method (abr_horseshoe, abr_ridge, abr_lasso) in the input:

    • HDI-based criteria (95% hdi, 99% hdi) select variables whose highest density interval does not include 0.

    • Mean, median, or mode-based criteria (mean>0.1, median>0.1, mode>0.1) select variables with absolute values of the respective statistic exceeding 0.1.

  3. The selected variables are combined into the output list and printed for user review.

Note

Only one criterion can be specified for criterion_mle and criterion_abr. If multiple criteria are provided for either, the function will lead to an error.

See also

estimate_rems() for estimating relational event models. shrinkem::shrinkem() for Approximate Bayesian Regularization.

Examples

# Example input from estimate_rems
estimates <- estimate_rems(
  edgelist = list(
    edgelist = data.frame(time = 1:10,
                          actor1 = sample(1:3, 10, replace = TRUE),
                          actor2 = sample(1:3, 10, replace = TRUE)),
    parameters = list(baseline = -5, send_z1 = 0.5, inertia = 0.3),
    covar = data.frame(id = 1:3, z1 = rnorm(3)),
    directed = TRUE
  ),
  methods = c("mle", "abr_horseshoe")
)
#> Warning: 
#> Warning: self-loops are present in the input edgelist (i.e. `actor1` and `actor2` are the same). They are removed with the processing.
#> Warning: use 'name' instead of 'id' in 'attr_actors'
#> Relational Event Model (tie oriented) 
#> 
#> Call:
#> ~1 + send("z1", scaling = "std") + inertia(scaling = "std")
#> 
#> 
#> Coefficients (MLE with interval likelihood):
#> 
#>          Estimate Std. Err  z value Pr(>|z|) Pr(=0)
#> baseline -3.80030  1.90006 -2.00009   0.0455 0.2636
#> send_z1  -3.53230  2.84701 -1.24070   0.2147 0.5506
#> inertia  -0.74484  0.60798 -1.22510   0.2205 0.5554
#> Null deviance: 42.60303 on 7 degrees of freedom
#> Residual deviance: 35.20138 on 4 degrees of freedom
#> Chi-square: 7.401654 on 3 degrees of freedom, asymptotic p-value 0.06013995 
#> AIC: 41.20138 AICC: 49.20138 BIC: 41.03911
#> MCMC burnin
#> MCMC sampling
#> Call:
#> shrinkem.default(x = estimates, Sigma = cov, type = "horseshoe")
#> 
#>          input.est shrunk.mean shrunk.median shrunk.mode shrunk.lower
#> baseline    -3.800      -1.603        -1.603      -1.401       -4.792
#> send_z1     -3.532      -0.306        -0.306       0.024       -4.994
#> inertia     -0.745      -0.269        -0.269      -0.004       -1.329
#>          shrunk.upper nonzero
#> baseline        0.248       0
#> send_z1         2.583       0
#> inertia         0.545       0

# Select variables using p<0.05 for MLE and 95% HDI for ABR Horseshoe
selected <- select_variables(estimates, criterion_mle = "p<0.05", criterion_abr = "95% hdi")
#> Selected variables:
#>  ABR Horseshoe:  

# View selected variables
print(selected$mle)                # Variables from MLE
#> NULL
print(selected$abr_horseshoe)      # Variables from ABR Horseshoe
#> character(0)