Define intervention in a `lvm` object

# S3 method for lvm
intervention(object, to, value, dist = none.lvm(), ...)

Arguments

object

lvm object

to

String defining variable or formula

value

function defining intervention

dist

Distribution

...

Additional arguments to lower level functions

See also

regression lvm sim

Examples

m <- lvm(y ~ a + x, a ~ x) distribution(m, ~a+y) <- binomial.lvm() mm <- intervention(m, "a", value=3) sim(mm, 10)
#> y a x #> 1 1 3 0.07489798 #> 2 1 3 0.45019776 #> 3 1 3 -0.16056416 #> 4 1 3 0.84669312 #> 5 1 3 -0.02494173 #> 6 1 3 0.40911405 #> 7 1 3 -0.14542408 #> 8 1 3 0.56811111 #> 9 1 3 -0.13628920 #> 10 1 3 0.05464296
mm <- intervention(m, a~x, function(x) (x>0)*1) sim(mm, 10)
#> y a x #> 1 0 0 -1.8275194 #> 2 1 1 0.8734125 #> 3 0 0 -1.3504169 #> 4 0 0 -0.1909089 #> 5 1 0 -0.5163645 #> 6 0 0 -1.6401133 #> 7 0 0 -0.4229099 #> 8 0 1 0.6295674 #> 9 1 1 0.1508383 #> 10 0 0 -0.5078554