Random draws
Abstract
This page presents an overview of methods to draw from a probabilistic network, and ways to generate structural null models from a binary network under various constraints.
Drawing from a probabilistic network
#
SpeciesInteractionNetworks.randomdraws
— Function.
randomdraws(N::SpeciesInteractionNetwork{<:Partiteness, <:Probabilistic})
Returns a binary network by making random draws from a probabilistic network. Each interaction is considered as an independent Bernoulli trial.
References
Poisot, Cirtwill, Cazelles, Gravel, Fortin and Stouffer (2015)
Null models for hypothesis testing
The usual null models of network structure can be generated using a PermutationConstraint
as the first argument. Although technically speaking, these are not permutations, it is nevertheless useful to map the constraints from one method of network generation to another.
#
SpeciesInteractionNetworks.nullmodel
— Function.
nullmodel(::Type{Degree}, N::SpeciesInteractionNetwork{<:Partiteness, <:Binary})
Returns a probabilistic network under the null model that all interactions occurr with a probability equal to the average of their generality and vulnerability, i.e. proportionally to how many links the species involved are establishing:
$P(i \rightarrow j) = \frac{1}{2}\left(\frac{\sum A_{i \rightarrow \cdot}}{|B|} + \frac{\sum A_{\cdot \rightarrow j}}{|T|} \right)$
References
Bascompte, Jordano, Melián and Olesen (2003)
nullmodel(::Type{Connectance}, N::SpeciesInteractionNetwork{<:Partiteness, <:Binary})
Returns a probabilistic network under the null model that all interactions occurr with a probability equal to the network connectance, i.e. in a network with $L$ links, and $|T|$ species on the top and $|B|$ species on the bottom,
$P(i \rightarrow j) = \frac{L}{|T|\times |B|}$
Note that for Unipartite
networks, $|T| = |B| = |S|$ (the two sides have the same number of species).
References
nullmodel(::Type{Generality}, N::SpeciesInteractionNetwork{<:Partiteness, <:Binary})
Returns a probabilistic network under the null model that interactions happen proportionally to the generality of the species, i.e. their expected number of outgoing links:
$P(i \rightarrow j) = \frac{\sum A_{i \rightarrow \cdot}}{|B|}$
References
Poisot, Stanko, Miklisov{á} and Morand (2013)
Weitz, Poisot, Meyer, Flores, Valverde, Sullivan and Hochberg (2013)
nullmodel(::Type{Generality}, N::SpeciesInteractionNetwork{<:Partiteness, <:Binary})
Returns a probabilistic network under the null model that interactions happen proportionally to the vulnerability of the species, i.e. their expected number of incomin links:
$P(i \rightarrow j) = \frac{\sum A_{\cdot \rightarrow j}}{|T|}$
References
Poisot, Stanko, Miklisov{á} and Morand (2013)
Weitz, Poisot, Meyer, Flores, Valverde, Sullivan and Hochberg (2013)
nullmodel(::Type{C}, N::SpeciesInteractionNetwork{<:Partiteness{T}, <:Binary}, sp::T) where {C <: PermutationConstraint, T}
Returns a probabilistic network where the interaction probabilites for species sp
have been replaced by the probabilities given under the null model specified by the permutation constraint given as its first argument; see nullmodel
. All interactions that do not involve species sp
have their probability set to 1.
The original publication (Saavedra et al., 2011) uses [Degree
] as the permutation constraint, but this function has been written to be more general.
This network can be passed to speciescontribution
.
References
Saavedra, Stouffer, Uzzi and Bascompte (2011)
Species-level contributions based on null models
The null model approach can be extended to the contribution of each species. We offer a generic interface to generating pseudo-random networks where the target species has its interactions randomized, while all other interactions remain fixed.
#
SpeciesInteractionNetworks.speciescontribution
— Function.
speciescontribution(::Type{C}, N::SpeciesInteractionNetwork{<:Partiteness{T}, <:Binary}, sp::T, f, args...; replicates=999, kwargs...) where {C <: PermutationConstraint, T}
Returns the contribution of species sp
to the value of f(N, args...; kwargs...)
, after Saavedra et al. (2011). Specifically, this function will generate a species-specific nullmodel
, and then update in-place a copy of the network where interactions of species sp
are randomly re-drawn according to the probabilities under the null model.
Note that for the sake of generality, the function f
can accept both positional and keyword arguments.
The contribution of a species to the score is defined as
$\frac{f(N)-\mu_f}{\sigma_f}$
where μ and σ are respectively the average and standard deviation of the values of the measure f
on the randomized networks.
In order to ensure that the networks generated under the null model are informative, we constrain the number of interactions of sp
in the randomized network to be equal to the number of interactions of sp
in the original network.
References
Saavedra, Stouffer, Uzzi and Bascompte (2011)
Linear filtering
The linear filter from Stock et al. (2017) is a general formulation of the null models presented above.
#
SpeciesInteractionNetworks.linearfilter
— Function.
linearfilter(N::SpeciesInteractionNetwork{<:Partiteness, <:Binary}; α::Vector{T}=ones(4)) where {T <: AbstractFloat}
The linear filter returns a probability of observing an interaction as a function of a linear combination of the observed value of the interaction, the generality and vulnerability of the species, and the connectance of the network. It is also used to provide a generic implementation of nullmodel
.
Specifically, the probability of an interaction is expressed as a weighted average, the weights being given as the vector α
.
The vector α
has four elements, all positive, and $\sum \alpha = 1$ (this is enforced internally, and does not need to be checked by the user).
$\alpha_1$ is the weight of the original interaction; it helps to think of it as a penalization parameter, that explains how important the original observation is.
$\alpha_2$ is the weight of generality; it regulates how important the probability of the species establishing an interaction is in the resulting network.
$\alpha_3$ is the weight of vulnerability; it regulates how important the probability of the species receing an interaction is in the resulting network.
$\alpha_4$ is the weight of connectance.
References