Skip to contents

Define intervention in a `lvm` object

Usage

# S3 method for class '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.1758473
#> 2  1 3 -0.7003017
#> 3  1 3  0.8740681
#> 4  1 3 -0.7909800
#> 5  1 3  0.5525168
#> 6  0 3  0.3305292
#> 7  1 3 -0.8173789
#> 8  1 3 -1.0896205
#> 9  1 3 -0.4401358
#> 10 1 3 -0.1832252
mm <- intervention(m, a~x, function(x) (x>0)*1)
sim(mm, 10)
#>    y a           x
#> 1  1 1  0.18123140
#> 2  0 0 -0.64806949
#> 3  1 1  0.30274123
#> 4  1 0 -0.92839816
#> 5  1 0 -0.44087137
#> 6  0 0 -0.37248179
#> 7  0 0 -0.81769810
#> 8  1 0 -0.57704241
#> 9  1 1  1.01409187
#> 10 1 1  0.06610547