Learn R Programming

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')

Version

1.0.0

License

LGPL-2.1

Maintainer

Duncan Clark

Last Published

April 10th, 2025

Functions in ernm (1.0.0)

plot.ernm

plot an ernm object
fullErnmLikelihood

likelihood for a fully observed ernm
marErnmLikelihood

likelihood for an ernm with missing data
vcov.ernm

parameter covariance matrix
mcmcEss

MCMC Effective Sample Size
mcmcse

MCMC Standard Error by Batch
summary.ernm

summary
taperedErnmLikelihood

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

Create an ERNM Package Skeleton
ernmFit

fit an ernm model
ernm_gof

print
extract-methods

Subsetting and assignment for Net objects
print.ernm

print
plot.DirectedNet

plot an DirectedNet object
plot.UndirectedNet

plot an UndirectedNet object
samplike

Sampson's Monks Data
simulateStatistics

simulate statistics
ErnmSamplers

Metropolis Samplers
MissingErnmModel

creates an ERNM likelihood model
DirectedNet-class

DirectedNet Class
FullErnmModel

creates an ERNM likelihood model
as.network.DirectedNet

convert and DirectedNet to a network object
UndirectedNet-class

UndirectedNet Class
as.BinaryNet

convert and network to either an UndirectedNet or DirectedNet object
BinaryNet

BinaryNet
ErnmModels

Models
as.network.UndirectedNet

convert and UndirectedNet to a network object
calculateStatistics

calculate model statistics from a formula
call-symbols

Internal Symbols
ernm

fits an ERNM model
dutch_school

Dutch School Data
createCppModel

creates a model
createCppSampler

create a sampler
runErnmCppTests

runErnmCppTests
registerDirectedStatistic

Register Statistics