Binary Network

Warning

This page has not yet passed technical or readability review.

An end-to-end analysis of binary data using the ordinal Markov random field. This example uses the ADHD dataset bundled with bgms.

Data

The ADHD dataset contains binary symptom ratings for 355 children. The first column is a group indicator (ADHD diagnosis); columns 2–19 are nine Inattentive and nine Hyperactive/Impulsive items scored as present (1) or absent (0). We drop the group column and analyze the first five Inattentive items.

library(bgms)
data = ADHD[, 2:6]
head(data)

Fit the model

Binary variables are a special case of ordinal data (two categories). bgm() fits an ordinal MRF with spike-and-slab edge selection by default.

fit = bgm(data, seed = 1234)

Posterior summaries

summary(fit)
coef(fit)

Edge selection

The posterior inclusion probabilities indicate the evidence for each edge:

coef(fit)$indicator

Convert to Bayes factors when the prior inclusion probability equals 0.5:

p = coef(fit)$indicator[1, 2]
BF_10 = p / (1 - p)       # evidence for inclusion
1 / BF_10                  # evidence for exclusion

Interpretation

Threshold the inclusion probabilities at 0.5 and plot with qgraph (Epskamp et al., 2012).

library(qgraph)

median_probability_network = coef(fit)$pairwise
median_probability_network[coef(fit)$indicator < 0.5] = 0.0

qgraph(median_probability_network,
  theme = "TeamFortress",
  maximum = 1,
  fade = FALSE,
  color = c("#f0ae0e"), vsize = 10, repulsion = .9,
  label.cex = 1, label.scale = "FALSE",
  labels = colnames(data)
)

Diagnostics

summary(fit)$pairwise
fit$nuts_diag$summary

See the MCMC Diagnostics guide for interpretation.

References

Epskamp, S., Cramer, A. O. J., Waldorp, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48(4), 1–18. https://doi.org/10.18637/jss.v048.i04