Description Usage Arguments Examples
Function to check for directed edges between two groups of variables.
1 | check_directed_edges(pdag, abs_group1, abs_group2)
|
pdag |
|
abs_group1 |
|
abs_group2 |
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)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.