r.gauss.pardag | R Documentation |
Generate a random Gaussian causal model. Parameters specifying the connectivity as well as coefficients and error terms of the corresponding linear structural equation model can be specified. The observational expectation value of the generated model is always 0, meaning that no interception terms are drawn.
r.gauss.pardag(p, prob, top.sort = FALSE, normalize = FALSE,
lbe = 0.1, ube = 1, neg.coef = TRUE, labels = as.character(1:p),
lbv = 0.5, ubv = 1)
p |
the number of nodes. |
prob |
probability of connecting a node to another node. |
top.sort |
|
normalize |
|
lbe , ube |
lower and upper bounds of the absolute values of edge weights. |
neg.coef |
logical indicating whether negative edge weights are also admissible. |
labels |
(optional) character vector of variable (or “node”) names. |
lbv , ubv |
lower and upper bound on error variances of the noise terms in the structural equations. |
The underlying directed acyclic
graph (DAG) is generated by drawing an undirected graph from an Erdős-Rényi
model orienting the edges according to a random topological ordering drawn
uniformly from the set of permutations of p
variables. This means that
any two nodes are connected with (the same) probability prob
, and that
the connectivity of different pairs of nodes is independent.
A Gaussian causal model can be represented as a set of linear structural
equations. The regression coefficients of the model can be represented as
"edge weights" of the DAG. Edge weights are drawn uniformly and
independently from the interval between lbe
and ube
; if
neg.coef = TRUE
, their sign is flipped with probability 0.5. Error
variances are drawn uniformly and independently from the interval between
lbv
and ubv
.
If normalize = TRUE
, the edge weights and error variances are
normalized in the end to ensure that the diagonal elements of the
observational covariance matrix are all 1; the procedure used is described in
Hauser and Bühlmann (2012). Note that in this case the error variances and
edge weights are no longer guaranteed to lie in the specified intervals
after normalization.
An object of class "GaussParDAG"
.
Alain Hauser (alain.hauser@bfh.ch)
P. Erdős and A. Rényi (1960). On the evolution of random graphs. Publications of the Mathematical Institute of the Hungarian Academy of Sciences 5, 17–61.
A. Hauser and P. Bühlmann (2012). Characterization and greedy learning of interventional Markov equivalence classes of directed acyclic graphs. Journal of Machine Learning Research 13, 2409–2464.
GaussParDAG
, randomDAG
set.seed(307)
## Plot some random DAGs
if (require(Rgraphviz)) {
## Topologically sorted random DAG
myDAG <- r.gauss.pardag(p = 10, prob = 0.2, top.sort = TRUE)
plot(myDAG)
## Unsorted DAG
myDAG <- r.gauss.pardag(p = 10, prob = 0.2, top.sort = FALSE)
plot(myDAG)
}
## Without normalization, edge weigths and error variances lie within the
## specified borders
set.seed(307)
myDAG <- r.gauss.pardag(p = 10, prob = 0.4,
lbe = 0.1, ube = 1, lbv = 0.5, ubv = 1.5, neg.coef = FALSE)
B <- myDAG$weight.mat()
V <- myDAG$err.var()
any((B > 0 & B < 0.1) | B > 1)
any(V < 0.5 | V > 1.5)
## After normalization, edge weights and error variances are not necessarily
## within the specified range, but the diagonal of the observational covariance
## matrix consists of ones only
set.seed(308)
myDAG <- r.gauss.pardag(p = 10, prob = 0.4, normalize = TRUE,
lbe = 0.1, ube = 1, lbv = 0.5, ubv = 1.5, neg.coef = FALSE)
B <- myDAG$weight.mat()
V <- myDAG$err.var()
any((B > 0 & B < 0.1) | B > 1)
any(V < 0.5 | V > 1.5)
diag(myDAG$cov.mat())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.