ghypernet v1.0.0


Monthly downloads



Fit and Simulate Generalised Hypergeometric Ensembles of Graphs

Provides functions for model fitting and selection of generalised hypergeometric ensembles of random graphs (gHypEG). To learn how to use it, check the vignettes for a quick tutorial. Please reference its use as Casiraghi, G., Nanumyan, V. (2019) <doi:10.5281/zenodo.2555300> together with those relevant references from the one listed below. The package is based on the research developed at the Chair of Systems Design, ETH Zurich. Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2016) <arXiv:1607.02441>. Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2017) <doi:10.1007/978-3-319-67256-4_11>. Casiraghi, G., (2017) <arxiv:1702.02048> Casiraghi, G., Nanumyan, V. (2018) <arXiv:1810.06495>. Brandenberger, L., Casiraghi, G., Nanumyan, V., Schweitzer, F. (2019) <doi:10.1145/3341161.3342926> Casiraghi, G. (2019) <doi:10.1007/s41109-019-0241-1>.




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 large networks characterised by a large number of repeated edges. It provides efficient methods to perform hypothesis testing and model selection on such data.

The theoretical foundation of this paper, gHypEGs, was developed in the following works:

  1. Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2016) Generalized Hypergeometric Ensembles: Statistical Hypothesis Testing in Complex Networks. arXiv Prepr. arXiv1607.02441
  2. Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2017) From Relational Data to Graphs: Inferring Significant Links Using Generalized Hypergeometric Ensembles in Social Informatics. SocInfo 2017 111-120 (Springer Verlag, 2017). doi:10.1007/978-3-319-67256-4_11
  3. Casiraghi, G., Nanumyan, V. (2018) Generalised hypergeometric ensembles of random graphs: the configuration model as an urn problem. arXiv Prepr. arXiv1810.06495
  4. Casiraghi, G. (2018) Analytical Formulation of the Block-Constrained Configuration Model. arXiv Prepr. arXiv1811.05337


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 'colors', 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.


You can install this package directly from GitHub. In R, run the following commands to install the package:




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


Giona Casiraghi (project lead)

Vahan Nanumyan

Laurence Brandenberger


ghypernet is licensed under the GNU Affero General Public License.

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

Functions in ghypernet

Name Description
RMSLE Computes the Root Mean Squared Logged Error
adj2el Maps adjacency matrix to edgelist
bccm Fitting bccm models
as.ghype Map list to ghype object
adj_karate Zachary's Karate Club graph
coef.nrm Extraction method for coefficients of models of class 'nrm'.
BootstrapProperty BootstrapProperty computes igraph analytics function on ensemble
ghype Fitting gHypEG models
conf.test Test regular (gnp) vs configuration model
dtcommittee Swiss MPs committee affiliation data frame.
JnBlock Fisher Information matrix for estimators in block models.
RMSE Computes the Root Mean Squared Error
contacts.adj Highschool contact network adjacency matrix
checkGraphtype Check graph input type (for whether it's a graph or a edgelist).
gof.test Perform a goodness-of-fit test
highschool.multiplex Highschool contact network multiplex representation
nrmChoose Selects the best set of predictors among the given sets by means of AIC.
nrm_selection Perform AIC forward selection for nrm.
highschool.predictors Highschool contact network predictors
loglratio Compute log-likelihood ratio for ghype models.
logl General method to compute log-likelihood for ghype models.
el2adj Maps edgelist to adjacency matrix
reciprocity_stat Calculate weighted reciprocity change statistics for multi-edge graphs.
cospons_mat Swiss MPs network adjacency matrix
mcfaddenR2 Computes Mc Fadden pseudo R-squared.
homophily_stat Calculate homophily in multi-edge graphs.
residuals.nrm Method to compute residuals of nrm models
mat2vec.ix Auxiliary function, gives mask for matrix for directed, undirected etc.
lr.test Perform likelihood ratio test between two ghype models.
ComputeXi Auxiliary function. Computes combinatorial matrix.
isNetwork Test null model vs full ghype.
coxsnellR2 Computes Cox and Snell pseudo R-squared for nrm models.
rghype Generate random realisations from ghype model.
createPredictors Create a nrmpredictor object from passed argument
regularm Fit the gnm model
linkSignificance Estimate statistical deviations from ghype model
summary.nrm_selection Summary method for elements of class 'nrm_selection'. Confidence intervals for nrm models.
summary.nrm Summary method for elements of class 'nrm'.
logLik.ghype Extract Log-Likelihood
nr.significance Computes the significance of more complex model against a simpler model by means of a likelihood ratio test.
nrm Fitting gHypEG regression models for multi-edge networks.
CreateIgGraphs Convert a list of adjacency matrices to a list of igraph graphs.
FitOmega Fit propensity matrix for full model
scm Fit the Soft-Configuration Model
sharedPartner_stat Calculate (un-)weighted shared partner change statistics for multi-edge graphs.
createPredictors.list Create a nrmpredictor object from list
vec2mat Auxiliary function, produces matrix from vector
dt Swiss MPs attribute data frame.
predict.nrm Method to predict the expected values of a nrm model
onlinesim_mat Swiss MPs committee similarity matrix.
vertexlabels Zachary's Karate Club vertex faction assignment
No Results!

Vignettes of ghypernet

No Results!

Last month downloads


Type Package
Date 2020-05-11
License AGPL-3
VignetteBuilder knitr
Encoding UTF-8
RoxygenNote 7.1.0
Language en-GB
LazyData true
NeedsCompilation no
Packaged 2020-05-13 16:06:30 UTC; giona
Repository CRAN
Date/Publication 2020-05-20 15:20:02 UTC

Include our badge in your README