The SNAC test to measure the goodness-of-fit of the DCSBM to network data.

The function computes the SNAC+ or SNAC statistics in the paper below. The row label vector of the adjacency matrix could be given through z otherwise will be estimated by cluster_fct. One can specify the ratio of nodes used to estimate column label vector. If plus = TRUE, the column labels will be estimated by spec_clust with (K+1) clusters, i.e. performing SNAC+ test, otherwise with K clusters SNAC test. One can also get multiple test statistics with repeated random subsampling on nodes.

snac_test(
  A,
  K,
  z = NULL,
  ratio = 0.5,
  fromEachCommunity = TRUE,
  plus = TRUE,
  cluster_fct = spec_clust,
  nrep = 1,
  ...
)

Arguments

A

adjacency matrix.

K

desired number of communities.

z

label vector for rows of adjacency matrix. If not provided, will be estimated by cluster_fct

ratio

ratio of subsampled nodes from the network.

fromEachCommunity

whether subsample from each estimated community or the full network, default is TRUE

plus

whether or not use column label vector with (K+1) communities to compute the statistics, default is TRUE.

cluster_fct

community detection function to estimate label vectors, by default using spec_clust. The first two arguments have to be A and K.

nrep

number of times the statistics are computed.

...

additional arguments for cluster_fct.

Value

A list of result

stat

SNAC or SNAC+ test statistic.

z

row label vector.

References

Adjusted chi-square test for degree-corrected block models, Linfan Zhang, Arash A. Amini, arXiv preprint arXiv:2012.15047, 2020.

See also

Examples

A <- sample_dcpp(500, 10, 4, 0.1)$adj
snac_test(A, K = 4, niter = 3)$stat
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> Warning: did not converge in 3 iterations
#> [1] 0.2268875