
x
) on a several (i.e., a vector of) target
variables (y
) from observational data. idaFast()
is more efficient than looping over
ida
. Only method="local"
(see ida
)
is available.
idaFast(x.pos, y.pos.set, mcov, graphEst)
x
in the covariance matrixy
in the covariance matrixgraphEst
length(y.pos.set)
rows. Row $i$ contains the multiset
of estimated possible total causal effects of x
on
y.pos.set[i]
. Note that all multisets in the matrix have the
same length, since the parents of x
are the same for all elements
of y.pos.set
.ida(x.pos, y.pos, mcov, graphEst, method="local",
y.notparent=FALSE, verbose=FALSE)
for all values of y.pos
in
y.pos.set
simultaneously, in an efficient way.
See the help file of ida
for more details. Note that the
option y.notparent = TRUE
is not implemented, since it is not
clear how to do that efficiently without orienting all edges away from
y.pos.set
at the same time, which seems not to be
desirable. Suggestions are welcome. Markus Kalisch, Martin Maechler, Diego Colombo, Marloes H. Maathuis,
Peter Buehlmann (2012). Causal Inference Using Graphical Models with
the R Package pcalg. Journal of Statistical Software
47(11) 1--26,
pc
for estimating a CPDAG, and
ida
for estimating the multiset of possible total causal
effects from observational data on only one target variable but with many more
options (than here in idaFast
).## Simulate the true DAG
set.seed(123)
p <- 7
myDAG <- randomDAG(p, prob = 0.2) ## true DAG
myCPDAG <- dag2cpdag(myDAG) ## true CPDAG
covTrue <- trueCov(myDAG) ## true covariance matrix
## simulate data from the true DAG
n <- 10000
dat <- rmvDAG(n, myDAG)
## estimate CPDAG (see help on the function "pc")
alpha <- 0.01
indepTest <- gaussCItest
suffStat <- list(C = cor(dat), n = n)
pc.fit <- pc(suffStat, indepTest, p, alpha)
if(require(Rgraphviz))
plot(myDAG)
(eff.est1 <- ida(2,5,cov(dat),pc.fit@graph,method="local",verbose=FALSE))
(eff.est2 <- ida(2,6,cov(dat),pc.fit@graph,method="local",verbose=FALSE))
(eff.est3 <- ida(2,7,cov(dat),pc.fit@graph,method="local",verbose=FALSE))
## These three computations can be combinded in an efficient way
## by using idaFast :
(eff.estF <- idaFast(2,c(5,6,7),cov(dat),pc.fit@graph))
Run the code above in your browser using DataLab