irefit {simplifyNet} | R Documentation |
Iterative refitting
Description
Iterative sparsifcation based refitting.
Usage
irefit(
network,
func,
tol,
rank = "none",
connected = FALSE,
directed = FALSE,
per = 0.5
)
Arguments
network |
Weighted adjacency matrix, weighted |
func |
Model function whose input is the network and whose output is a single real value or a list of reevaluated weights in the first index and a real value in the second. |
tol |
Allowed error around the original output of |
rank |
Ranking of edges. Lower ranked edges are removed first. Must be the same length as |
connected |
If TRUE, connectivity of the network is prioritized over scoring by |
directed |
If |
per |
Percentage of edges to add/remove from the sparsifier at each step. |
Value
Sparsified network, H
, which still maintains evaluator function, func
, plus/minus tol
.
Author(s)
Alexander Mercier
Andrew Kramer
Examples
#Set scoring function
mean.weight.degree <- function(graph){
graph.ob <- igraph::graph_from_edgelist(graph[,1:2])
igraph::E(graph.ob)$weight <- graph[,3]
return(mean(igraph::strength(graph.ob)))
}
#Generate random graph
g <- igraph::erdos.renyi.game(100, 0.1)
igraph::E(g)$weight <- rexp(length(igraph::E(g)), rate=10) #random edge weights from exp(10)
E_List <- cbind(igraph::as_edgelist(g), igraph::E(g)$weight)
colnames(E_List) <- c("n1", "n2", "weight")
sparse_dist <- simplifyNet::irefit(E_List, func=mean.weight.degree, tol = 0.1)