linkSignificance allows to estimate the statistical deviations of an observed graph from a ghype model.

linkSignificance(
  graph,
  model,
  under = FALSE,
  log.p = FALSE,
  binomial.approximation = FALSE,
  give_pvals = FALSE
)

link_significance(
  graph,
  model,
  under = FALSE,
  log.p = FALSE,
  binomial.approximation = FALSE,
  give_pvals = TRUE
)

Arguments

graph

an adjacency matrix or a igraph object.

model

a ghype model

under

boolean, estimate under-represented deviations? Default FALSE: i.e. returns over representation

log.p

boolean, return log values of probabilities

binomial.approximation

boolean, force binomial? default FALSE

give_pvals

boolean, return p-values for both under and over significance? when FALSE, it returns probabilty of observing stricly more (or less) edges than in graph. When TRUE returns probability of observing exactly as many edges or more (less) than in graph, like a standard pvalue.

Value

matrix of probabilities with same size as adjacency matrix.

Examples

data("adj_karate")
fullmodel <- ghype(graph = adj_karate, directed = FALSE, selfloops = FALSE)
link_significance(graph = adj_karate, model = fullmodel, under=FALSE)
#>            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#>  [1,] 0.0000000 0.5664955 0.5594483 0.5768615 0.5771274 0.5769230 0.5769443
#>  [2,] 0.5664955 0.0000000 0.5543444 0.5769599 1.0000000 1.0000000 1.0000000
#>  [3,] 0.5594483 0.5543444 0.0000000 0.5769214 1.0000000 1.0000000 1.0000000
#>  [4,] 0.5768615 0.5769599 0.5769214 0.0000000 1.0000000 1.0000000 1.0000000
#>  [5,] 0.5771274 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000 0.5950861
#>  [6,] 0.5769230 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 0.5605329
#>  [7,] 0.5769443 1.0000000 1.0000000 1.0000000 0.5950861 0.5605329 0.0000000
#>  [8,] 0.5941000 0.5668550 0.5667915 0.5773456 1.0000000 1.0000000 1.0000000
#>  [9,] 0.5940446 1.0000000 0.5596907 1.0000000 1.0000000 1.0000000 1.0000000
#> [10,] 1.0000000 1.0000000 0.6328494 1.0000000 1.0000000 1.0000000 1.0000000
#> [11,] 0.5942444 1.0000000 1.0000000 1.0000000 0.5791433 0.5780856 1.0000000
#> [12,] 0.5778563 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [13,] 0.6325276 1.0000000 1.0000000 0.5788268 1.0000000 1.0000000 1.0000000
#> [14,] 0.5768741 0.5597474 0.5769374 0.5771820 1.0000000 1.0000000 1.0000000
#> [15,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [16,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [17,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5785385 0.5786845
#> [18,] 0.5948187 0.6329616 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [19,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [20,] 0.5944608 0.5947299 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [21,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [22,] 0.5945998 0.5949318 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [23,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [24,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [25,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [26,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [27,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [28,] 1.0000000 1.0000000 0.5941651 1.0000000 1.0000000 1.0000000 1.0000000
#> [29,] 1.0000000 1.0000000 0.5945035 1.0000000 1.0000000 1.0000000 1.0000000
#> [30,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [31,] 1.0000000 0.5942688 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [32,] 0.5940101 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [33,] 1.0000000 1.0000000 0.5939668 1.0000000 1.0000000 1.0000000 1.0000000
#> [34,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>            [,8]      [,9]     [,10]     [,11]     [,12]     [,13]     [,14]
#>  [1,] 0.5941000 0.5940446 1.0000000 0.5942444 0.5778563 0.6325276 0.5768741
#>  [2,] 0.5668550 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5597474
#>  [3,] 0.5667915 0.5596907 0.6328494 1.0000000 1.0000000 1.0000000 0.5769374
#>  [4,] 0.5773456 1.0000000 1.0000000 1.0000000 1.0000000 0.5788268 0.5771820
#>  [5,] 1.0000000 1.0000000 1.0000000 0.5791433 1.0000000 1.0000000 1.0000000
#>  [6,] 1.0000000 1.0000000 1.0000000 0.5780856 1.0000000 1.0000000 1.0000000
#>  [7,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [8,] 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [9,] 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [10,] 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [11,] 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000
#> [12,] 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000
#> [13,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000
#> [14,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000
#> [15,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [16,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [17,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [18,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [19,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [20,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [21,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [22,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [23,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [24,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [25,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [26,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [27,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [28,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [29,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [30,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [31,] 1.0000000 0.5775184 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [32,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [33,] 1.0000000 0.5768985 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [34,] 1.0000000 0.5665742 0.5947003 1.0000000 1.0000000 1.0000000 0.5768452
#>           [,15]     [,16]     [,17]     [,18]     [,19]     [,20]     [,21]
#>  [1,] 1.0000000 1.0000000 1.0000000 0.5948187 1.0000000 0.5944608 1.0000000
#>  [2,] 1.0000000 1.0000000 1.0000000 0.6329616 1.0000000 0.5947299 1.0000000
#>  [3,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [4,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [5,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [6,] 1.0000000 1.0000000 0.5785385 1.0000000 1.0000000 1.0000000 1.0000000
#>  [7,] 1.0000000 1.0000000 0.5786845 1.0000000 1.0000000 1.0000000 1.0000000
#>  [8,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [9,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [10,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [11,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [12,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [13,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [14,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [15,] 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [16,] 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [17,] 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [18,] 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000
#> [19,] 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000 1.0000000
#> [20,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000
#> [21,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000
#> [22,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [23,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [24,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [25,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [26,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [27,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [28,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [29,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [30,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [31,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [32,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [33,] 0.5774819 0.5772515 1.0000000 1.0000000 0.6327416 1.0000000 0.5776771
#> [34,] 0.5943862 0.5669085 1.0000000 1.0000000 0.5947003 0.6323844 0.6324661
#>           [,22]     [,23]     [,24]     [,25]     [,26]     [,27]     [,28]
#>  [1,] 0.5945998 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [2,] 0.5949318 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [3,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5941651
#>  [4,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [5,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [6,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [7,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [8,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [9,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [10,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [11,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [12,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [13,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [14,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [15,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [16,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [17,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [18,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [19,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [20,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [21,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [22,] 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [23,] 1.0000000 0.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [24,] 1.0000000 1.0000000 0.0000000 1.0000000 0.5600598 1.0000000 0.5670525
#> [25,] 1.0000000 1.0000000 1.0000000 0.0000000 0.5951499 1.0000000 0.5784029
#> [26,] 1.0000000 1.0000000 0.5600598 0.5951499 0.0000000 1.0000000 1.0000000
#> [27,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 1.0000000
#> [28,] 1.0000000 1.0000000 0.5670525 0.5784029 1.0000000 1.0000000 0.0000000
#> [29,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [30,] 1.0000000 1.0000000 0.5772450 1.0000000 1.0000000 0.5687802 1.0000000
#> [31,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [32,] 1.0000000 1.0000000 1.0000000 0.5947271 0.5510257 1.0000000 1.0000000
#> [33,] 1.0000000 0.5945239 0.5595693 1.0000000 1.0000000 1.0000000 1.0000000
#> [34,] 1.0000000 0.5773072 0.5665286 1.0000000 1.0000000 0.5943029 0.5666475
#>           [,29]     [,30]     [,31]     [,32]     [,33]     [,34]
#>  [1,] 1.0000000 1.0000000 1.0000000 0.5940101 1.0000000 1.0000000
#>  [2,] 1.0000000 1.0000000 0.5942688 1.0000000 1.0000000 1.0000000
#>  [3,] 0.5945035 1.0000000 1.0000000 1.0000000 0.5939668 1.0000000
#>  [4,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [5,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [6,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [7,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [8,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#>  [9,] 1.0000000 1.0000000 0.5775184 1.0000000 0.5768985 0.5665742
#> [10,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5947003
#> [11,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [12,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [13,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [14,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5768452
#> [15,] 1.0000000 1.0000000 1.0000000 1.0000000 0.5774819 0.5943862
#> [16,] 1.0000000 1.0000000 1.0000000 1.0000000 0.5772515 0.5669085
#> [17,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [18,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [19,] 1.0000000 1.0000000 1.0000000 1.0000000 0.6327416 0.5947003
#> [20,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.6323844
#> [21,] 1.0000000 1.0000000 1.0000000 1.0000000 0.5776771 0.6324661
#> [22,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [23,] 1.0000000 1.0000000 1.0000000 1.0000000 0.5945239 0.5773072
#> [24,] 1.0000000 0.5772450 1.0000000 1.0000000 0.5595693 0.5665286
#> [25,] 1.0000000 1.0000000 1.0000000 0.5947271 1.0000000 1.0000000
#> [26,] 1.0000000 1.0000000 1.0000000 0.5510257 1.0000000 1.0000000
#> [27,] 1.0000000 0.5687802 1.0000000 1.0000000 1.0000000 0.5943029
#> [28,] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.5666475
#> [29,] 0.0000000 1.0000000 1.0000000 0.5948647 1.0000000 0.5943029
#> [30,] 1.0000000 0.0000000 1.0000000 1.0000000 0.5667308 0.5940702
#> [31,] 1.0000000 1.0000000 0.0000000 1.0000000 0.5770358 0.5769537
#> [32,] 0.5948647 1.0000000 1.0000000 0.0000000 0.5665801 0.5665286
#> [33,] 1.0000000 0.5667308 0.5770358 0.5665801 0.0000000 0.5594095
#> [34,] 0.5943029 0.5940702 0.5769537 0.5665286 0.5594095 0.0000000