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 = 107.713011
#> Scaled convergence tolerance is 1.60505e-06
#> Stepsize computed as 4.000000
#> BUILD 3 328.526352 107.713011
#> HI-REDUCTION 5 107.713011 107.189184
#> LO-REDUCTION 7 107.713011 93.010685
#> HI-REDUCTION 9 107.189184 90.102496
#> LO-REDUCTION 11 93.010685 90.102496
#> HI-REDUCTION 13 90.797091 89.739658
#> LO-REDUCTION 15 90.102496 89.660251
#> HI-REDUCTION 17 89.739658 89.587440
#> LO-REDUCTION 19 89.660251 89.565161
#> HI-REDUCTION 21 89.587440 89.561182
#> LO-REDUCTION 23 89.565161 89.559246
#> HI-REDUCTION 25 89.561182 89.553403
#> LO-REDUCTION 27 89.559246 89.553246
#> HI-REDUCTION 29 89.554559 89.553246
#> HI-REDUCTION 31 89.553484 89.553246
#> HI-REDUCTION 33 89.553403 89.553246
#> HI-REDUCTION 35 89.553264 89.553246
#> HI-REDUCTION 37 89.553250 89.553239
#> HI-REDUCTION 39 89.553246 89.553232
#> LO-REDUCTION 41 89.553239 89.553232
#> Exiting from Nelder Mead minimizer
#> 43 function evaluations used
# Use the optimal penalties
Plist <- ridgeP.fused(Slist, ns, lambda = opt$lambda, maxit = 1000)
#> i = 1 | max diff = 2.1757506777e-01
#> i = 2 | max diff = 9.5598204555e-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 0.0 0.0 0.0 0.0
#> B 0.0 1.6 0.0 0.0 0.0 0.3 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 0.5
#> D 0.0 0.0 0.0 1.9 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.0 2.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.0 0.0
#> F 0.0 0.3 0.0 0.0 0.0 0.9 -0.3 -0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> G 0.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.2 0.0 1.5 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0
#> I 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.7 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 0.0 0.0 0.0 0.0 1.7 0.0 0.0 0.0 0.0 -0.4 0.0
#> K 0.0 0.0 0.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
#> L 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.0 0.0 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