Learn R Programming

ParallelPC (version 1.2)

pc_parallel: Estimate the Equivalence Class of a DAG using the PC_parallel Algorithm

Description

Estimate the equivalence class of a directed acyclic graph (DAG) from observational data, using the PC_parallel algorithm.

Usage

pc_parallel(suffStat, indepTest, alpha, labels, p, fixedGaps = NULL, fixedEdges = NULL, NAdelete = TRUE, m.max = Inf, u2pd = c("relaxed", "rand", "retry"), skel.method = c("parallel"), mem.efficient = FALSE, conservative = FALSE, maj.rule = FALSE, solve.confl = FALSE, verbose = FALSE, num.cores = detectCores())

Arguments

suffStat
A list of sufficient statistics, containing all necessary elements for the conditional independence decisions in the function indepTest.
indepTest
A function for testing conditional independence. It is internally called as indepTest(x,y,S,suffStat), and tests conditional independence of x and y given S. Here, x and y are variables, and S is a (possibly empty) vector of variables (all variables are denoted by their column numbers in the adjacency matrix). suffStat is a list, see the argument above. The return value of indepTest is the p-value of the test for conditional independence.
alpha
significance level (number in (0,1) for the individual conditional independence tests.
labels
(optional) character vector of variable (or "node") names. Typically preferred to specifying p.
p
(optional) number of variables (or nodes). May be specified if labels are not, in which case labels is set to 1:p.
fixedGaps
A logical matrix of dimension p*p. If entry [i,j] or [j,i] (or both) are TRUE, the edge i-j is removed before starting the algorithm. Therefore, this edge is guaranteed to be absent in the resulting graph.
fixedEdges
A logical matrix of dimension p*p. If entry [i,j] or [j,i] (or both) are TRUE, the edge i-j is never considered for removal. Therefore, this edge is guaranteed to be present in the resulting graph.
NAdelete
If indepTest returns NA and this option is TRUE, the corresponding edge is deleted. If this option is FALSE, the edge is not deleted.
m.max
Maximal size of the conditioning sets that are considered in the conditional independence tests.
u2pd
String specifying the method for dealing with conflicting information when trying to orient edges (see pcalg for details).
skel.method
Character string specifying method; the default, "parallel", skeleton_parallel for learning the causal structure.
mem.efficient
If TRUE, uses less amount of memory at any time point while running the algorithm.
conservative
Logical indicating if the conservative PC is used. In this case, only option u2pd = "relaxed" is supported. Note that therefore the resulting object might not be extendable to a DAG. See pcalg for details.
maj.rule
Logical indicating that the triples shall be checked for ambiguity using a majority rule idea, which is less strict than the conservative PC algorithm. For more information, see pcalg.
solve.confl
If TRUE, the orientation of the v-structures and the orientation rules work with lists for candidate sets and allow bi-directed edges to resolve conflicting edge orientations.See pcalg for details.
verbose
If TRUE, detailed output is provided.
num.cores
The numbers of cores CPU to run the algorithm.

Value

An object of class "pcAlgo" (see pcAlgo in the pcalg package) containing an estimate of the equivalence class of the underlying DAG.

Examples

Run this code
##########################################
## Using pc_parallel without mem.efficeient
##########################################
library(pcalg)
library(parallel)
data("gmG")
p<-ncol(gmG$x)
suffStat<-list(C=cor(gmG$x),n=nrow(gmG$x))
pc_parallel(suffStat, indepTest=gaussCItest, p=p, skel.method="parallel", alpha=0.01, num.cores=2)

##########################################
## Using pc_parallel with mem.efficeient
##########################################
library(pcalg)
library(parallel)
data("gmG")
p<-ncol(gmG$x)
suffStat<-list(C=cor(gmG$x),n=nrow(gmG$x))
pc_parallel(suffStat, indepTest=gaussCItest, p=p, skel.method="parallel",
alpha=0.01, num.cores=2, mem.efficient=TRUE)

#################################################
## Using pc_parallel with mutual information test
#################################################
library(pcalg)
library(parallel)
data("gmG")
p<-ncol(gmG$x)
#The first parameter is the dataset rather than suffStat
pc_parallel(gmG$x, indepTest=mig, p=p, skel.method="parallel",
alpha=0.01, num.cores=2, mem.efficient=TRUE)

Run the code above in your browser using DataLab