# Create a three-tier causal graph (exposures -> mediators -> outcome)
cg <- caugi(
X1 %-->% M1 + M2,
X2 %-->% M1 + M2,
M1 %-->% Y,
M2 %-->% Y
)
# Option 1: Named list (tier names are just labels)
tiers <- list(
exposures = c("X1", "X2"),
mediators = c("M1", "M2"),
outcome = "Y"
)
layout_rows <- caugi_layout_tiered(cg, tiers, orientation = "rows")
# Option 2: Named numeric vector (0-indexed or 1-indexed both work)
tiers <- c(X1 = 1, X2 = 1, M1 = 2, M2 = 2, Y = 3)
layout_cols <- caugi_layout_tiered(cg, tiers, orientation = "columns")
# Option 3: Data.frame
tiers <- data.frame(
name = c("X1", "X2", "M1", "M2", "Y"),
tier = c(1, 1, 2, 2, 3)
)
layout <- caugi_layout_tiered(cg, tiers, orientation = "rows")
# The layout includes tier information, so plot() works without passing tiers
plot(cg, layout = layout)
Run the code above in your browser using DataLab