ergm.userterms-package: User-defined terms used in Exponential Family Random Graph...

Description Creating User-defined terms using this package References See Also Examples

Description

This package contains template code for user defined (change) statistics that can be used with the statnet suite of packages (and ergm in particular). To use this package the statnet packages ergm and network are required.

As background, statnet is a suite of software packages for statistical network analysis. The packages implement recent advances in network modeling based on exponential-family random graph models (ERGM). The components of the package provide a comprehensive framework for ERGM-based network modeling: tools for model estimation, for model evaluation, for model-based network simulation, and for network visualization. This broad functionality is powered by a central Markov chain Monte Carlo (MCMC) algorithm. The coding is optimized for speed and robustness. For detailed information on how to download and install the software, go to the ergm website: statnet.org. A tutorial, support newsgroup, references and links to further resources are provided there.

When publishing results obtained using this package the original authors are to be cited as:

Mark S. Handcock, David R. Hunter, Carter T. Butts, Steven M. Goodreau, and Martina Morris. 2003 statnet: Software tools for the Statistical Modeling of Network Data
statnet.org.

We have invested a lot of time and effort in creating the statnet suite of packages for use by other researchers. Please cite it in all papers where it is used.

For complete citation information, use
citation(package="statnet").

Creating User-defined terms using this package

The statnet suite of packages allows the user to explore a large number of potential models for their network data. These can be seen by typing help("ergm-terms",package="ergm") (once the package ergm has been installed). For more information on the models and terms see Morris, Handcock, and Hunter (2008).

The purpose of the package is to allow additional terms can be coded up by users (you!) and be used at native speeds with statnet. So the suite of packages can be extended with minimal work by the user. In addition the core packages are not altered and so the new packages benefit from improvements to the core suite.

The process of creating new terms is explained in depth by the document entitled by Hunter, Goodreau, and Handcock (2010) that is found in the inst/doc directory of this package.

In brief, to add a new term you need to (all file references are relative to the package directory).:

1. Download the source version of this package. For example, in R use

download.packages("ergm.userterms", destdir=".", type="source")

where destdir is the directory to save the source (e.g., ergm.userterms_3.0.tar.gz) in.

2. Unpack the source into a directory (e.g., on Linux or the Mac tar -vzxf ergm.userterms_3.0.tar.gz).

3. Optionally, rename the package name from ergm.userterms to some something more evocative of its use (e.g., myergm). This can be done using a global change to the files in the directory. Optionally, edit the DESCRIPTION file to reflect the use of the package.

4. Edit R/InitErgmTerm.users.R to add R InitErgmTerm functions for the new terms.

5. Edit src/changestats.users.c to add C functions (like the example already in that file) to compute the new change statistics.

6. Compile the package using the usual R tools (e.g., R CMD build myergm and R CMD INSTALL myergm).

7. Run it! It depends on ergm and network, of course. See the example below.

References

Hunter DR, Goodreau SM, Handcock MS (2013). ergm.userterms: A Template Package for Extending statnet, Journal of Statistical Software 52(2), 1-25, URL http://www.jstatsoft.org/v52/i02/.

See Also

statnet, network, ergm, ergm-terms

Examples

1
2
3
4
data(faux.mesa.high)
summary(faux.mesa.high~mindegree(2))
fit <- ergm(faux.mesa.high~mindegree(2), estimate="MPLE")
summary(fit)

Example output

Loading required package: network
network: Classes for Relational Data
Version 1.13.0.1 created on 2015-08-31.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Martina Morris, University of Washington
                    Skye Bender-deMoll, University of Washington
 For citation information, type citation("network").
 Type help("network-package") to get started.

Loading required package: ergm

ergm: version 3.9.4, created on 2018-08-15
Copyright (c) 2018, Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Carter T. Butts, University of California -- Irvine
                    Steven M. Goodreau, University of Washington
                    Pavel N. Krivitsky, University of Wollongong
                    Martina Morris, University of Washington
                    with contributions from
                    Li Wang
                    Kirk Li, University of Washington
                    Skye Bender-deMoll, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("ergm").

NOTE: Versions before 3.6.1 had a bug in the implementation of the bd()
constriant which distorted the sampled distribution somewhat. In
addition, Sampson's Monks datasets had mislabeled vertices. See the
NEWS and the documentation for more details.

Loading required package: statnet.common

Attaching package: 'statnet.common'

The following objects are masked from 'package:ergm':

    colMeans.mcmc.list, sweep.mcmc.list

The following object is masked from 'package:base':

    order


ergm.userterms: version 3.1.1, created on 2013-04-26
Copyright (c) 2013, Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Carter T. Butts, University of California -- Irvine
                    Steven M. Goodreau, University of Washington
                    Pavel N. Krivitsky, University of Wollongong
                    Martina Morris, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("ergm.userterms").

NOTE: If you use custom ERGM terms based on 'ergm.userterms' version
prior to 3.1, you will need to perform a one-time update of the package
boilerplate files (the files that you did not write or modify) from
'ergm.userterms' 3.1 or later. See help('eut-upgrade') for
instructions.

Warning messages:
1: replacing previous import 'statnet.common::sweep.mcmc.list' by 'ergm::sweep.mcmc.list' when loading 'ergm.userterms' 
2: replacing previous import 'statnet.common::colMeans.mcmc.list' by 'ergm::colMeans.mcmc.list' when loading 'ergm.userterms' 
mindegree2 
        97 
Starting maximum pseudolikelihood estimation (MPLE):
Evaluating the predictor and response matrix.
Maximizing the pseudolikelihood.
Finished MPLE.
Stopping at the initial estimate.
Evaluating log-likelihood at the estimate. 

==========================
Summary of model fit
==========================

Formula:   faux.mesa.high ~ mindegree(2)

Iterations:  NA 

Maximum Pseudolikelihood Results:
           Estimate Std. Error MCMC % z value Pr(>|z|)    
mindegree2  -4.8709     0.1294      0  -37.64   <1e-04 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Warning:  The standard errors are based on naive pseudolikelihood and are suspect.

     Null Pseudo-deviance: 28987  on 20910  degrees of freedom
 Residual Pseudo-deviance: 17022  on 20909  degrees of freedom
 
AIC: 17024    BIC: 17031    (Smaller is better.) 

ergm.userterms documentation built on May 15, 2019, 9:03 a.m.