Compute the robustness for a given set of Latent Block Model parameters.

robustness_lbm(
  con = NULL,
  pi = NULL,
  rho = NULL,
  nr = NULL,
  nc = NULL,
  ext_seq = "uniform",
  method = "exact",
  approx_threshold = 10000,
  net = NULL,
  ...
)

Arguments

con

A matrix, the connectivity parameter

pi

A vector of length nrow(con), the proportion of row blocks

rho

A vector of length ncol(con), the proportion of column blocks

nr

An integer, the number of row (primary) species

nc

An integer, the number of column (secondary) species

ext_seq

A string, the rule for the primary extinctions sequences, one of:

  • "uniform", the default for uniform extinctions sequences,

  • "decreasing" and "increasing" for primary extinctions sequences by increasing and decreasing row blocks connection probability,

  • "natural" primary extinctions sequences with the block ordering given in the function parameter.

  • "blocks" primary extinctions sequences for all blocks permutation.

method

A string, the method used to compute the robustness by block. One of:

  • "exact" (the default), average on all possible networks

  • "no_empty_block" restricts the networks space to the ones with no empty block of primary species

  • "expected" restricts the networks space to the ones that have approximately the same number of species per block than the expected one. Do not do anything for ext_seq = "uniform".

approx_threshold

A numeric, the maximum size of the possible block partition allowed for exact robustness by block calculation. Higher threshold gives more precise results at the cost of computation times and possibly memory problem. Do not do anything for ext_seq = "uniform". When the threshold is exceeded the robustness is computed by a Monte Carlo approximation with approx_threshold number of samples.

net

A network, if given, the function will fit a LBM to obtain the parameters of the network and then compute the robustness.

...

Option to be passed to get_lbm_param function.

Value

A list and a robber type object:

  • $fun the robustness function, a vector of size nr +1

  • $auc the area under the curve of the robustness function

  • $block a vector of size length(pi), the block ordering for primary extinctions sequence by blocks. NULL if ext_seq = "uniform".

  • $model, $method, $ext_seq, $param.

Examples

con <- matrix(c(.5,.3,.3,.1), 2, 2)
pi  <- c(.25,.75)
rho <- c(1/3, 2/3)
nr <- 50
nc <- 30
my_rob <- robustness_lbm(con, pi, rho, nr, nc, ext_seq = "natural")
my_rob$fun
#>  [1] 9.998028e-01 9.997809e-01 9.997566e-01 9.997295e-01 9.996995e-01
#>  [6] 9.996661e-01 9.996290e-01 9.995878e-01 9.995419e-01 9.994910e-01
#> [11] 9.994345e-01 9.993717e-01 9.993018e-01 9.992243e-01 9.991381e-01
#> [16] 9.990423e-01 9.989359e-01 9.988176e-01 9.986862e-01 9.985402e-01
#> [21] 9.983780e-01 9.981977e-01 9.979974e-01 9.977747e-01 9.975273e-01
#> [26] 9.972523e-01 9.969467e-01 9.966069e-01 9.962291e-01 9.958089e-01
#> [31] 9.953410e-01 9.948189e-01 9.942333e-01 9.935693e-01 9.928002e-01
#> [36] 9.918763e-01 9.907065e-01 9.891302e-01 9.868806e-01 9.835394e-01
#> [41] 9.784834e-01 9.708142e-01 9.592501e-01 9.419345e-01 9.160936e-01
#> [46] 8.774308e-01 8.190659e-01 7.296584e-01 5.899986e-01 3.666666e-01
#> [51] 1.820766e-14
my_rob$auc
#> [1] 0.9604438
# A easier alternative way, if you don't know the parameters of the network:
data(hostparasite)
(robustness_lbm(net = hostparasite, ncores = 1L))
#> 

#> 









#> $model
#> [1] "lbm"
#> 
#> $ext_seq
#> [1] "uniform"
#> 
#> $fun
#>  [1] 0.9762710 0.9731198 0.9695500 0.9655062 0.9609254 0.9557362 0.9498579
#>  [8] 0.9431989 0.9356556 0.9271105 0.9174307 0.9064653 0.8940437 0.8799724
#> [15] 0.8640321 0.8459745 0.8255172 0.8023389 0.7760706 0.7462807 0.7124428
#> [22] 0.6738552 0.6294316 0.5771287 0.5123727 0.4236969 0.2806268 0.0000000
#> 
#> $auc
#> [1] 0.808319
#> 
#> $block
#> NULL
#> 
#> $method
#> [1] "exact"
#> 
#> $param
#> $param$con
#>            [,1]      [,2]
#> [1,] 0.03759168 0.4609027
#> [2,] 0.25445594 0.9500186
#> 
#> $param$pi
#> [1] 0.6327591 0.3672409
#> 
#> $param$rho
#> [1] 0.6877587 0.3122413
#> 
#> $param$nr
#> [1] 27
#> 
#> $param$nc
#> [1] 26
#> 
#> 
#> $sd
#>  [1] 0.03373627 0.03433957 0.03513052 0.03610450 0.03725673 0.03858187
#>  [7] 0.04007362 0.04172432 0.04352444 0.04546207 0.04752240 0.04968705
#> [13] 0.05193346 0.05423434 0.05655715 0.05886404 0.06111231 0.06325621
#> [19] 0.06525096 0.06706045 0.06866987 0.07010104 0.07141118 0.07260006
#> [25] 0.07319109 0.07082149 0.05674207 0.00000000
#> 
#> attr(,"class")
#> [1] "robber"