# 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.6.0 (2026-04-24)
    #> Platform: x86_64-apple-darwin20
    #> Running under: macOS Sonoma 14.4.1
    #>
    #> Matrix products: default
    #> BLAS:   /Library/Frameworks/R.framework/Versions/4.6-x86_64/Resources/lib/libRblas.0.dylib
    #> LAPACK: /Library/Frameworks/R.framework/Versions/4.6-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    #>
    #> 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.3
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] vctrs_0.7.3       cli_3.6.6         knitr_1.51        rlang_1.2.0
    #>  [5] xfun_0.57         otel_0.2.0        purrr_1.2.2       jsonlite_2.0.0
    #>  [9] SMUT_1.1          htmltools_0.5.9   sass_0.4.10       matrixcalc_1.0-6
    #> [13] rmarkdown_2.31    grid_4.6.0        evaluate_1.0.5    jquerylib_0.1.4
    #> [17] MASS_7.3-65       fastmap_1.2.0     yaml_2.3.12       lifecycle_1.0.5
    #> [21] compiler_4.6.0    igraph_2.3.1      RSpectra_0.16-2   pkgconfig_2.0.3
    #> [25] Rcpp_1.1.1-1.1    rstudioapi_0.18.0 lattice_0.22-9    digest_0.6.39
    #> [29] R6_2.6.1          parallel_4.6.0    magrittr_2.0.5    bslib_0.11.0
    #> [33] Matrix_1.7-5      tools_4.6.0       SPAtest_3.1.2     SKAT_2.2.5
    #> [37] cachem_1.1.0