Construct a function to calculate response to perturbation.

press.impact(edges, perturb, monitor = NULL)

Arguments

edges

an edge list.

perturb

a named vector that indicates which nodes were perturbed and the relative magnitude of the perturbation.

monitor

n named vector that indicates the subset of nodes to monitor.

Value

Returns a function that when applied to a community matrix calculates the response to a press perturbation.

Details

Given the an edge list that specifies a directed graph, a set of nodes to perturb and a set of nodes to monitor, press.impact constructs a function of a single argument W that determines the response of the monitored nodes to the perturbation for a simulated community matrix W.

Examples

set.seed(32) ## Sample model edges <- parse.digraph(c( "E *-> D", "D *-> C", "C -> E", "E *-> B", "B *-> A", "A -> E", "D --> B")) edges <- enforce.limitation(edges) s <- community.sampler(edges) s$select(0.5) ## Perturb D, monitor C f <- press.impact(edges,perturb=c(D=1),monitor=c(C=0)) W <- s$community() f(W)
#> [1] -0.1423594
W <- s$community() f(W)
#> [1] 0.3849461
## Perturb D, monitor all f <- press.impact(edges,perturb=c(D=1)) W <- s$community() f(W)
#> [1] -6.294866 -7.373123 -8.269788 -6.722383 -3.906486
W <- s$community() f(W)
#> [1] 3.2166319 1.8985287 2.8477769 0.9746708 2.5440113