lead_abs: lead_abs

Description Usage Arguments Examples

Description

Takes as input the pdag and all the clusters (all Zs). Loops over the groups to decide which are pairs (i.e. which have connected edges). Decides the order of directing edges between pairs. First, the pairs are directed that have 1 or more directed edges. Last, all pairs that have no directed edges are directed. All pairs are sent to the add_abstraction function to direct the edges.

Usage

1
lead_abs(pdag, abs_groups)

Arguments

pdag
abs_groups

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
37
38
39
40
41
42
##---- 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 (pdag, abs_groups)
{
    undirected_list <- list()
    for (i in 1:length(abs_groups)) {
        cat("i: ", i)
        for (z in i:length(abs_groups)) {
            if ((z + 1) <= length(abs_groups)) {
                absList <- find_edge_between_groups(pdag, abs_groups[[i]],
                  abs_groups[[z + 1]])
                if (length(absList$abs_group1) > 0) {
                  group1 <- noquote(gsub("[^0-9]", "", absList$abs_group1))
                  group2 <- noquote(gsub("[^0-9]", "", absList$abs_group2))
                  dir_list <- check_directed_edges(pdag, group1,
                    group2)
                  if (!is.null(dir_list)) {
                    print("directed edges found between groups")
                    pdag <- add_abstraction(pdag, absList$abs_group1,
                      absList$abs_group2)
                  }
                  else {
                    print("no directed edges found between groups")
                    undirected_list <- append(undirected_list,
                      absList)
                  }
                }
            }
        }
    }
    if (length(undirected_list) > 0) {
        print("start with undirected list")
        for (i in seq(1, length(undirected_list), by = 2)) {
            pdag <- add_abstraction(pdag, undirected_list[i]$abs_group1,
                undirected_list[i + 1]$abs_group2)
        }
    }
    return(pdag)
  }

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