R/rags2ridgesFused.R
sparsify.fused.Rd
A simple wrapper for sparsify
which determines the support of
a list
of partial correlation/precision matrix by various methods and
returns the sparsified matrices.
sparsify.fused(Plist, ...)
A list
of numeric
precision matrices.
Arguments passed to sparsify
.
A list
of the same length as Plist
with the output from
sparsify
.
ns <- c(10, 11)
Ylist <- createS(ns, p = 16, dataset = TRUE)
Slist <- lapply(Ylist, covML)
Tlist <- default.target.fused(Slist, ns)
# Obtain regularized precision under optimal penalty
opt <- optPenalty.fused.auto(Ylist, Tlist, cv.method = "aLOOCV",
maxit.ridgeP.fused = 1500)
#> Found 2 unique penalties of which 0 are interpreted as fixed and 2 are to be determined by aLOOCV.
#> Non-fixed parameters: ridge, fusion
#> Fixed parameters: <none>
#> Nelder-Mead direct search function minimizer
#> function value for initial parameters = 155.232366
#> Scaled convergence tolerance is 2.31314e-06
#> Stepsize computed as 4.000000
#> BUILD 3 483.047026 155.232366
#> HI-REDUCTION 5 155.232366 143.332857
#> LO-REDUCTION 7 155.232366 121.934693
#> HI-REDUCTION 9 143.332857 119.874900
#> LO-REDUCTION 11 121.934693 119.874900
#> HI-REDUCTION 13 121.473346 117.982682
#> LO-REDUCTION 15 119.874900 117.961943
#> HI-REDUCTION 17 118.393667 117.961943
#> HI-REDUCTION 19 118.046915 117.961943
#> HI-REDUCTION 21 117.982682 117.961943
#> HI-REDUCTION 23 117.973533 117.961943
#> HI-REDUCTION 25 117.964092 117.961943
#> HI-REDUCTION 27 117.963481 117.961943
#> HI-REDUCTION 29 117.962115 117.961943
#> HI-REDUCTION 31 117.962067 117.961912
#> HI-REDUCTION 33 117.961943 117.961881
#> LO-REDUCTION 35 117.961912 117.961874
#> HI-REDUCTION 37 117.961881 117.961874
#> Exiting from Nelder Mead minimizer
#> 39 function evaluations used
# Use the optimal penalties
Plist <- ridgeP.fused(Slist, ns, lambda = opt$lambda, maxit = 1000)
#> i = 1 | max diff = 2.1180914010e-01
#> i = 2 | max diff = 1.6462479809e-30
#> Converged in 2 iterations, max diff < 1.49e-08.
# Determine support regularized (standardized) precision under optimal penalty
res <- sparsify.fused(Plist, threshold = "top", verbose = FALSE)
#> - Retained elements: 10
#> - Corresponding to 8.33 % of possible edges
#>
#> - Retained elements: 10
#> - Corresponding to 8.33 % of possible edges
#>
round(res[[1]]$sparsePrecision, 1)
#> A B C D E F G H I J K L M N O P
#> A 1.4 0.0 0.0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.3 0.0 0.0 0.0
#> B 0.0 1.8 0.0 0 0.0 0.0 0.0 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> C 0.0 0.0 1.8 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.4
#> D 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> E 0.0 0.0 0.0 0 1.6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0
#> F 0.0 0.0 0.0 0 0.0 1.3 -0.3 0.0 0.0 0.4 0.0 0.0 0.0 0.0 0.0 0.0
#> G 0.0 0.0 0.0 0 0.0 -0.3 1.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> H 0.0 0.4 0.0 0 0.0 0.0 0.0 1.5 0.0 0.0 0.0 0.0 0.0 -0.5 0.0 0.0
#> I 0.0 0.0 0.0 0 0.0 0.0 0.0 0.0 1.8 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> J 0.0 0.0 0.0 0 0.0 0.4 0.0 0.0 0.0 1.9 0.0 0.0 0.0 0.0 0.0 0.0
#> K 0.0 0.0 0.0 0 0.0 0.0 0.0 0.0 0.0 0.0 1.8 0.0 -0.5 0.0 0.0 0.0
#> L 0.0 0.0 0.0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.7 -0.4 0.0 0.0 0.0
#> M -0.3 0.0 0.0 0 0.0 0.0 0.0 0.0 0.0 0.0 -0.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