R/PLNnetworkfamily-S3methods.R
extract_probs.RdExtracts edge selection frequency in networks reconstructed from bootstrap subsamples during the stars stability selection procedure, as either a matrix or a named vector. In the latter case, edge names follow igraph naming convention.
an object with class PLNnetworkfamily, i.e. an output from PLNnetwork()
penalty used for the bootstrap subsamples
Integer index of the model to be returned. Only the first value is taken into account.
a character for the criterion used to performed the selection. Either
"BIC", "ICL", "EBIC", "StARS", "R_squared". Default is ICL for PLNPCA, and BIC for PLNnetwork.
If StARS (Stability Approach to Regularization Selection) is chosen and stability selection
was not yet performed, the function will call the method stability_selection() with default argument.
output format. Either a matrix (default) or a named vector.
tolerance for rounding error when comparing penalties.
Either a matrix or named vector of edge-wise probabilities. In the latter case, edge names follow igraph convention.
data(trichoptera)
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
nets <- PLNnetwork(Abundance ~ 1 + offset(log(Offset)), data = trichoptera)
#>
#> Initialization...
#> Adjusting 30 PLN with sparse inverse covariance estimation
#> Joint optimization alternating gradient descent and graphical-lasso
#> sparsifying penalty = 3.665314
sparsifying penalty = 3.385544
sparsifying penalty = 3.127128
sparsifying penalty = 2.888437
sparsifying penalty = 2.667965
sparsifying penalty = 2.464322
sparsifying penalty = 2.276222
sparsifying penalty = 2.10248
sparsifying penalty = 1.942
sparsifying penalty = 1.793768
sparsifying penalty = 1.656852
sparsifying penalty = 1.530386
sparsifying penalty = 1.413573
sparsifying penalty = 1.305676
sparsifying penalty = 1.206015
sparsifying penalty = 1.113961
sparsifying penalty = 1.028933
sparsifying penalty = 0.9503954
sparsifying penalty = 0.8778525
sparsifying penalty = 0.8108468
sparsifying penalty = 0.7489555
sparsifying penalty = 0.6917884
sparsifying penalty = 0.6389848
sparsifying penalty = 0.5902116
sparsifying penalty = 0.5451613
sparsifying penalty = 0.5035496
sparsifying penalty = 0.4651141
sparsifying penalty = 0.4296123
sparsifying penalty = 0.3968204
sparsifying penalty = 0.3665314
#> Post-treatments
#> DONE!
if (FALSE) { # \dontrun{
stability_selection(nets)
probs <- extract_probs(nets, crit = "StARS", format = "vector")
probs
} # }
if (FALSE) { # \dontrun{
## Add edge attributes to graph using igraph
net_stars <- getBestModel(nets, "StARS")
g <- plot(net_stars, type = "partial_cor", plot=F)
library(igraph)
E(g)$prob <- probs[as_ids(E(g))]
g
} # }