Learn R Programming

⚠️There's a newer version (1.0.4) of this package.Take me there.

ernm

Estimation of fully/partially observed Exponential-Family Random Network Models (ERNM). ERNMs are a generalization of ERGM (see the ergm package) and Gibbs Fields, encompassing both as special cases

Adding Statistics

The preferred method for users to use their own custom statistics is to create a package as in the example extension package in inst/examplePackage. Users can then directly call register*Statistic.

For Statistics that may be useful for the wider community. They can be integrated into the ERNM package as follows. This workflow also forces users to adequately test their statistics, which may be beneficial, especially for complex statistics.

  1. Add to the inst/include/stats.h file. This is where the calculation of the statistics defined. Note for ERNM the dyadUpdate and discreteVertexUpdate and continVertexUpdate methods are crucial for the performance of the MCMC routine required to fit ERNMs.
  2. Register the statistic with the src/statController.cpp file
  3. Add the statistic to the test_stat.cpp file. This will then be run when the package is built to ensure the statistic is safe on the C++ end
  4. Add R tests in tests/testthat/test-stats.R to actually check the value of the statistic is as expected on the R end.
  5. Rebuild the package and use the statistics.

After these steps you should be able to add new statistics to your local fork of the ERNM package, and then submit a PR to have those statistics integrated into the ERNM package for others to use.

Copy Link

Version

Install

install.packages('ernm')

Monthly Downloads

544

Version

1.0.2

License

LGPL-2.1

Maintainer

Duncan Clark

Last Published

July 28th, 2025

Functions in ernm (1.0.2)

call-symbols

Internal Symbols
calculateStatistics

calculate model statistics from a formula
coef.ernm

Access ERNM parameters
mcmcse

MCMC Standard Error by Batch
dutch_school

Dutch School Data
plot.Rcpp_UndirectedNet

Plot an UndirectedNet object
summary.ernm

Summary for ernm object
ernm

Fits an ERNM model
ernmPackageSkeleton

Create an ERNM Package Skeleton
print.ernm

Print ernm object
as.network.Rcpp_UndirectedNet

Convert an Rcpp_UndirectedNet to a network object
marErnmLikelihood

likelihood for an ernm with missing data
mcmcEss

MCMC Effective Sample Size
as.network.UndirectedNet

Conversion to network object
samplike

Sampson's Monks Data
simulateStatistics

Simulate statistics
plot.ernm

Plot an ernm object
taperedErnmLikelihood

(E(g(X)) - g(x_o)^2 for TaperedModel
ernmFit

Fit an ernm
extract-methods

Subsetting and assignment for Net objects
fullErnmLikelihood

likelihood for a fully observed ernm
ernm_gof

Goodness of fit for ERNM model
register_rcpp_net_methods

Register setter methods for Rcpp net objeccts
registerDirectedStatistic

Register Statistics
runErnmCppTests

runErnmCppTests
MissingErnmModel

creates an ERNM likelihood model
as.network.DirectedNet

Conversion to network object
FullErnmModel

creates an ERNM likelihood model
as.network.Rcpp_DirectedNet

Convert and Rcpp_DirectedNet to a network object
as.BinaryNet

Convert a network to either an UndirectedNet or DirectedNet object
UndirectedNet-class

UndirectedNet Class
BinaryNet

BinaryNet
ErnmModels

Models
ErnmSamplers

Metropolis Samplers
createCppSampler

Create a sampler
DirectedNet-class

DirectedNet Class
createCppModel

Creates a model
plot.Rcpp_DirectedNet

Plot an Rcpp_UnirectedNet object
vcov.ernm

Parameter covariance matrix