tskeleton {tpc} | R Documentation |
Estimate the Skeleton of a DAG while Accounting for a Partial Ordering
Description
Like pcalg::skeleton
, but takes a user-specified partial node
ordering into account. The conditional independence
between x
and y
given S
is not tested if any variable in
S
lies in the future of both x
and y
.
Usage
tskeleton(
suffStat,
indepTest,
alpha,
labels,
p,
method = c("stable", "original"),
m.max = Inf,
fixedGaps = NULL,
fixedEdges = NULL,
NAdelete = TRUE,
tiers = NULL,
verbose = FALSE
)
Arguments
suffStat |
A list of sufficient statistics, containing all necessary elements for
the conditional independence decisions in the function |
indepTest |
Predefined |
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 |
(optional) number of variables (or nodes). May be specified if |
method |
Character string specifying method; the default, "stable" provides an order-independent skeleton, see 'Details' below. |
m.max |
Maximal size of the conditioning sets that are considered in the conditional independence tests. |
fixedGaps |
logical symmetric matrix of dimension |
fixedEdges |
a logical symmetric matrix of dimension |
NAdelete |
logical needed for the case |
tiers |
Numeric vector specifying the tier / time point for each variable.
Must be of length 'p', if specified, or have the same length as 'labels', if specified.
A smaller number corresponds to an earlier tier / time point. Conditional independence
testing is restricted such that if |
verbose |
if |
Details
See pcalg::skeleton
for further information on the
skeleton algorithm.
Value
An object of class "pcAlgo" (see pcalg::pcAlgo
)
containing an estimate of the skeleton of the underlying DAG, the conditioning
sets (sepset) that led to edge removals and several other parameters.
Author(s)
Original code by Markus Kalisch, Martin Maechler, Alain Hauser and Diego Colombo. Modifications by Janine Witte.
Examples
# load simulated cohort data
data("dat_sim")
n <- nrow(dat_sim)
lab <- colnames(dat_sim)
# estimate skeleton without taking background information into account
tskel.fit <- tskeleton(suffStat = list(C = cor(dat_sim), n = n),
indepTest = gaussCItest, alpha = 0.01, labels = lab)
skel.fit <- pcalg::skeleton(suffStat = list(C = cor(dat_sim), n = n),
indepTest = gaussCItest, alpha = 0.01, labels = lab)
identical(skel.fit@graph, tskel.fit@graph) # TRUE
# estimate skeleton with temporal ordering as background information
tiers <- rep(c(1,2,3), times=c(3,3,3))
tskel.fit2 <- tskeleton(suffStat = list(C = cor(dat_sim), n = n),
indepTest = gaussCItest, alpha = 0.01, labels = lab, tiers = tiers)
# in this case, the skeletons estimated with and without
# background knowledge are identical, but fewer conditional
# independence tests were performed when background
# knowledge was taken into account
identical(tskel.fit@graph, tskel.fit2@graph) # TRUE
tskel.fit@n.edgetests
tskel.fit2@n.edgetests