This is a wrapper function for the pc function as
implemented in the pcalg package. All computations are carried out by the
pcalg package.
pc(
data = NULL,
sparsity = 10^(-1),
test = regTest,
suffStat = NULL,
method = "stable.fast",
methodNA = "none",
methodOri = "conservative",
output = "cpdag",
varnames = NULL,
conservative = TRUE,
...
)A tpdag or tskeleton object. Both return types are
S3 objects, i.e., lists with entries: $amat (the estimated adjacency
matrix), $order (character vector with the order, as inputted to
this function), $psi (the significance level used for testing), and
$ntests (the number of tests conducted).
A data.frame with data. All variables should be assigned to exactly one period by prefixing them with the period name (see example below).
The sparsity level to be used for independence testing (i.e. significance level threshold to use for each test).
A procedure for testing conditional independence.
The default, regTest uses a regression-based information
loss test. Another available option is corTest which
tests for vanishing partial correlations. User supplied functions
may also be used, see details below about the required syntax.
Sufficient statistic. If this argument is supplied, the sufficient statistic is not computed from the inputted data. The format and contents of the sufficient statistic depends on which test is being used.
Which method to use for skeleton construction, must be
"stable", "original", or "stable.fast" (the default).
See skeleton for details.
Method for handling missing information (NA values).
Must be one of "none" (default, an error is thrown if NAs
are present), "cc" (complete case analysis, deletes all observations
that have any NA values), or "twd" (test wise deletion, omits
observations with missing information test-by-test) (further details below).
Method for handling conflicting separating sets when orienting
edges, must be one of "standard", "conservative" (the default) or
"maj.rule". See pc for further details.
One of "cpdag", "skeleton" or "pcAlgo". If
"skeleton", a skeleton is constructed and outputted,
but the edges are not directed. If "cpdag" (the default),
the edges are directed, resulting in a completed partially directed
acyclic graph (CPDAG). If "pcAlgo" the CPDAG is outputted as the
object class pcAlgo-class from the pcalg package. This is
intended for compatability with tools from that package.
A character vector of variable names. It only needs to be supplied
if the data argument is not used, and data are hence passed exclusively
through the suffStat argument.
Logital, if TRUE the conservative version of PC is used
(see pc for details).
Further optional arguments which are passed to
skeleton if output = "skeleton" or to
pc otherwise.
Note that all independence test procedures implemented
in the pcalg package may be used, see pc.
The methods for handling missing information require that the data,
rather than the suffStat argument is used for inputting data; the latter
assumes no missing information and hence always sets methodNA = "none".
If the test is corTest, test-wise deletion is performed when computing the
sufficient statistic (correlation matrix) (so for each pair of variables, only
complete cases are used). If the test is regTest, test-wise deletion
is performed for each conditional independence test instead.
# PC on included example data, use sparsity psi = 0.01, default test (regression-based
#information loss):
data(tpcExample)
pc(tpcExample, sparsity = 0.01)
# PC on included example data, use sparsity psi = 0.01, use test for vanishing partial
# correlations:
data(tpcExample)
pc(tpcExample, sparsity = 0.01, test = corTest)
Run the code above in your browser using DataLab