Skip to main content

Validate instrumental variables

Source: R/identification.R

Description

Tests whether a set of variables are valid instruments for identifying the causal effect of exposure x on outcome y, conditionally on given. Every node in z must be d-/m-separated from y given given in the graph obtained by removing the first edge of every causal path from x to y (exclusion restriction), and at least one node in z must be d-/m-connected to x given given (relevance). given must contain no descendant of x or y.

Usage

is_valid_iv(cg, x, y, z = character(), given = character())

Arguments

cg A DAG or ADMG created with cgraph().
x Exposure node name.
y Outcome node name, or character vector of node names.
z Character vector of instrument node names.
given Character vector of node names the instruments are conditionally valid given (may be empty).

Value

TRUE if z satisfies the instrumental variable criterion.

Examples

# Classic IV graph: Z --> X --> Y with hidden confounder U --> X, U --> Y
dag <- cgraph(Z %-->% X, X %-->% Y, U %-->% X, U %-->% Y)
is_valid_iv(dag, "X", "Y", "Z") # Z is a valid instrument
#> [1] TRUE
is_valid_iv(dag, "X", "Y", "U") # U confounds X and Y
#> [1] FALSE

# W confounds Z and Y, so Z is an instrument only given W
dag <- cgraph(W %-->% Z + Y, Z %-->% X %-->% Y, U %-->% X + Y)
is_valid_iv(dag, "X", "Y", "Z")
#> [1] FALSE
is_valid_iv(dag, "X", "Y", "Z", given = "W")
#> [1] TRUE