library(igraph)
# We set simplify = FALSE to allow multiple edges.
g <- graph.formula(W -+ X, W -+ Z, X -+ Z, Z -+ Y, # Observed edges
X -+ Z, Z -+ X, simplify = FALSE)
# We set the bidirected edges
g <- set.edge.attribute(g, "description", 5:6, "U")
# We construct the set of available experimental data
s <- list(
list(Z = c("X"), W = c("Z"))
)
surrogate.outcome(y = "Y", x = "X", S = s, G = g)
Run the code above in your browser using DataLab