Learn R Programming

pcalg (version 1.0-0)

idaFast: Estimate multiset of possible total causal effects for several target nodes at the same time.

Description

This function estimates the multiset of possible total causal effects of one variable (x) on a vector of target variables (y) from observational data. This method is more efficient than looping over ida. Only method="local" (see help file of ida) is available.

Usage

idaFast(x.pos,y.pos.set,mcov,graphEst)

Arguments

x.pos
Column index of x in the covariance matrix
y.pos.set
Vector of column indices of the target variables y in the covariance matrix
mcov
Covariance matrix that was used to estimate graphEst
graphEst
Estimated CPDAG from the function pc. If the output of pc is pc.fit, then the estimated CPDAG can be obtained by pc.fit@graph.

Value

  • Matrix with 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 elements of y.pos.set.

Details

This function performs ida(x.pos, y.pos, mcov, graphEst, method="local", y.notparent=FALSE, verbose=FALSE) for all values of y.pos in y.pos.set at the same time, in an efficient way. See the help file of ida for more details.

References

M.H. Maathuis, M. Kalisch, P. B"uhlmann (2009), Estimating high-dimensional intervention effects from observational data; Annals of Statistics, 2009.

See Also

pc,idaFast

Examples

Run this code
## 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)

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