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 igraph network, or edge list formatted | n1 | n2 | weight | with colnames c("n1", "n2", "weight").

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.
A wrapper function may have to be written.

tol

Allowed error around the original output of func approximated by the sparsified network within which edges are removed. Specifies if method converges.

rank

Ranking of edges. Lower ranked edges are removed first. Must be the same length as nrow(E_List).

connected

If TRUE, connectivity of the network is prioritized over scoring by func.

directed

If TRUE, specifies that the inputted network is directed. Default is FALSE.

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)

[Package simplifyNet version 0.0.1 Index]