Building Custom ergm Terms with RStudio
RStudio is an integrated development environment (IDE) for R; it makes creating and modifying packages in R incredibly easy.
Prerequisites for building R packages
For Debian / Ubuntu, you can install the core software development utilities required for R package development as well as LaTeX by executing:
sudo apt-get install r-base-dev texlive-full
Some packages may require installation of additional R build dependencies. To provide all components needed to build R itself from source you can execute:
sudo apt-get build-dep r-base-core
For other versions of Linux please consult their documentation to determine how to install a basic GNU development tool chain and a LaTeX distribution.
Get the latest versions of R (requires R version > 3.0) and Rstudio.
Get the latest versions of the required packages from CRAN:
network (>= 1.7-1), ergm (>= 3.1-0), statnet.common (>= 3.1-0)
Enter this into R or RStudio console:
install.packages(c('network', 'ergm', 'statnet.common'))
If you are prompted to install into a personal library, click OK.
You do not need to install ergm.userterms yet!
Get ergm.userterms source
Please note that you do not at any point need to install the ergm.userterms package binaries using the install.packages command; indeed, doing so in the future may override any work you have put into building terms in your local copy.
After you download the source file, extract the downloaded ergm.userterms_3.1-0.tar.gz file, and note the location of the directory.
Project menu → Create Project→ Existing Directory → Browse →
Navigate to where you saved the source code (the folder called "ergm.userterms", see picture below) → Select Folder → Create Project
The new project should be open and ready for coding. When doing so, the three files that you will need to open and edit can be found at:
Files pane → R → InitErgmTerm.user.R
Files pane → src → changestats.users.c
Files pane → src → changestats.users.h
Coding your own custom ERGM term
If you are following these instructions in preparation for a statnet workshop, you can close everything and stop here; we will pick up from this point in the workshop. If you are learning on your own, we recommend following along with the JSS paper as a tutorial. If doing the latter, you will not need to follow the instructions in Section A3 if you are using RStudio; instead, whenever you want to build your version of the ergm.userterms package, simply click on:
Build menu → Build & Reload