Learn R Programming

Introduction

ghypernet is an OpenSource R package that allows to estimate and work with Generalised Hypergeometric Ensembles of Random Graphs (gHypEG).

ghypernet has been developed specifically for the analysis of networks characterised by a large number of repeated edges. It provides efficient methods to perform hypothesis testing and model selection on such data.

Explore the provided Vignettes for some examples on how to analyse networks with ghypernet.

Installation

# Install ghypernet from CRAN
install.packages("ghypernet")

# Or the development version from GitHub:
devtools::install_github("gi0na/r-ghypernet")

Dependencies

The package uses the library BiasedUrn to work with Wallenius' non-central hypergeometric distribution. Although this is not required, it is recommended to install the BiasedUrn R package, increasing the number of 'colours', i.e., the number of dimensions of the distribution. It can be easily done modifying the makevar file. In case the BiasedUrn library cannot be found, all computations will be performed using the multinomial approximation.

References

The theoretical foundation of the generalised hypergeometric ensemble, gHypEGs, has been developed in the following works:

Casiraghi, G., Nanumyan, V., Scholtes, I., & Schweitzer, F. (2016). Generalized Hypergeometric Ensembles: Statistical Hypothesis Testing in Complex Networks. ArXiv Preprint ArXiv:1607.02441.

Casiraghi, G. (2017). Multiplex Network Regression: How do relations drive interactions?. ArXiv Preprint ArXiv:1702.02048, 15.

Casiraghi, G., Nanumyan, V., Scholtes, I., & Schweitzer, F. (2017). From Relational Data to Graphs: Inferring Significant Links Using Generalized Hypergeometric Ensembles (Vol. 10540, pp. 111–120). Springer Verlag.

Casiraghi, G. (2019). The block-constrained configuration model. Applied Network Science, 4(1), 123.

Brandenberger, L., Casiraghi, G., Nanumyan, V., & Schweitzer, F. (2019). Quantifying triadic closure in multi-edge social networks. Proceedings of the 2019 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining, 307–310.

Casiraghi, G., & Nanumyan, V. (2021). Configuration models as an urn problem. Sci Rep 11, 13416.

Casiraghi, G. (2021) The likelihood-ratio test for multi-edge network models. J. Phys. Complex. 2 035012.

Acknowledgements

The research and development behind ghypernet is performed at the Chair of Systems Design, ETH Zürich.

Contributors

Giona Casiraghi (project lead)

Vahan Nanumyan

Laurence Brandenberger

Copyright

ghypernet is licensed under the GNU Affero General Public License.

(c) Copyright ETH Zürich, 2016-2026

Copy Link

Version

Install

install.packages('ghypernet')

Monthly Downloads

248

Version

1.1.2

License

AGPL-3

Maintainer

Giona Casiraghi

Last Published

February 4th, 2026

Functions in ghypernet (1.1.2)

isNetwork

Test null model vs full ghype.
logLik.ghype

Extract Log-Likelihood
mat2vec.ix

Auxiliary function, gives mask for matrix for directed, undirected etc.
residuals.nrm

Method to compute residuals of nrm models
mcfaddenR2

Computes Mc Fadden pseudo R-squared.
regularm

Fit the gnm model
vec2mat

Auxiliary function, produces matrix from vector
nrmChoose

Selects the best set of predictors among the given sets by means of AIC.
logl

General method to compute log-likelihood for ghype models.
vertexlabels

Zachary's Karate Club vertex faction assignment
homophily_stat

Calculate homophily in multi-edge graphs.
loglratio

Compute log-likelihood ratio for ghype models.
lr.test

Perform likelihood ratio test between two ghype models.
create_predictors.list

Create a nrmpredictor object from list
CreateIgGraphs

Convert a list of adjacency matrices to a list of igraph graphs.
linkSignificance

Estimate statistical deviations from ghype model
conf.test

Test regular (gnp) vs configuration model
compute_xi

Auxiliary function. Computes combinatorial matrix.
nrmSelection

Perform AIC forward selection for nrm.
nr.ci

Confidence intervals for nrm models.
nr.significance

Computes the significance of more complex model against a simpler model by means of a likelihood ratio test.
summary.nrm

Summary method for elements of class 'nrm'.
summary.nrm_selection

Summary method for elements of class 'nrm_selection'.
gof.test

Perform a goodness-of-fit test
nrm

Fitting gHypEG regression models for multi-edge networks.
dtcommittee

Swiss MPs committee affiliation data frame.
onlinesim_mat

Swiss MPs committee similarity matrix.
adj_karate

Zachary's Karate Club graph
dt

Swiss MPs attribute data frame.
dmvhyper_base

Log PMF of multivariate hypergeometric
rghype

Generate random realisations from ghype model.
highschool.multiplex

Highschool contact network multiplex representation
rmvhyper_base

Random samples from multivariate hypergeometric
predict.nrm

Method to predict the expected values of a nrm model
reciprocity_stat

Calculate weighted reciprocity change statistics for multi-edge graphs.
scm

Fit the Soft-Configuration Model
sharedPartner_stat

Calculate (un-)weighted shared partner change statistics for multi-edge graphs.
FitOmega

Fit propensity matrix for full model
RMSE

Computes the Root Mean Squared Error
BootstrapProperty

BootstrapProperty computes igraph analytics function on ensemble
adj2el

Maps adjacency matrix to edgelist
JnBlock

Fisher Information matrix for estimators in block models.
RMSLE

Computes the Root Mean Squared Logged Error
coef.nrm

Extraction method for coefficients of models of class 'nrm'.
contacts.adj

Highschool contact network adjacency matrix
create_predictors

Create a nrmpredictor object from passed argument
as.ghype

Map list to ghype object
el2adj

Maps edgelist to adjacency matrix
coxsnellR2

Computes Cox and Snell pseudo R-squared for nrm models.
checkGraphtype

Check graph input type (for whether it's a graph or a edgelist).
bccm

Fitting bccm models
extract.nrm.cluster

Extract details from statistical models for table construction. The function has methods for a range of statistical models.
get_zero_dummy

Create a dummy variable to encode zero values of another variable.
ghype

Fitting gHypEG models
highschool.predictors

Highschool contact network predictors
cospons_mat

Swiss MPs network adjacency matrix