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

trueCov

Covariance matrix of a DAG.


Description

Compute the (true) covariance matrix of a generated DAG.

Usage

trueCov(dag, back.compatible = FALSE)

Arguments

dag

Graph object containing the DAG.

back.compatible

logical indicating if the data generated should be the same as with pcalg version 1.0-6 and earlier (where wgtMatrix() differed).

Value

Covariance matrix.

Note

This function can not be used to estimate the covariance matrix from an estimated DAG or corresponding data.

Author(s)

Markus Kalisch

See Also

randomDAG for generating a random DAG

Examples

set.seed(123)
g <- randomDAG(n = 5, prob = 0.3) ## generate random DAG
if(require(Rgraphviz)) {
plot(g)
}

## Compute true covariance matrix
trueCov(g)

## For comparison:
## Estimate true covariance matrix after generating data from g
d <- rmvDAG(10000, g)
cov(d)

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.