R Under development (unstable) (2024-02-05 r85863 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(pcalg) > > ## possDe > ## a -> b -- c > amat <- matrix(c(0,1,0, 0,0,1, 0,1,0), 3,3) > colnames(amat) <- rownames(amat) <- letters[1:3] > ## plot(as(t(amat), "graphNEL")) > > stopifnot( + all(possDe(m = amat, x = 1, possible = TRUE, ds = FALSE, type = "pdag") == c(1,2,3)), + all(possDe(m = amat, x = 1, possible = FALSE, ds = FALSE, type = "pdag") == c(1,2)), + all(possDe(m = amat, x = 1, y = 2, possible = TRUE, ds = FALSE, type = "pdag") == 1) ) > > ## possAn > ## a -- b -> c > amat <- matrix(c(0,1,0, 1,0,1, 0,0,0), 3,3) > colnames(amat) <- rownames(amat) <- letters[1:3] > plot(as(t(amat), "graphNEL")) Attaching package: 'BiocGenerics' The following objects are masked from 'package:stats': IQR, mad, sd, var, xtabs The following objects are masked from 'package:base': Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted, lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames, sapply, setdiff, table, tapply, union, unique, unsplit, which.max, which.min > > stopifnot( + all(possAn(m = amat, x = 3, possible = TRUE, ds = FALSE, type = "pdag") == c(1,2,3)), + all(possAn(m = amat, x = 3, y = 2, possible = TRUE, ds = FALSE, type = "pdag") == 3) ) > > proc.time() user system elapsed 1.10 0.21 1.28