find_pattern: find_pattern

Description Usage Arguments Examples

Description

Function to produce the pdag from the skeleton.

Usage

1

Arguments

skel

Examples

 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)
  }

gekepals/pcabs documentation built on June 15, 2019, 12:03 a.m.