check_directed_edges: check_directed_edges

Description Usage Arguments Examples

Description

Function to check for directed edges between two groups of variables.

Usage

1
check_directed_edges(pdag, abs_group1, abs_group2)

Arguments

pdag
abs_group1
abs_group2

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_group1, abs_group2)
{
    ind <- which((pdag == 1 & t(pdag) == 0), arr.ind = TRUE)
    dir_edge <- FALSE
    ind_no <- list()
    t <- 1
    for (i in seq_len(nrow(ind))) {
        if (ind[i, 1] %in% abs_group1) {
            if (ind[i, 2] %in% abs_group2) {
                cat("directed edge to the right found on t = ",
                  i, "\n")
                dir_edge = TRUE
                ind_no[[t]] <- ind[i, 1]
                t <- t + 1
                ind_no[[t]] <- ind[i, 2]
                t <- t + 1
            }
        }
        else if (ind[i, 2] %in% abs_group1) {
            if (ind[i, 1] %in% abs_group2) {
                cat("directed edge to the left found on t = ",
                  i, "\n")
                dir_edge = TRUE
                ind_no[[t]] <- ind[i, 1]
                t <- t + 1
                ind_no[[t]] <- ind[i, 2]
                t <- t + 1
            }
        }
    }
    if (dir_edge) {
        return(ind_no)
    }
    else {
        return(NULL)
    }
  }

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