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

The function computes the NAC+ or NAC statistics in the paper below. Label vectors, if not provided, are estimated using spec_clust by default but one can also use any other community detection algorithms through cluster_fct. Note that the function has to have A and K as its first two arguments, and additional arguments could be provided through ....

nac_test(A, K, z = NULL, y = NULL, plus = T, cluster_fct = spec_clust, ...)

Arguments

A

adjacency matrix.

K

number of communities.

z

label vector for rows of A. If not provided, will be estimated from cluster_fct.

y

label vector for columns of A. If not provided, will be estimated from cluster_fct.

plus

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

cluster_fct

community detection function to get z and y, by default using spec_clust. The first two arguments have to be A and K.

...

additional arguments for cluster_fct.

Value

A list of result

stat

NAC or NAC+ test statistic.

z

row label vector.

y

column 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
nac_test(A, K = 4)$stat
#> [1] 3.561323
nac_test(A, K = 4, cluster_fct = fast_cpl)$stat
#> number of iterations= 3 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 4 
#> number of iterations= 5 
#> number of iterations= 9 
#> number of iterations= 8 
#> number of iterations= 9 
#> number of iterations= 11 
#> number of iterations= 10 
#> number of iterations= 11 
#> number of iterations= 10 
#> number of iterations= 11 
#> number of iterations= 10 
#> [1] 1.252656