---
title: "Ancillary materials: network models you might need next"
engine: knitr
editor: source
subtitle: "ICPSR Network Analysis: Advanced Topics · self-study"
---

```{r}
#| label: setup
#| include: false
source("_helpers.R")
```

These are eight working documents on topics the 2026 course does not have a full slot for. Each one is complete, each one runs end to end on the machine you used in class, and each one exists because it is the thing you will plausibly need next. They are ordered below by how likely you are to reach for them, not by which lecture they came from.

None of this is graded and none of it is assumed by any later session. Think of it as a reference shelf: pull down the one that matches the problem in front of you, ignore the rest, and come back when your data changes shape.

::: {.callout-note title="How these documents work"}
Every document is a **walkthrough**, not slides: prose between runnable chunks, meant to be read and re-run on your own. They share a small set of conventions:

- **Every number and figure is produced by a chunk.** There are no screenshots of R output anywhere. If you can see it, you can reproduce it.
- **Slow fits are shipped precomputed** and reload instantly. To refit them yourself, set `options(session.refit = TRUE)` before rendering.
- **Folded boxes are optional:** open a **Depth** box for more, a **Stuck?** box for a hint, ignore whichever you do not need.
- **Exercises have a Solution tab.** You are working alone: use it.
- **A seed is set on every fit**, so your numbers should match the ones in the prose. If they do not, the "Versions" block at the foot of each document is the first thing to check.
:::

# The Shelf, in Order of How Likely You Are to Need It

This ordering is by **likelihood of need**, not by difficulty: #1 is the deepest, not the easiest. If you felt shaky in the taught ERGM/SAOM sessions, do not start at the top: begin with **#7 (`random_graphs`)**, which builds the null-model idea from scratch, and work *upward*. If you were comfortable, the top-down order is the right one.

## 1. [Temporal ERGMs](tergm.html)

**The problem it solves:** you have a network measured at several time points and you want to model *change*: reciprocation of last year's ties, the stickiness of existing relationships, delayed effects. A cross-sectional ERGM on the last wave throws all of that away.

**Extends:** the ERGM session (day 11, W3 Mon), whose final block (C4) taught the TERGM core. This is the **day-11 deep dive**, picking up where the class session stopped. **Prerequisites:** `btergm`, `network`, `networkDynamic`, `tsna`, `RSiena`, `networkdata`. If you fit the TERGM in class and want the rest, read this first. It also fits a TERGM and a SAOM to the *same* classroom data and shows where they agree and where they do not.

## 2. [A hard SAOM: diplomatic recognition (Duque 2018)](saom_duque.html)

**The problem it solves:** the taught SAOM converged quickly and looked easy. Larger applications often do not. This is a larger, directed network that **does not converge in one pass**, and the document is about reading that failure honestly rather than reporting a number you should not trust.

**Extends:** the SAOM session (day 12, W3 Tue). **Prerequisites:** `RSiena`, `networkdata`. The fit is slow, so a precomputed result is included.

## 3. [Composition change in SAOMs](saom_composition.html)

**The problem it solves:** actors who join or leave between waves: students transferring, firms folding, patients discharged. Dropping them biases what is left; SAOMs can handle them natively, and this shows how, plus why it is *not* the same as ordinary missing data.

**Extends:** the SAOM session (day 12, W3 Tue). **Prerequisites:** `RSiena` (data files ship with the document).

## 4. [ERGMs in applied political science](ergm_applications.html)

**The problem it solves:** the taught session ran on friendship data so the network itself was immediately legible. Here are two worked applications, Senate cosponsorship and rebel-group cooperation in civil wars (Gade et al. 2019), with the full build-fit-interpret pipeline.

**Extends:** the ERGM session (day 11, W3 Mon). **Prerequisites:** `ergm`, `network`, `networkdata`.

## 5. [Valued ERGMs, in depth](valued_ergm_depth.html)

**The problem it solves:** your edges have *weights*: interaction counts, message volumes, trade values, durations: not just presence/absence. The taught session introduced the idea briefly; this is the rest of it: reference measures, valued mutuality and closure, and how to check a valued fit.

**Extends:** the ERGM session (day 11, W3 Mon), block C3. **Prerequisites:** `ergm`, `ergm.count`, `network`.

## 6. [Ego-ERGMs: roles from local structure](ego_ergms.html)

**The problem it solves:** you want to group nodes by *structural role*: brokers, hubs, peripherals: rather than by community membership. Two nodes in different parts of the graph can play the same role, and community detection will never tell you that.

**Extends:** the ERGM session (day 11, W3 Mon); connects to blockmodeling (day 9, W2 Thu) and week-1 community detection. **Prerequisites:** `ergm`, `network`, and `ego_ergm()` from `networkdata`.

## 7. [Random graphs, and what a null model is for](random_graphs.html)

**The problem it solves:** the conceptual foundation under everything else: why "more clustered than chance" is meaningless until you say *than what chance*, and why that question is what ERGMs exist to answer. Mostly revision if you were here in week 1; a gentle on-ramp if you were not.

**Extends:** it is the natural thing to read *before* the ERGM session. **Prerequisites:** `igraph`, `sna`, `ergm`, `network`.

## 8. [Relational Event Models](relational_events.html)

**The problem it solves:** your data record interactions one at a time, with a sender, receiver, and timestamp, and the order or timing of those interactions is part of the question. Aggregating the stream into waves can hide immediate replies, repeated actions, and other sequence-specific patterns.

**Extends:** the temporal ERGM session (Day 11) and the SAOM session (Day 12). **Prerequisites:** `relevent` and `goldfish`, both available from CRAN. The phone-call data and precomputed fits ship with the document.

# Before You Start: An Environment Check

Run this once. If it prints `ANCILLARY SETUP OK`, every document on the shelf will run for you. If it names a missing package, install that package and re-run.

```{r}
#| label: env-check
#| cache: false
core   <- c("ergm", "ergm.count", "network", "sna", "igraph", "RSiena")
extras <- c("btergm", "networkDynamic", "tsna", "networkdata",
            "relevent", "goldfish")

missing <- c(core, extras)[!vapply(c(core, extras), requireNamespace,
                                   logical(1), quietly = TRUE)]
if (length(missing)) {
  cat("MISSING:", paste(missing, collapse = ", "), "\n")
  cat("Install CRAN packages with install.packages(); networkdata is GitHub:\n")
  cat('  remotes::install_github("ochyzh/networkdata")\n')
} else {
  cat("ANCILLARY SETUP OK\n")
  cat("R", as.character(getRversion()), "\n")
}
```

::: {.callout-tip title="One package is not on CRAN"}
`networkdata` (Olga Chyzh's data-and-tools package, which carries the diplomacy, Senate, rebel, and Lazega datasets plus `ego_ergm()`) installs from GitHub:

```r
# install.packages("remotes")
remotes::install_github("ochyzh/networkdata")
```

Installing from GitHub compiles from source, so you need build tools: **Rtools** on Windows, **Xcode command-line tools** (`xcode-select --install`) on macOS, `r-base-dev` on Linux. If the install fails on a managed or locked-down laptop and you cannot get it working, don't stall: **documents 3, 5, 7, and 8 (`saom_composition`, `valued_ergm_depth`, `random_graphs`, `relational_events`) need no `networkdata` at all**, so start there and come back to the other four once the install is sorted. Everything else is on CRAN.
:::

# A Note on Where These Came From

If you took an earlier version of this course, some of this will look familiar: these topics used to be taught as lectures. In the 2026 redesign they did not fit the seven-day structure, so rather than delete them they were rebuilt as documents you can work through at your own pace.

"Rebuilt" is the operative word. Each one was checked line by line, every fit was re-run against current package versions, and a fair number of bugs that had accumulated in the old materials were fixed along the way: some of which are called out in the documents themselves, because a wrong analysis that looks right is worth learning to spot. What you have here runs, and where a result is ugly or a model refuses to converge, the document says so rather than hiding it. That honesty is the point: the most useful thing these can teach, beyond the methods themselves, is what real analyses look like when they do not go smoothly.
