Generate an interaction matrix, either randomly from a uniform distribution or using Klemm-Eguiluz algorithm to generate a modular and scale-free interaction matrix.

generateA(N = 100, type = "random", pep = 50, d = -0.5,
  min.strength = -0.5, max.strength = 0.5, c = 0.02,
  ignore.c = FALSE, negedge.symm = FALSE, clique.size = 5,
  groups = c(), intra.group.strength = 0.5,
  inter.group.strength = NA)

Arguments

N

number of species

type

random (sample a uniform distribution), klemm (generate a Klemm-Eguiluz matrix) or empty (zero everywhere, except for diagonal which is set to d)

pep

desired positive edge percentage (only for klemm)

d

diagonal values (should be negative)

min.strength

random: minimal off-diagonal interaction strength (only for random)

max.strength

random: maximal off-diagonal interaction strength, klemm: maximal absolute off-diagonal interaction strength

c

desired connectance (interaction probability)

ignore.c

do not adjust connectance

negedge.symm

set symmetric negative interactions (only for klemm)

clique.size

modularity parameter (only for klemm)

groups

vector of group memberships for each species, assign NA if species does not belong to any group (only for random)

intra.group.strength

interaction strength between members of the same group

inter.group.strength

interaction strength between members of different groups (if not defined, will be assigned randomly)

Value

the interaction matrix

References

Klemm & Eguiluz, Growing Scale-Free Networks with Small World Behavior http://arxiv.org/pdf/cond-mat/0107607v1.pdf

Examples

klemm=generateA(N=10,type="klemm",c=0.5)
#> [1] "Adjusting connectance to 0.5" #> [1] "Initial edge number 80" #> [1] "Initial connectance 0.777777777777778" #> [1] "Number of edges removed 25" #> [1] "Final connectance 0.5" #> [1] "Final connectance: 0.5" #> [1] "Initial edge number 55" #> [1] "Initial connectance 0.5" #> [1] "Number of negative edges already present: 10" #> [1] "Converting 18 edges into negative edges" #> [1] "Final connectance: 0.5" #> [1] "Final arc number (excluding self-arcs) 45" #> [1] "Final negative arc number (excluding self-arcs) 18" #> [1] "PEP: 60"
groups=c(rep(NA,5),rep(1,10),rep(2,5),rep(3,10),rep(4,10)) Agroup=generateA(N=40,groups=groups,c=0.5,intra.group.strength=0.1,inter.group.strength=-0.5, d=-1)
#> [1] "Adjusting connectance to 0.5" #> [1] "Initial edge number 1600" #> [1] "Initial connectance 1" #> [1] "Number of edges removed 780" #> [1] "Final connectance 0.5" #> [1] "Final connectance: 0.5"