Description Usage Arguments Examples
Function to produce the pdag from the skeleton.
1 | find_pattern(skel)
|
skel |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (skel)
{
verbose <- TRUE
res <- skel
g <- as(skel, "matrix")
p <- as.numeric(dim(g)[1])
pdag <- g
ind <- which(g == 1, arr.ind = TRUE)
for (i in seq_len(nrow(ind))) {
cat("\n", "i = ", i, ":")
x <- ind[i, 1]
cat("\n", x)
y <- ind[i, 2]
cat("\n", y, "\n")
allz <- setdiff(which(g[y, ] == 1), x)
cat("z:", allz, "\n")
for (z in allz) {
if (g[x, z] == 0 && !(y %in% skel@sepset[[x]][[z]] ||
y %in% skel@sepset[[z]][[x]])) {
if (verbose) {
cat("\n", x, "->", y, "<-", z, "\n")
cat("Sxz=", skel@sepset[[z]][[x]], "Szx=",
skel@sepset[[x]][[z]])
}
pdag[x, y] <- pdag[z, y] <- 1
pdag[y, x] <- pdag[y, z] <- 0
}
}
}
return(pdag)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.