Day 8: Building Network Data

From raw rows to the statistical problem

Shahryar Minhas

What We Are Doing Today

First, build a defensible object

We will make explicit decisions about actors, ties, missingness, time, and covariates.

Then we will inspect what we built before asking a model to use it.

Then, find the statistical problem

The same actors recur across dyads, so the rows are coupled.

We will see a regression reject a true null about half the time and work out why.

The QMD is the complete walkthrough. These slides mark the route and give us places to stop, argue, and interpret.

Your Research Question Comes Before the R Object

Alliance network

Which states could have allied, when did they coexist, and what counts as a commitment?

Legislative network

Is the tie cosponsorship, voting agreement, communication, or service on the same coalition?

The actor roster, tie definition, direction, and time window determine the population and outcome before modeling begins.

The Four Applied Questions

For every object, summary, or model today, ask:

  1. What do we want to understand? Name the political event or relationship.
  2. How does this tool help? State what it measures, estimates, or corrects.
  3. What makes it distinct? Say what changes relative to the preceding approach.
  4. What can we say in ordinary language? Give the result without package vocabulary.

“It ran” is not an interpretation. “This network contains directed nominations among eligible classmates, with unreported dyads left missing” is.

From Raw Records to an Estimand

  1. Name the political event.
  2. Define the tie’s direction, scale, and time window.
  3. Define which actor-pairs were eligible.
  4. Build the network outcome.
  5. Attach covariates by actor identity.
  6. Audit actors, ties, missingness, and dimensions.

netify() implements these decisions. It does not make them for us.

Let’s Start With Your Research Question

Think of a network in your own research.

  1. Who are the actors?
  2. What exactly does a tie record?
  3. Can \(i \rightarrow j\) differ from \(j \rightarrow i\)?
  4. Which pairs could have formed a tie but did not?

If we cannot answer those questions in ordinary language, the software arguments will not rescue us.

Five Choices Come Before the Model

Direction

Can \(i \rightarrow j\) differ from \(j \rightarrow i\)?

Weight

Is the tie present, counted, measured, or valued?

Roster

Who exists, including actors with no observed ties?

Missingness

Does no row mean zero, unobserved, or ineligible?

Time

Are repeated rows one tie or separate periods?

These choices define the outcome, the risk set, and the population before we estimate anything.

These Are Nominations, Not Yet a Matrix

From To
s01 s03
s03 s07
s04 s07
s06 s07
s01 s08
s06 s08
s01 s09
s07 s09

What one row says

s01 -> s03 means student 1 nominated student 3.

It does not tell us whether:

  • s03 nominated s01
  • s02 was asked and nominated nobody
  • a missing row is a zero or missing observation
  • all students appear somewhere in the edge list

Before looking at any code: Is this network directed? Binary or valued? Cross-sectional or longitudinal?

The Rows Become a 30 by 30 Object

class_net <- netify(
  classroom_edges,
  actor1 = "from",
  actor2 = "to",
  symmetric = FALSE
)
    s01 s02 s03 s04 s05
s01  NA   0   1   0   0
s02   0  NA   0   0   0
s03   0   0  NA   0   0
s04   0   0   0  NA   0
s05   0   0   0   0  NA

Read it literally

  • Rows are senders
  • Columns are receivers
  • 1 is an observed nomination
  • 0 is a non-tie under the current missingness rule
  • NA on the diagonal means self-ties are not eligible

The matrix is not just storage. It is the set of outcomes the model will treat as possible.

Zero, Missing, and Ineligible Are Different

Matrix entry Claim being made Example
1 We observed a tie Student 1 nominated student 3
0 We observed or assume an eligible non-tie Student 1 could nominate student 4 but did not
NA We do not have an eligible observed outcome Self-tie, non-overlap, or unobserved dyad
No actor row The actor is outside the constructed roster An isolate disappeared because it never entered the edge list

If an isolated student disappears, what happens to density? What population does the network now describe?

missing_to_zero, the diagonal rule, and the nodelist are modeling decisions in disguise.

Read the Object Before You Analyze It

Actors

30

The roster size

Directed ties

51

Observed nominations

Density

0.059

Observed ties over eligible ordered pairs

Reciprocity

-0.062

Correlation of \(Y_{ij}\) and \(Y_{ji}\)

In netify, reciprocity is a correlation, not the proportion of observed ties that are mutual. It can be negative.

Making a Nomination and Receiving One Are Different Classroom Actions

Two questions about the same actor

Out-degree: Whom did this student nominate?

In-degree: Who nominated this student?

Student s06 made 5 nominations. Student s07 was nominated by 3 classmates.

Day 9 turns the tendency to initiate actions and the tendency to be targeted into separate actor-specific effects. Those are the quantities we technically call sender and receiver effects.

An Event Log Has a Different Problem

Source Target Date Event type
Russia Ukraine 2014-02-28 Material conflict
Russia Ukraine 2014-03-01 Verbal conflict
Russia Ukraine 2014-03-03 Material conflict
Germany Ukraine 2014-03-04 Verbal cooperation

Are the first three rows three ties, one valued tie, or three observations of a process unfolding through time?

There is no automatic answer. The correct representation depends on the substantive question.

Pooling and Keeping Time Answer Different Questions

Pool the events

netify(..., sum_dyads = TRUE)

One weighted network

Question: How much interaction occurred over the whole period?

Keep the periods

netify(..., time = "year")

One network per year

Question: How did interaction change from one period to the next?

Would averaging repeated events preserve the quantity you care about, or quietly change it?

A Longitudinal Comparison Needs a Roster Rule

Roster varies by period

Each network contains only actors observed in that period.

Apparent change can reflect actors entering and leaving the matrix.

Roster is held comparable

actor_time_uniform or an explicit nodelist defines who is at risk in each period.

Change is easier to interpret, but the rule must match the design.

If a country has no recorded events in 2015, is it an isolate, unobserved, or outside the risk set?

Covariates Join by Actor Identity

class_net <- add_node_vars(
  class_net,
  classroom_nodes,
  actor = "student",
  node_vars = c("gender", "grade", "gpa")
)

The safe rule

Join attributes using an actor key.

Never assume the row order of the node table matches the order of the adjacency matrix.

After the join, inspect actor names, missing values, and at least a few known cases.

What happens to a regression if GDP values are shifted down by one country but the dimensions still match?

Hand Off an Object You Have Checked

netify object

Outcome, roster, time, covariates

\(\Longrightarrow\)

to_lame()

Y, Xrow, Xcol, Xdyad

or

to_igraph()

Graph algorithms and plotting

Exporting is not the end of data preparation. It is the point at which our measurement choices become model inputs.

Now Look at the Rows a Regression Sees

With 30 actors

870 directed dyad rows

58 rows contain any one actor

An actor-level variable is copied across a row or column band. Unobserved actor traits affect those same bands.

Where Does the Predictor Actually Vary?

Actor attribute

\[x_{ij}=z_i\]

GDP, regime type, gender, or an ideal point

The value repeats across every dyad sent by actor \(i\).

Dyad-specific predictor

\[x_{ij}=w_{ij}\]

Distance, shared border, or a pair-specific treatment

The value can differ from one dyad to the next.

Is the apparent sample size the number of dyads, or is the important variation carried by the actors?

Build a World Where the True Effect Is Zero

Actor traits

\(a_i, a_j \sim N(0,1)\)

Unobserved sender and receiver propensities

\(\Longrightarrow\)

Outcome

\(y_{ij}=a_i+a_j+\varepsilon_{ij}\)

Dyads sharing actors have related outcomes

\(\perp\)

Predictor

\(x_{ij}=z_i\)

\(z_i\) has no causal or associational effect on \(y_{ij}\)

The coefficient is truly zero. Any rejection is a false positive.

Before we run it, which standard error is going to be too small, and why?

The Regression Rejects a True Null About Half the Time

What changed?

Not the true coefficient. It remains zero.

Not the number of rows. Each regression sees the same dyad table.

What changed is where the predictor varies and whether the uncertainty calculation respects that structure.

Sender Clustering Is Only a Preview

What it recognizes

Rows sent by the same actor may have correlated errors.

That is enough to repair much of this deliberately sender-driven simulation.

What it leaves out

Dyads can share receivers, reverse direction, time periods, and higher-order network structure.

One-way sender clustering is not a general dyadic correction.

The lesson is not “always cluster by sender.” The lesson is to identify the dependence your design and model actually create.

The Rest of the Course Makes Different Choices

Shared actor effects

Days 9 and 10

SRM, blocks, distance, and AME

Graph structure

Day 11

ERGM and TERGM

Network change

Day 12

SAOM

Inference and design

Day 13

DCR and causal inference

Compare the answers

Day 14

One network through every lens

These methods are not interchangeable repairs. They encode different questions about actors, ties, structure, time, and uncertainty.

Is Latent Structure a Nuisance or the Estimand?

Nuisance

Use latent structure to absorb residual dependence so observed covariate effects and predictions are more credible.

What it owes us: an exogeneity argument if latent effects may correlate with observed covariates.

Estimand

Treat recovered positions, roles, affinities, or influence relations as the substantive quantity to be measured.

What it owes us: identification, alignment, uncertainty, and careful interpretation of omitted structure.

Three cautions: latent maps are invariant to rotation and reflection; one graph is one dependent realization; and latent structure can absorb omitted variables.

After the Code Runs, Say What Network You Built

  1. Name the actors and who was eligible to tie.
  2. Define the tie, direction, weight, and time window.
  3. Separate observed zeros, missing dyads, and structural zeros.
  4. Report the political pattern that the next model needs to explain.

“The annual conflict network is sparse, and a small number of states initiated a large share of the recorded conflict. That pattern motivates separate model terms for how often each state initiates conflict and how often each state is targeted.”

Centrality, reciprocity, and clustering describe the network you constructed. They do not establish power, retaliation, or another mechanism by themselves.

What to Carry Into Day 9

  1. A network object records measurement choices.
  2. Zero, missing, and ineligible dyads make different claims about the risk set.
  3. Sending and receiving are different actor roles.
  4. Dyads sharing actors are statistically coupled.
  5. The effective information depends on where the variation lives, not just the number of rows.

A dyadic dataset can contain thousands of rows while carrying only a few dozen independent actor-level values.

lame_data <- to_lame(trade_net)  # Day 9 starts here