NetworkMotif: Posterior probability of a network motif

View source: R/NetworkMotif.R

NetworkMotifR Documentation

Posterior probability of a network motif

Description

NetworkMotif quantifies the uncertainty of a given network structure among the response variables: it returns the proportion of posterior draws in which every edge of the motif is present, that is, the posterior probability that all edges of the motif are present simultaneously. The input draws are the GammaPst output of RGM.

Usage

NetworkMotif(Gamma, GammaPst)

Arguments

Gamma

A p * p binary matrix (numeric 0/1 or logical) with a zero diagonal, specifying the motif: Gamma[i, j] = 1 for the directed edge from response j to response i (the same orientation as A and GammaEst in RGM). Entries equal to 0 are ignored, so the motif can be any subgraph (a single edge, a cascade, a feed-forward loop, a feedback loop, ...); only the presence of the specified edges is required, not the absence of others.

GammaPst

A p * p * n_pst array of posterior draws of the causal edge indicators, the GammaPst component returned by RGM.

Value

A number between 0 and 1: the proportion of posterior draws that contain all edges of Gamma.

References

Ni, Y., Ji, Y., & Müller, P. (2018). Reciprocal graphical models for integrative gene regulatory network analysis. Bayesian Analysis, 13(4), 1095-1110. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/17-BA1087")}.

Examples

# Simulate a cascade Y1 -> Y2 -> Y3 with two own instruments per response
set.seed(9154)
n = 2000; p = 3; k = 6
A = matrix(0, p, p); A[2, 1] = 0.3; A[3, 2] = -0.3     # A[i, j]: effect of Y_j on Y_i
D = matrix(0, p, k)
for (i in 1:p) D[i, (2 * i - 1):(2 * i)] = 1
X = matrix(rnorm(n * k), n, k)
Y = (X %*% t(D) + matrix(rnorm(n * p), n, p)) %*% t(solve(diag(p) - A))
X = scale(X); Y = scale(Y)                              # the model has no intercept

# Fit MR.RGM (a short chain to keep the example fast; the defaults are the recommended length)
fit = RGM(X = X, Y = Y, D = D, nIter = 2000, nBurnin = 1000, Thin = 2)

# Posterior probability of the cascade Y1 -> Y2 -> Y3 (both edges present)
Gamma = matrix(0, p, p); Gamma[2, 1] = 1; Gamma[3, 2] = 1
NetworkMotif(Gamma = Gamma, GammaPst = fit$GammaPst)

# Posterior probability of the feedback loop Y1 -> Y2 -> Y3 -> Y1
Gamma[1, 3] = 1
NetworkMotif(Gamma = Gamma, GammaPst = fit$GammaPst)


MR.RGM documentation built on Nov. 24, 2026, 9:06 a.m.