These functions conduct tests of any network-level statistic:

  • test_random() performs a conditional uniform graph (CUG) test of a measure against a distribution of measures on random networks of the same dimensions.

  • test_permutation() performs a quadratic assignment procedure (QAP) test of a measure against a distribution of measures on permutations of the original network.

  • test_gof() performs a chi-squared test on the squared Mahalanobis distance between a diff_model and diff_models objects.

test_random(
  .data,
  FUN,
  ...,
  times = 1000,
  strategy = "sequential",
  verbose = FALSE
)

test_permutation(
  .data,
  FUN,
  ...,
  times = 1000,
  strategy = "sequential",
  verbose = FALSE
)

test_gof(diff_model, diff_models)

Arguments

.data

An object of a {manynet}-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

FUN

A graph-level statistic function to test.

...

Additional arguments to be passed on to FUN, e.g. the name of the attribute.

times

Integer indicating number of simulations used for quantile estimation. (Relevant to the null hypothesis test only - the analysis itself is unaffected by this parameter.) Note that, as for all Monte Carlo procedures, convergence is slower for more extreme quantiles. By default, times=1000. 1,000 - 10,000 repetitions recommended for publication-ready results.

strategy

If {furrr} is installed, then multiple cores can be used to accelerate the function. By default "sequential", but if multiple cores available, then "multisession" or "multicore" may be useful. Generally this is useful only when times > 1000. See {furrr} for more.

verbose

Whether the function should report on its progress. By default FALSE. See {progressr} for more.

diff_model

A diff_model object is returned by play_diffusion() or as_diffusion() and contains a single empirical or simulated diffusion.

diff_models

A diff_models object is returned by play_diffusions() and contains a series of diffusion simulations.

Mahalanobis distance

test_gof() takes a single diff_model object, which may be a single empirical or simulated diffusion, and a diff_models object containing many simulations. Note that currently only the goodness of fit of the

It returns a tibble (compatible with broom::glance()) that includes the Mahalanobis distance statistic between the observed and simulated distributions. It also includes a p-value summarising a chi-squared test on this statistic, listing also the degrees of freedom and number of observations. If the p-value is less than the convention 0.05, then one can argue that the first diffusion is not well captured by

See also

Other models: regression

Examples

marvel_friends <- to_unsigned(ison_marvel_relationships)
marvel_friends <- to_giant(marvel_friends) %>% 
  to_subgraph(PowerOrigin == "Human")
(cugtest <- test_random(marvel_friends, network_heterophily, attribute = "Attractive",
  times = 200))
#> 
#>  CUG Test Results
#> 
#> Observed Value: -0.8571429 
#> Pr(X>=Obs): 1 
#> Pr(X<=Obs): 0 
#> 
plot(cugtest)

(qaptest <- test_permutation(marvel_friends, 
                network_heterophily, attribute = "Attractive",
                times = 200))
#> 
#>  QAP Test Results
#> 
#> Observed Value: -0.8571429 
#> Pr(X>=Obs): 0.99 
#> Pr(X<=Obs): 0.06 
#> 
plot(qaptest)

  # Playing a reasonably quick diffusion
  x <- play_diffusion(generate_random(15), transmissibility = 0.7)
  # Playing a slower diffusion
  y <- play_diffusions(generate_random(15), transmissibility = 0.1, times = 40)
  plot(x)

  plot(y)

  test_gof(x, y)
#> # A tibble: 1 × 4
#>   statistic  p.value    df  nobs
#>       <dbl>    <dbl> <int> <int>
#> 1      96.6 5.81e-14    15    40