Goodness of fit statistics for bipartite networks
Source:R/gof_stats_bipartite.R
gof_stats_bipartite.RdCalculates goodness of fit statistics specifically designed for bipartite networks, evaluating degree heterogeneity and higher-order dependencies.
Arguments
- Y
a bipartite relational data matrix (nA x nB rectangular matrix) where Y\[i,j\] represents the relationship from node i in set A to node j in set B. Missing values (NA) are allowed and will be handled appropriately.
- warn_square
logical; if
TRUE(default) a warning is issued whenYis square (a possible unipartite matrix passed by mistake). SetFALSEfor a genuinely square bipartite network.- family
optional outcome family. For
"normal", use weighted four-cycle dependence instead of a nonzero-edge count. Model fitting and post-hoc diagnostics supply this automatically.
Value
A named numeric vector containing bipartite-specific goodness-of-fit statistics:
- sd.rowmean
Standard deviation of row means. Measures the heterogeneity in out-degree from set A nodes (sender effects). Higher values indicate more variation in how active A nodes are.
- sd.colmean
Standard deviation of column means. Measures the heterogeneity in in-degree to set B nodes (receiver effects). Higher values indicate more variation in how popular B nodes are.
- four.cycle.dep
For Gaussian outcomes, weighted dependence over complete observed rectangles, as defined below. Replaces the count.
- four.cycles
Count of four-cycles (also called 4-paths or squares) in the bipartite network. A four-cycle occurs when two nodes from set A (e.g., i and k) both connect to the same two nodes in set B (e.g., j and l), forming a closed path: i->j->k->l->i. This measures the tendency for pairs of A-nodes to share multiple common B-node connections, capturing a form of clustering specific to bipartite networks. High four-cycle counts indicate that connections are not random but show patterns of shared preferences or co-occurrence. For example, in a user-item network, many four-cycles suggest that users who like one item tend to also like other items that co-occur with it.
Details
For Gaussian outcomes, four.cycle.dep is the mean product of
four globally centered, sample-standardized values around each fully
observed rectangle. It measures dependence among edge magnitudes.
It returns NA when no complete rectangle is observed or the
observed values have zero variance. Missing cells are not zeros.
A nonzero-edge count is unsuitable for Gaussian predictive checks:
continuous draws are nonzero almost surely, so fixing the observation
mask fixes their four-cycle count regardless of model fit.
For bipartite networks, reciprocity and triadic closure are not meaningful concepts since edges only exist between the two node sets. Instead, this function focuses on:
Degree heterogeneity in both node sets
Four-cycles as the simplest higher-order dependence pattern