Ising networks for binary data

Written by Mohammed Saqr and Sonsoles López-Pernas

Much psychological and educational data is binary: a symptom is present or absent, a diagnostic criterion is met or not, an item is passed or failed, a behaviour is reported or not. Correlations between such variables are poorly defined, and partial correlation networks built for continuous data do not apply. The Ising model is the network model for binary variables. Each edge is an interaction on the log-odds scale: a positive edge means that when one variable takes the value 1, the other is more likely to take the value 1, with all other variables held constant; a negative edge means it is less likely. A missing edge means that the association between the two variables is accounted for by the rest of the network (van Borkulo et al., 2014).

This article estimates a regularized Ising network for five binary indicators of self-regulated learning, reads its interactions, describes the nodes by centrality and by how well each is classified from the others, and compares the result with an unregularized estimator.

library(psychnets)

Data

SRL_GPT holds 300 sets of responses to the Motivated Strategies for Learning Questionnaire. The responses were generated by a large language model (GPT) in a study of how such models answer psychological surveys (Saqr, 2025); they serve as a well-structured example and are not evidence about students. The construct scores are continuous, so for this example dichotomize() with method = "rank" codes each score as 1 when it lies in the upper half of its distribution and 0 otherwise.

binary_data <- dichotomize(data = SRL_GPT, method = "rank")
head(binary_data)
#>      CSU IV SE SR TA
#> [1,]   0  0  0  0  1
#> [2,]   1  1  1  1  1
#> [3,]   1  1  1  1  0
#> [4,]   0  1  1  0  1
#> [5,]   0  0  0  0  1
#> [6,]   0  0  0  0  0
colMeans(binary_data)
#>       CSU        IV        SE        SR        TA 
#> 0.4966667 0.5366667 0.4766667 0.4600000 0.5000000

Between 46% and 54% of the respondents are coded 1 on each indicator; the split is not exactly half because tied scores stay on the same side. Dichotomizing discards information, so it is justified only when the research question concerns the two states; naturally binary variables are analysed as they are.

The model

For a binary vector \(\mathbf{x} \in \{0, 1\}^p\), the Ising model gives

\[P(\mathbf{x}) = \frac{1}{Z}\exp\left(\sum_i \tau_i x_i + \sum_{i<j}\omega_{ij}x_i x_j\right),\]

where \(\tau_i\) is the threshold of node \(i\) (its tendency to be 1 when all other nodes are 0), \(\omega_{ij}\) the interaction between nodes \(i\) and \(j\), and \(Z\) the normalizing constant. The conditional distribution of one node is a logistic regression on the others,

\[\operatorname{logit} P(X_i = 1 \mid \mathbf{X}_{-i}) = \tau_i + \sum_{j \ne i}\omega_{ij}X_j ,\]

so \(\exp(\omega_{ij})\) is the conditional odds ratio of \(X_i = 1\) when \(X_j\) changes from 0 to 1.

The network is estimated one node at a time. Each node is regressed on all the others by \(\ell_1\)-penalized logistic regression, and the penalty is selected by the extended BIC with \(\gamma = 0.25\). Each pair thus receives two estimates. Under the AND rule a pair is retained when both regressions select it, under the OR rule when either does, and the retained pair’s weight is the mean of the two estimates.

Which indicators are directly associated?

psychnet() with method = "ising" estimates the network; rule = "AND" is the default and is stated here for clarity.

ising_net <- psychnet(data = binary_data, method = "ising", rule = "AND")
summary(ising_net)
#> <psychnet> ising network
#>   nodes: 5   edges: 6   (undirected)
#>   optimality (KKT residual): 4.90e-10
#>   edge weight: range [0.853, 2.192], mean 1.573
as.data.frame(ising_net)
#>   from to    weight
#> 1  CSU IV 2.0693278
#> 2  CSU SE 2.1915348
#> 3   IV SE 0.9334331
#> 4  CSU SR 0.8529154
#> 5   IV SR 2.1108751
#> 6   SE SR 1.2808939

The network has 6 edges, all positive and all among the four learning constructs, with weights from 0.853 to 2.192. The strongest is CSU–SE (2.192): with the other indicators held constant, being in the upper half of cognitive strategy use multiplies the odds of being in the upper half of self-efficacy by about 9 (\(e^{2.192}\)). The weakest, CSU–SR (0.853), still corresponds to an odds ratio of about 2.3.

Test anxiety has no edge. Once the learning constructs are known, being in its upper half is unrelated to any of them. The Gaussian network of the continuous scores has a clear negative edge between self-regulation and test anxiety (-0.350; see the Gaussian graphical models article), so its absence here shows how much information the median split removes.

Is the fitted network the optimum of its objective?

Each penalized logistic regression is solved iteratively. Any solution must satisfy the problem’s optimality (Karush–Kuhn–Tucker) conditions; the amount by which a fitted network violates them, the largest over the five regressions, is its certificate, and a value near zero shows that the network is the optimum of its objective.

certificate(ising_net)
#>   method  certificate kind certified
#> 1  ising 4.895834e-10  kkt      TRUE

The violation is \(4.90 \times 10^{-10}\), so the interactions are the solutions of the penalized regressions. The certificate concerns the computation, not the sampling stability of the edges or the validity of the binary coding.

Which indicators are most connected?

net_centralities() returns strength, the sum of absolute interactions, and expected influence, the signed sum.

net_centralities(ising_net)
#>   node strength expected_influence
#> 1  CSU 5.113778           5.113778
#> 2   IV 5.113636           5.113636
#> 3   SE 4.405862           4.405862
#> 4   SR 4.244684           4.244684
#> 5   TA 0.000000           0.000000

Cognitive strategy use and intrinsic value have the highest strength (5.114), followed by self-efficacy (4.406) and self-regulation (4.245). All edges are positive, so expected influence equals strength, and test anxiety, without edges, has 0 on both. The four learning indicators are about equally central, and test anxiety stands apart from them.

How well is each indicator classified from the others?

For a binary node, predictability is the classification accuracy of its nodewise model, normalized against the accuracy of always predicting the more frequent category (Haslbeck & Waldorp, 2018):

\[\operatorname{nCC}_j = \frac{\operatorname{CC}_j - m_j}{1 - m_j},\]

where \(\operatorname{CC}_j\) is the proportion classified correctly and \(m_j\) the proportion in the larger category. An nCC of 0 means no gain over the base rate and 1 means perfect classification. net_predict() needs the data to compute it.

net_predict(ising_net, data = binary_data)
#>   node   type metric predictability  accuracy
#> 1  CSU binary    nCC      0.7114094 0.8566667
#> 2   IV binary    nCC      0.7338129 0.8766667
#> 3   SE binary    nCC      0.6993007 0.8566667
#> 4   SR binary    nCC      0.6376812 0.8333333
#> 5   TA binary    nCC      0.0000000 0.5000000

Intrinsic value is classified best, with 87.7% correct and nCC = 0.734. Cognitive strategy use (nCC = 0.711) and self-efficacy (0.699), both 85.7% correct, and self-regulation (0.638, 83.3% correct) follow. Test anxiety has nCC = 0 and 50% correct: without neighbours it is predicted no better than by its base rate. These are in-sample values.

Does an unregularized estimator find the same network?

method = "ising_sampler" fits the nodewise logistic regressions without a penalty and removes the interactions whose Wald test is not significant at alpha. Agreement with the penalized network shows that the structure does not depend on the penalty.

unregularized_net <- psychnet(data = binary_data, method = "ising_sampler",
                              alpha = 0.05)
unregularized_net
#> <psychnet> ising_sampler network
#>   nodes: 5   edges: 6   (undirected)
#>   optimality: unavailable
as.data.frame(unregularized_net)
#>   from to    weight
#> 1  CSU IV 2.2425237
#> 2  CSU SE 2.3454742
#> 3   IV SE 1.1870117
#> 4  CSU SR 0.8818853
#> 5   IV SR 2.2882117
#> 6   SE SR 1.4609560

The unregularized network has the same 6 edges, and test anxiety is again isolated. Its interactions are larger, CSU–SE 2.345 instead of 2.192 and IV–SR 2.288 instead of 2.111, because no penalty shrinks them. The structure is therefore not a product of regularization.

certificate(unregularized_net)
#>          method certificate kind certified
#> 1 ising_sampler          NA  kkt        NA

The certificate is NA. After the Wald pruning sets non-significant interactions to zero, the network is no longer the maximum-likelihood solution whose optimality conditions the certificate checks. The penalized network above is the one with a certified optimum.

What does the network look like?

cograph::splot() draws the network, with green positive and red negative edges and a ring showing each node’s predictability.

cograph::splot(ising_net, psych_styling = TRUE, predictability = TRUE)

The figure shows four densely connected learning indicators and an isolated test anxiety node with an empty predictability ring. Node positions come from a layout algorithm and carry no statistical meaning.

Reporting the analysis

A report defines what 1 and 0 mean for each node and how any dichotomization was made, and states the sample size, the estimator, \(\gamma\), the AND or OR rule and the treatment of missing data. Interactions are reported on the log-odds scale, and predictability as nCC together with raw accuracy.

In this analysis, a regularized Ising network (\(\gamma = 0.25\), AND rule) of rank-dichotomized scores from 300 complete responses kept 6 positive edges among the learning constructs, the largest CSU–SE (2.192), and left test anxiety isolated. An unregularized estimator with Wald pruning at 0.05 kept the same edges.

Assumptions and when to use the Ising model

References

Haslbeck, J. M. B., & Waldorp, L. J. (2018). How well do network models predict observations? On the importance of predictability in network models. Behavior Research Methods, 50(2), 853-861. doi:10.3758/s13428-017-0910-x

Saqr, M. (2025). Delving into the psychology of machines: Exploring the structure of self-regulated learning via LLM-generated survey responses. Computers in Human Behavior, 173, 108769. doi:10.1016/j.chb.2025.108769

van Borkulo, C. D., Borsboom, D., Epskamp, S., Blanken, T. F., Boschloo, L., Schoevers, R. A., & Waldorp, L. J. (2014). A new method for constructing networks from binary data. Scientific Reports, 4, 5918. doi:10.1038/srep05918