get_diversity_from_path {triversity} | R Documentation |
Compute the diversity associated to a random walk following a path between the levels of a tripartite graph.
Description
get_diversity_from_path
computes diversity values of the probability distribution of a
random walk following a path
between the different levels of the input tripartite
graph. It starts at a given level with an initial probability distribution, then randomly follows
the links of the graph between the different levels according to the input path
, then
stops at the last specified level. The implemented diversity measures all belong to the
parametrized family of "True Diversity" measures. They can either be specified by their diversity
order
in [0
,Inf
[ or by their measure
name when it corresponds to
classical instances such as the richness, the Shannon entropy, the Herfindahl-Hirschman index,
or the Berger-Parker index.
Usage
get_diversity_from_path(tripartite, path, conditional_path = NULL,
initial_distribution = NULL, initial_node = NULL, order = NULL,
measure = NULL)
Arguments
tripartite |
A tripartite graph obtained by calling the |
path |
A vector of integers in { |
conditional_path |
A vector of integers in { |
initial_distribution |
A vector of floats in [ |
initial_node |
A string giving the name of a node in the first level of the input
|
order |
A vector of positive floats (possibly including |
measure |
A vector of strings giving the names of the diversity measures to compute.
Possible values are |
Value
A vector of positive floats giving the diversity values (or conditional diversity values)
of the random walk following the input path
.
Examples
data (tripartite_example)
tripartite <- get_tripartite (data=tripartite_example)
# COMPUTING DIFFERENT DIVERSITY VALUES FOR A GIVEN PATH
# Herfindahl-Hirschman index of nodes in level 3 wrt nodes in level 1
get_diversity_from_path (tripartite, path=c(1,2,3), measure='herfindahl')
1 / get_diversity_from_path (tripartite, path=c(1,2,3), order=2)
# Shannon entropy of nodes in level 3 wrt nodes in level 1
get_diversity_from_path (tripartite, path=c(1,2,3), measure='entropy')
log2 (get_diversity_from_path (tripartite, path=c(1,2,3), order=1))
# Some other diversity values of nodes in level 3 wrt nodes in level 1
get_diversity_from_path (tripartite, path=c(1,2,3), order=c(1,2,Inf),
measure=c('richness','bergerparker'))
# Eight of the main diversity values of nodes in level 3 wrt nodes in level 1
get_diversity_from_path (tripartite, path=c(1,2,3))
# SPECIFYING THE INITIAL DISTRIBUTION
# Diversity of nodes in level 3 wrt nodes in level 1 (with non-uniform weights)
get_diversity_from_path (tripartite, path=c(1,2,3), initial_distribution=c(0.75,0.25))
# Individual diversity of nodes in level 3 wrt node 'u1' in level 1
get_diversity_from_path (tripartite, path=c(1,2,3), initial_node='u1')
get_diversity_from_path (tripartite, path=c(1,2,3), initial_distribution=c(1,0))
# COMPUTING THE MEAN OF INDIVIDUAL DIVERSITES
# Mean of individual diversities of nodes in level 3 wrt nodes in level 2 (with
# uniform weights)
get_diversity_from_path (tripartite, path=c(2,3), conditional_path=c(2))
# Mean of individual diversities of nodes in level 3 wrt nodes in level 2 (weighted
# according to the path from level 1 to level 2, with a uniform distribution in level 1)
get_diversity_from_path (tripartite, path=c(2,3), conditional_path=c(1,2))
# Mean of individual diversities of nodes in level 3 wrt nodes in level 2 (weighted
# according to the path from level 1 to level 2, with only node 'u1' in level 1)
get_diversity_from_path (tripartite, path=c(2,3), conditional_path=c(1,2),
initial_node='u1')