Captures an R expression for a dynamic (rule-based) exposure
intervention. The expression is evaluated at each time step inside the
simulated data.table, so any column in the current Monte Carlo
dataset can be referenced by name (including the exposure itself, which
holds its natural-course draw at the time of evaluation).
Examples
# Treat only if the natural-course value of A exceeds 0:
dyn_int(as.numeric(A > 0))
#> [[1]]
#> as.numeric(A > 0)
#>
#> attr(,"class")
#> [1] "causalMed_dynint"
# Treat if L1 > 0 or L2 equals 1:
dyn_int(as.numeric(L1 > 0 | L2 == 1))
#> [[1]]
#> as.numeric(L1 > 0 | L2 == 1)
#>
#> attr(,"class")
#> [1] "causalMed_dynint"