jewel_vignette

library(jewel)

In this vignette we demonstrate the usage of the jewel method for the estimation of networks. The vignette consists of three parts: generation of the artifical missing values into example dataset (since we need to know the true values for the performance evaluation), application of jewel and performance evaluation (we compare imputed values with the true ones).

Data generation

First, generate the data: 3 datasets with 100 variables and 50 samples. Their underlying graphs will have a quarter of edges not in common (can be tuned with perc parameter).

K <- 3
p <- 100
n <- 50
data <- generateData_rewire(K = K, p = p, n = n)
G_list_true <- data$Graphs
G_common_true <- data$CommonGraph
X <- data$Data

Applying jewel

Method jewel asks for some prior information on hubs if that is available to you. Let’s assume we do know which vertices are hubs. To simulate that, we’ll choose 3% of vertices with the highest degrees and put their degree to 10 (“hub”), while the rest is put to 1. Here we use only one graph because in simulation the degree distribution is the same by construction for all graphs.

true_degrees <- rowSums(G_list_true[[1]])
cut <- sort(true_degrees, decreasing = TRUE)[ceiling(p * 0.03)]
apriori_hubs <- ifelse(true_degrees >= cut, 10, 1)

Now construct the weights.

W <- constructWeights(apriori_hubs, K = K)

And now we estimate the graphs with user chosen \(\lambda_1\) and weights \(\mathbf{W}\) and with stability selection procedure

res <- jewel(X, lambda1 = 0.1, W = W, stability = TRUE)
G_list_est <- res$G_list
G_common_est <- res$CommonG

Performance evaluation

evaluatePerformance(G = G_common_true, G_hat = G_common_est)
mapply(evaluatePerformance, G_list_true, G_list_est)

Session info

sessionInfo()
#> R version 4.3.0 (2023-04-21)
#> Platform: x86_64-apple-darwin20 (64-bit)
#> Running under: macOS Monterey 12.5.1
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
#> 
#> locale:
#> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> time zone: Europe/Oslo
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] jewel_2.0.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] vctrs_0.6.2      cli_3.6.1        knitr_1.43       rlang_1.1.1     
#>  [5] xfun_0.39        purrr_1.0.1      jsonlite_1.8.5   SMUT_1.1        
#>  [9] htmltools_0.5.5  sass_0.4.6       matrixcalc_1.0-6 rmarkdown_2.22  
#> [13] grid_4.3.0       evaluate_0.21    jquerylib_0.1.4  MASS_7.3-60     
#> [17] fastmap_1.1.1    lifecycle_1.0.3  yaml_2.3.7       compiler_4.3.0  
#> [21] RSpectra_0.16-1  igraph_1.4.3     pkgconfig_2.0.3  Rcpp_1.0.10     
#> [25] rstudioapi_0.14  lattice_0.21-8   digest_0.6.31    R6_2.5.1        
#> [29] parallel_4.3.0   magrittr_2.0.3   bslib_0.5.0      Matrix_1.5-4.1  
#> [33] tools_4.3.0      SPAtest_3.1.2    SKAT_2.2.5       cachem_1.0.8