Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rmvnorm.ivent

Simulate from a Gaussian Causal Model


Description

Produces one or more samples from the observational or an interventional distribution associated to a Gaussian causal model.

Usage

rmvnorm.ivent(n, object, target = integer(0), target.value = numeric(0))

Arguments

n

Number of samples required.

object

An instance of GaussParDAG

target

Intervention target: vector of intervened nodes. If the vector is empty, samples from the observational distribution are generated. Otherwise, samples from an interventional distribution are simulated.

target.value

Values of the intervened variables. If target.value is a vector of the same length as target, the indicated intervention levels are used for all n samples. If target.value is a matrix of dimension n by length(target), the i-th sample is simulated using the i-th row of the matrix as intervention levels.

Value

If n = 1 a vector of length p is returned, where p denotes the number of nodes of object. Otherwise an n by p matrix is returned with one sample per row.

Author(s)

Alain Hauser (alain.hauser@bfh.ch)

Examples

set.seed(307)
myDAG <- r.gauss.pardag(5, 0.5)
var(rmvnorm.ivent(n = 1000, myDAG))
myDAG$cov.mat()
var(rmvnorm.ivent(n = 1000, myDAG, target = 1, target.value = 1))
myDAG$cov.mat(target = 1, ivent.var = 0)

pcalg

Methods for Graphical Models and Causal Inference

v2.7-2
GPL (>= 2)
Authors
Markus Kalisch [aut, cre], Alain Hauser [aut], Martin Maechler [aut], Diego Colombo [ctb], Doris Entner [ctb], Patrik Hoyer [ctb], Antti Hyttinen [ctb], Jonas Peters [ctb], Nicoletta Andri [ctb], Emilija Perkovic [ctb], Preetam Nandy [ctb], Philipp Ruetimann [ctb], Daniel Stekhoven [ctb], Manuel Schuerch [ctb], Marco Eigenmann [ctb], Leonard Henckel [ctb], Joris Mooij [ctb]
Initial release
2021-4-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.