==3446389== Memcheck, a memory error detector ==3446389== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==3446389== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info ==3446389== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla ==3446389== R Under development (unstable) (2022-11-12 r83339) -- "Unsuffered Consequences" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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. Natural language support but running in an English locale 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. > pkgname <- "catnet" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('catnet') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("catNetwork-class") > ### * catNetwork-class > > flush(stderr()); flush(stdout()) > > ### Name: catNetwork-class > ### Title: Class "catNetwork" > ### Aliases: catNetwork catNetwork-class > ### Keywords: classes graphs > > ### ** Examples > > set.seed(123) > cnet <- cnRandomCatnet(numnodes=10, maxParents=2, numCategories=2) > cnet A catNetwork object with 10 nodes, 2 parents, 2 categories, Likelihood = 0 , Complexity = 19 . > > > > cleanEx() > nameEx("cnCluster") > ### * cnCluster > > flush(stderr()); flush(stdout()) > > ### Name: cnCluster-method > ### Title: Network Clustering > ### Aliases: cnCluster cnClusterSep cnClusterMI cnCluster,catNetwork-method > ### cnClusterSep,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=30, maxParents=2, numCategories=2) > cnCluster(object=cnet) [[1]] N4 N7 N11 N16 N18 N1 N2 N5 4 7 11 16 18 1 2 5 [[2]] N10 N3 10 3 [[3]] N14 N27 14 27 [[4]] N19 N22 N21 N26 N12 N23 N29 N17 19 22 21 26 12 23 29 17 > > > > cleanEx() > nameEx("cnCompare") > ### * cnCompare > > flush(stderr()); flush(stdout()) > > ### Name: cnCompare-method > ### Title: Network Comparison > ### Aliases: cnCompare cnCompare,catNetwork,catNetwork-method > ### cnCompare,catNetwork,matrix-method cnCompare,catNetwork,list-method > ### cnCompare,catNetwork,catNetworkEvaluate-method > ### Keywords: methods graphs > > ### ** Examples > > cnet1 <- cnRandomCatnet(numnodes=10, maxParents=2, numCategories=2) > cnet2 <- cnRandomCatnet(numnodes=10, maxParents=2, numCategories=2) > dist <- cnCompare(object1=cnet1, object2=cnet2) > dist Edges: TP = 0, FP = 5, FN = 5, F-score = 0.000000, Hamming: (FP+FN) = 10, exp = 13, Skeleton: TP = 0, FP = 5, FN = 5, Order: FP = 0, FN = 0, Markov blanket: FP = 2, FN = 0 > > > > cleanEx() > nameEx("cnComplexity") > ### * cnComplexity > > flush(stderr()); flush(stdout()) > > ### Name: cnComplexity-method > ### Title: Network Complexity > ### Aliases: cnComplexity cnComplexity,catNetwork-method > ### cnComplexity,catNetwork,integer-method cnKLComplexity > ### cnKLComplexity,catNetwork-method > ### cnKLComplexity,catNetwork-method,integer-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnComplexity(object=cnet) [1] 22 > > > > cleanEx() > nameEx("cnDiscretize") > ### * cnDiscretize > > flush(stderr()); flush(stdout()) > > ### Name: cnDiscretize > ### Title: Data Categorization > ### Aliases: cnDiscretize > > ### ** Examples > > ps <- t(sapply(1:10, function(i) rnorm(20, i, 0.1))) > dps1 <- cnDiscretize(ps, 3, mode="quantile") > hist(dps1[1,]) > qlevels <- lapply(1:10, function(i) rep(1, 3)) > qlevels[[1]] <- c(1,2,1) > dps2 <- cnDiscretize(ps, 3, mode="uniform", qlevels) > hist(dps2[1,]) > > > > cleanEx() > nameEx("cnDot") > ### * cnDot > > flush(stderr()); flush(stdout()) > > ### Name: cnDot-method > ### Title: Network Description File > ### Aliases: cnDot cnDot,catNetwork-method > ### cnDot,catNetwork,character-method > ### cnDot,catNetwork,character-method,character-method > ### cnDot,matrix-method cnDot,matrix,character-method > ### cnDot,matrix,character-method,character-method cnDot,list-method > ### cnDot,list,character-method > ### cnDot,list,character-method,character-method > ### Keywords: methods graphs aplot > > ### ** Examples > > #cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > #cnDot(object=cnet, file="cnet") > > > > cleanEx() > nameEx("cnEdges") > ### * cnEdges > > flush(stderr()); flush(stdout()) > > ### Name: cnEdges-method > ### Title: Network Edges > ### Aliases: cnEdges cnEdges,catNetwork,missing-method > ### cnEdges,catNetwork,vector-method cnEdges,catNetwork,character-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnEdges(object=cnet) $N1 [1] "N2" $N2 [1] "N10" $N4 [1] "N2" "N5" $N7 [1] "N5" $N9 [1] "N1" "N5" > > > > cleanEx() > nameEx("cnFind") > ### * cnFind > > flush(stderr()); flush(stdout()) > > ### Name: cnFind-method > ### Title: Find Network by Complexity > ### Aliases: cnFind cnFindKL cnFind,list-method > ### cnFind,catNetworkEvaluate-method cnFindKL,list-method > ### cnFindKL,catNetworkEvaluate-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=10, maxParents=2, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) > netlist <- cnSearchOrder(data=psamples, maxParentSet=2) > bnet <- cnFind(object=netlist, complexity=cnComplexity(cnet)) > bnet A catNetwork object with 10 nodes, 1 parents, 2 categories, Likelihood = -5.617766 , Complexity = 15 . > > > > cleanEx() > nameEx("cnFindAIC") > ### * cnFindAIC > > flush(stderr()); flush(stdout()) > > ### Name: cnFindAIC-method > ### Title: Find Network by AIC > ### Aliases: cnFindAIC cnFindAIC,catNetworkEvaluate-method > ### cnFindAIC,list-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=12, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=10) > nodeOrder <- sample(1:12) > nets <- cnSearchOrder(data=psamples, perturbations=NULL, + maxParentSet=2, maxComplexity=36, nodeOrder) > aicnet <- cnFindAIC(object=nets) > aicnet A catNetwork object with 12 nodes, 2 parents, 2 categories, Likelihood = -4.901405 , Complexity = 28 . > > > > cleanEx() > nameEx("cnFindBIC") > ### * cnFindBIC > > flush(stderr()); flush(stdout()) > > ### Name: cnFindBIC-method > ### Title: Find Network by BIC > ### Aliases: cnFindBIC cnFindBIC,list-method > ### cnFindBIC,catNetworkEvaluate-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=12, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=10) > nodeOrder <- sample(1:12) > nets <- cnSearchOrder(data=psamples, perturbations=NULL, + maxParentSet=2, maxComplexity=36, nodeOrder) > bicnet <- cnFindBIC(object=nets, numsamples=dim(psamples)[2]) > bicnet A catNetwork object with 12 nodes, 2 parents, 2 categories, Likelihood = -4.360781 , Complexity = 31 . > > > > cleanEx() > nameEx("cnLoglik") > ### * cnLoglik > > flush(stderr()); flush(stdout()) > > ### Name: cnLoglik-method > ### Title: Sample Log-likelihood > ### Aliases: cnLoglik cnLoglik,catNetwork-method > ### Keywords: methods graphs distribution > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents = 3, numCategories = 2) > psamples <- cnSamples(object=cnet, numsamples=100) > cnLoglik(object=cnet, data=psamples) [1] -5.95861 > > > > cleanEx() > nameEx("cnMatEdges") > ### * cnMatEdges > > flush(stderr()); flush(stdout()) > > ### Name: cnMatEdges-method > ### Title: Network Edge Matrix > ### Aliases: cnMatEdges cnMatEdges,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnMatEdges(object=cnet) [,1] [,2] [1,] "N9" "N1" [2,] "N4" "N2" [3,] "N1" "N2" [4,] "N4" "N5" [5,] "N7" "N5" [6,] "N9" "N5" [7,] "N2" "N10" > > > > cleanEx() > nameEx("cnMatParents") > ### * cnMatParents > > flush(stderr()); flush(stdout()) > > ### Name: cnMatParents-method > ### Title: Network Parent Matrix > ### Aliases: cnMatParents cnMatParents,catNetwork,missing-method > ### cnMatParents,catNetwork,vector-method > ### Keywords: methods > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnMatParents(object=cnet) N1 N2 N3 N4 N5 N6 N7 N8 N9 N10 N1 0 0 0 0 0 0 0 0 1 0 N2 1 0 0 1 0 0 0 0 0 0 N3 0 0 0 0 0 0 0 0 0 0 N4 0 0 0 0 0 0 0 0 0 0 N5 0 0 0 1 0 0 1 0 1 0 N6 0 0 0 0 0 0 0 0 0 0 N7 0 0 0 0 0 0 0 0 0 0 N8 0 0 0 0 0 0 0 0 0 0 N9 0 0 0 0 0 0 0 0 0 0 N10 0 1 0 0 0 0 0 0 0 0 > > > > cleanEx() > nameEx("cnNew") > ### * cnNew > > flush(stderr()); flush(stdout()) > > ### Name: cnNew > ### Title: New catNetwork > ### Aliases: cnNew > ### Keywords: classes graphs > > ### ** Examples > > library(catnet) > cnet <- cnNew( + nodes = c("a", "b", "c"), + cats = list(c("1","2"), c("1","2"), c("1","2")), + parents = list(NULL, c(1), c(1,2)), + probs = list( c(0.2,0.8), + list(c(0.6,0.4),c(0.4,0.6)), + list(list(c(0.3,0.7),c(0.7,0.3)), + list(c(0.9,0.1),c(0.1,0.9)))) + ) > > > > cleanEx() > nameEx("cnNodeLoglik") > ### * cnNodeLoglik > > flush(stderr()); flush(stdout()) > > ### Name: cnNodeLoglik > ### Title: Node Log-likelihood > ### Aliases: cnNodeLoglik cnNodeLoglik,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) > cnNodeLoglik(cnet, node=5, data=psamples) [1] -0.6736088 > > > > cleanEx() > nameEx("cnNodeMarginalProb") > ### * cnNodeMarginalProb > > flush(stderr()); flush(stdout()) > > ### Name: cnNodeMarginalProb-method > ### Title: Probability Calculations > ### Aliases: cnNodeMarginalProb cnNodeMarginalProb,catNetwork-method > ### cnJointProb cnJointProb,catNetwork-method cnCondProb > ### cnCondProb,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnNodeMarginalProb(cnet, node=5) [1] 0.4401602 0.5598398 > cnCondProb(cnet, x=c("N1"=1, "N2"=2), y=c("N3"=1, "N4"=2, "N5"=2)) [1] 0.07914342 > > > > cleanEx() > nameEx("cnNodeSampleLoglik") > ### * cnNodeSampleLoglik > > flush(stderr()); flush(stdout()) > > ### Name: cnNodeSampleLoglik > ### Title: Node Log-likelihood > ### Aliases: cnNodeSampleLoglik cnNodeSampleProb > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) ==3446389== Invalid read of size 4 ==3446389== at 0x167738AB: RCatnet::genSamples(SEXPREC*, SEXPREC*, SEXPREC*) (packages/tests-vg/catnet/src/rcatnet.cpp:581) ==3446389== by 0x1676F6B4: catnetSamples (packages/tests-vg/catnet/src/catnet_rexport.cpp:714) ==3446389== by 0x4A08B1: R_doDotCall (svn/R-devel/src/main/dotcode.c:877) ==3446389== by 0x4A0E0B: do_dotcall (svn/R-devel/src/main/dotcode.c:1551) ==3446389== by 0x4D7AEB: bcEval (svn/R-devel/src/main/eval.c:7128) ==3446389== by 0x4F1DAF: Rf_eval (svn/R-devel/src/main/eval.c:750) ==3446389== by 0x4F370D: R_execClosure (svn/R-devel/src/main/eval.c:1920) ==3446389== by 0x4F477A: R_execMethod (svn/R-devel/src/main/eval.c:2096) ==3446389== by 0x48A14C0: R_dispatchGeneric (svn/R-devel/src/library/methods/src/methods_list_dispatch.c:1153) ==3446389== by 0x53A862: do_standardGeneric (svn/R-devel/src/main/objects.c:1280) ==3446389== by 0x4E50A4: bcEval (svn/R-devel/src/main/eval.c:7085) ==3446389== by 0x4F1DAF: Rf_eval (svn/R-devel/src/main/eval.c:750) ==3446389== Address 0x16cb30b8 is 16 bytes after a block of size 7,960 alloc'd ==3446389== at 0x484086F: malloc (/builddir/build/BUILD/valgrind-3.18.1/coregrind/m_replacemalloc/vg_replace_malloc.c:381) ==3446389== by 0x5311B0: GetNewPage (svn/R-devel/src/main/memory.c:974) ==3446389== by 0x53153A: Rf_allocSExp (svn/R-devel/src/main/memory.c:2399) ==3446389== by 0x58D44F: ReadItem (svn/R-devel/src/main/serialize.c:1879) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== ==3446389== Invalid read of size 4 ==3446389== at 0x167738CB: RCatnet::genSamples(SEXPREC*, SEXPREC*, SEXPREC*) (packages/tests-vg/catnet/src/rcatnet.cpp:582) ==3446389== by 0x1676F6B4: catnetSamples (packages/tests-vg/catnet/src/catnet_rexport.cpp:714) ==3446389== by 0x4A08B1: R_doDotCall (svn/R-devel/src/main/dotcode.c:877) ==3446389== by 0x4A0E0B: do_dotcall (svn/R-devel/src/main/dotcode.c:1551) ==3446389== by 0x4D7AEB: bcEval (svn/R-devel/src/main/eval.c:7128) ==3446389== by 0x4F1DAF: Rf_eval (svn/R-devel/src/main/eval.c:750) ==3446389== by 0x4F370D: R_execClosure (svn/R-devel/src/main/eval.c:1920) ==3446389== by 0x4F477A: R_execMethod (svn/R-devel/src/main/eval.c:2096) ==3446389== by 0x48A14C0: R_dispatchGeneric (svn/R-devel/src/library/methods/src/methods_list_dispatch.c:1153) ==3446389== by 0x53A862: do_standardGeneric (svn/R-devel/src/main/objects.c:1280) ==3446389== by 0x4E50A4: bcEval (svn/R-devel/src/main/eval.c:7085) ==3446389== by 0x4F1DAF: Rf_eval (svn/R-devel/src/main/eval.c:750) ==3446389== Address 0x16cb30b8 is 16 bytes after a block of size 7,960 alloc'd ==3446389== at 0x484086F: malloc (/builddir/build/BUILD/valgrind-3.18.1/coregrind/m_replacemalloc/vg_replace_malloc.c:381) ==3446389== by 0x5311B0: GetNewPage (svn/R-devel/src/main/memory.c:974) ==3446389== by 0x53153A: Rf_allocSExp (svn/R-devel/src/main/memory.c:2399) ==3446389== by 0x58D44F: ReadItem (svn/R-devel/src/main/serialize.c:1879) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== by 0x58D4F1: ReadItem (svn/R-devel/src/main/serialize.c:1895) ==3446389== by 0x58D540: ReadItem (svn/R-devel/src/main/serialize.c:1898) ==3446389== > cnNodeSampleLoglik(node=5, parents=c(1,2), data=psamples) [1] -0.6834014 > > > > cleanEx() > nameEx("cnNodes") > ### * cnNodes > > flush(stderr()); flush(stdout()) > > ### Name: cnNodes-method > ### Title: Netwok Nodes > ### Aliases: cnNodes cnNodes,catNetwork,missing-method > ### cnNodes,catNetwork,vector-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnNodes(object=cnet) [1] "N1" "N2" "N3" "N4" "N5" "N6" "N7" "N8" "N9" "N10" > > > > cleanEx() > nameEx("cnNumNodes") > ### * cnNumNodes > > flush(stderr()); flush(stdout()) > > ### Name: cnNumNodes-method > ### Title: Network Size > ### Aliases: cnNumNodes cnNumNodes,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnNumNodes(object=cnet) [1] 10 > > > > cleanEx() > nameEx("cnOrder") > ### * cnOrder > > flush(stderr()); flush(stdout()) > > ### Name: cnOrder-method > ### Title: Network Node Order > ### Aliases: cnOrder cnOrder,catNetwork-method cnOrder,list-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=20, maxParents=3, numCategories=2) > cnOrder(object=cnet) [1] 1 2 4 7 8 12 13 14 16 17 18 19 20 3 5 6 9 10 11 15 > > > > cleanEx() > nameEx("cnParHist") > ### * cnParHist > > flush(stderr()); flush(stdout()) > > ### Name: cnParHist-method > ### Title: Parenthood Histogram > ### Aliases: cnParHist cnParHist,catNetworkEvaluate-method > ### cnParHist,list-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=20, maxParents=3, numCategories=2) > psamples <- cnSamples(cnet, 100) > nodeOrder <- sample(1:20) > nets <- cnSearchOrder(psamples, perturbations=NULL, + maxParentSet=2, maxComplexity=50, nodeOrder) > cnParHist(object=nets) N1 N2 N3 N4 N5 N6 N7 N8 N9 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N20 N1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N3 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N4 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N6 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N7 0 0 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N8 0 0 0 0 0 0 29 0 0 0 0 0 0 0 0 0 0 0 0 0 N9 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 N10 0 0 0 0 28 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 N11 0 0 0 0 7 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 N12 0 0 0 0 0 0 0 0 25 0 0 0 0 0 0 0 0 0 0 0 N13 0 0 0 22 0 0 0 0 0 0 22 0 0 0 0 0 0 0 0 0 N14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N15 0 0 0 0 0 0 26 0 0 0 9 0 0 0 0 0 0 0 0 0 N16 0 0 0 0 0 0 0 0 0 18 0 0 0 0 23 0 0 0 0 0 N17 0 11 0 0 0 11 0 0 3 0 0 0 0 0 0 0 0 0 0 0 N18 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 N19 0 0 0 0 0 0 0 0 0 0 21 0 0 2 0 0 0 0 0 0 N20 0 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 0 0 > > > > cleanEx() > nameEx("cnParents") > ### * cnParents > > flush(stderr()); flush(stdout()) > > ### Name: cnParents-method > ### Title: Network Parent Structure > ### Aliases: cnParents cnParents,catNetwork,missing-method > ### cnParents,catNetwork,character-method > ### cnParents,catNetwork,vector-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnParents(object=cnet) $N1 [1] "N9" $N2 [1] "N4" "N1" $N5 [1] "N4" "N7" "N9" $N10 [1] "N2" > > > > cleanEx() > nameEx("cnPlot") > ### * cnPlot > > flush(stderr()); flush(stdout()) > > ### Name: cnPlot-method > ### Title: Plot Network > ### Aliases: cnPlot cnPlot,catNetwork-method > ### cnPlot,catNetworkEvaluate-method > ### Keywords: methods graphs aplot > > ### ** Examples > > ## Set R_CATNET_USE_IGRAPH to TRUE if you want to use 'igraph' > #Sys.setenv(R_CATNET_USE_IGRAPH=FALSE) > #cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > #cnPlot(object=cnet) > > > > cleanEx() > nameEx("cnPredict") > ### * cnPredict > > flush(stderr()); flush(stdout()) > > ### Name: cnPredict-method > ### Title: Prediction > ### Aliases: cnPredict cnPredict,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3) > ## generate a sample of size 2 and set nodes 8, 9 and 10 as not-available > psamples <- matrix(as.integer(1+rbinom(10*2, 2, 0.4)), nrow=10) > psamples[8, ] <- rep(NA, 2) > psamples[9, ] <- rep(NA, 2) > psamples[10, ] <- rep(NA, 2) > ## make show sample rows are named after the network's nodes > rownames(psamples) <- cnNodes(cnet) > ## predict the values of nodes 8, 9 and 10 > newsamples <- cnPredict(object=cnet, data=psamples) > > > > cleanEx() > nameEx("cnProb") > ### * cnProb > > flush(stderr()); flush(stdout()) > > ### Name: cnProb-method > ### Title: Conditional Probability Structure > ### Aliases: cnProb cnPlotProb cnProb,catNetwork-method > ### cnPlotProb,catNetwork-method > ### Keywords: methods graphs distribution > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnProb(object=cnet) $N1 N9 C1 C2 A C1 0.034 0.966 B C2 0.719 0.281 $N2 N4 N1 C1 C2 A C1 C1 0.446 0.554 B C1 C2 0.727 0.273 A C2 C1 0.554 0.446 B C2 C2 0.881 0.119 $N3 C1 C2 0.638 0.362 $N4 C1 C2 0.56 0.44 $N5 N4 N7 N9 C1 C2 A C1 C1 C1 0.587 0.413 B C1 C1 C2 0.402 0.598 A C1 C2 C1 0.047 0.953 B C1 C2 C2 0.514 0.486 A C2 C1 C1 0.357 0.643 B C2 C1 C2 0.642 0.358 A C2 C2 C1 0.416 0.584 B C2 C2 C2 0.379 0.621 $N6 C1 C2 0.62 0.38 $N7 C1 C2 0.757 0.243 $N8 C1 C2 0.581 0.419 $N9 C1 C2 0.717 0.283 $N10 N2 C1 C2 A C1 0.385 0.615 B C2 0.088 0.912 > cnPlotProb(object=cnet) Node[N1], Parents: N9 [ C1]C1 0.034 [ C1]C2 0.966 [ C2]C1 0.719 [ C2]C2 0.281 Node[N2], Parents: N4 N1 [ C1 C1]C1 0.446 [ C1 C1]C2 0.554 [ C1 C2]C1 0.727 [ C1 C2]C2 0.273 [ C2 C1]C1 0.554 [ C2 C1]C2 0.446 [ C2 C2]C1 0.881 [ C2 C2]C2 0.119 Node[N3], Parents: []C1 0.638 []C2 0.362 Node[N4], Parents: []C1 0.56 []C2 0.44 Node[N5], Parents: N4 N7 N9 [ C1 C1 C1]C1 0.587 [ C1 C1 C1]C2 0.413 [ C1 C1 C2]C1 0.402 [ C1 C1 C2]C2 0.598 [ C1 C2 C1]C1 0.047 [ C1 C2 C1]C2 0.953 [ C1 C2 C2]C1 0.514 [ C1 C2 C2]C2 0.486 [ C2 C1 C1]C1 0.357 [ C2 C1 C1]C2 0.643 [ C2 C1 C2]C1 0.642 [ C2 C1 C2]C2 0.358 [ C2 C2 C1]C1 0.416 [ C2 C2 C1]C2 0.584 [ C2 C2 C2]C1 0.379 [ C2 C2 C2]C2 0.621 Node[N6], Parents: []C1 0.62 []C2 0.38 Node[N7], Parents: []C1 0.757 []C2 0.243 Node[N8], Parents: []C1 0.581 []C2 0.419 Node[N9], Parents: []C1 0.717 []C2 0.283 Node[N10], Parents: N2 [ C1]C1 0.385 [ C1]C2 0.615 [ C2]C1 0.088 [ C2]C2 0.912 > > > > cleanEx() > nameEx("cnRandomCatnet") > ### * cnRandomCatnet > > flush(stderr()); flush(stdout()) > > ### Name: cnRandomCatnet > ### Title: Random Network > ### Aliases: cnRandomCatnet > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=20, maxParents=3, numCategories=2) > > > > cleanEx() > nameEx("cnReorderNodes") > ### * cnReorderNodes > > flush(stderr()); flush(stdout()) > > ### Name: cnReorderNodes-method > ### Title: Reorder Network Nodes > ### Aliases: cnReorderNodes cnReorderNodes,catNetwork,vector-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnMatParents(cnet) N1 N2 N3 N4 N5 N6 N7 N8 N9 N10 N1 0 0 0 0 0 0 0 0 1 0 N2 1 0 0 1 0 0 0 0 0 0 N3 0 0 0 0 0 0 0 0 0 0 N4 0 0 0 0 0 0 0 0 0 0 N5 0 0 0 1 0 0 1 0 1 0 N6 0 0 0 0 0 0 0 0 0 0 N7 0 0 0 0 0 0 0 0 0 0 N8 0 0 0 0 0 0 0 0 0 0 N9 0 0 0 0 0 0 0 0 0 0 N10 0 1 0 0 0 0 0 0 0 0 > cnet1 <- cnReorderNodes(object=cnet, nodeIndices=cnOrder(cnet)) > cnNodes(object=cnet1) [1] "N3" "N4" "N6" "N7" "N8" "N9" "N1" "N2" "N5" "N10" > cnMatParents(cnet1) N3 N4 N6 N7 N8 N9 N1 N2 N5 N10 N3 0 0 0 0 0 0 0 0 0 0 N4 0 0 0 0 0 0 0 0 0 0 N6 0 0 0 0 0 0 0 0 0 0 N7 0 0 0 0 0 0 0 0 0 0 N8 0 0 0 0 0 0 0 0 0 0 N9 0 0 0 0 0 0 0 0 0 0 N1 0 0 0 0 0 1 0 0 0 0 N2 0 1 0 0 0 0 1 0 0 0 N5 0 1 0 1 0 1 0 0 0 0 N10 0 0 0 0 0 0 0 1 0 0 > > > > cleanEx() > nameEx("cnSamples") > ### * cnSamples > > flush(stderr()); flush(stdout()) > > ### Name: cnSamples-method > ### Title: Samples from Network > ### Aliases: cnSamples cnSamples,catNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3) > ## generate a sample of size 100 from cnet > psamples <- cnSamples(object=cnet, numsamples=100, output="frame", as.index=FALSE) > ## perturbed sample > nsamples <- 20 > perturbations <- rbinom(10, 2, 0.4) > ## generate a perturbed sample of size 100 from cnet > psamples <- cnSamples(object=cnet, numsamples=nsamples, perturbations, as.index=TRUE) > > > > cleanEx() > nameEx("cnSearchHist") > ### * cnSearchHist > > flush(stderr()); flush(stdout()) > > ### Name: cnSearchHist > ### Title: Parent Histogram Matrix > ### Aliases: cnSearchHist > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=8, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) > mhisto <- cnSearchHist(data=psamples, perturbations=NULL, + maxParentSet=2, maxComplexity=20) > mhisto N1 N2 N3 N4 N5 N6 N7 N8 N1 0 0 0.00000 0.000000 0 0.0000 0.00000 0.00000 N2 0 0 0.00000 0.000000 0 0.0000 0.00000 0.00000 N3 0 0 0.00000 0.000000 0 17.8957 0.00000 0.00000 N4 0 0 0.00000 0.000000 0 0.0000 15.90755 0.00000 N5 0 0 0.00000 0.000000 0 0.0000 0.00000 0.00000 N6 0 0 13.91901 0.000000 0 0.0000 0.00000 0.00000 N7 0 0 0.00000 3.976889 0 0.0000 0.00000 15.90716 N8 0 0 0.00000 0.000000 0 0.0000 15.90755 0.00000 > > > > cleanEx() > nameEx("cnSearchOrder") > ### * cnSearchOrder > > flush(stderr()); flush(stdout()) > > ### Name: cnSearchOrder > ### Title: Network Search for Given Node Order > ### Aliases: cnSearchOrder > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=12, maxParents=3, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) > nodeOrder <- sample(1:12) > nets <- cnSearchOrder(data=psamples, perturbations=NULL, + maxParentSet=2, maxComplexity=36, nodeOrder) > ## next we find the network with complexity of the original one and plot it > cc <- cnComplexity(object=cnet) > cnFind(object=nets, complexity=cc) A catNetwork object with 12 nodes, 2 parents, 2 categories, Likelihood = -7.558422 , Complexity = 21 . > > > > cleanEx() > nameEx("cnSearchSA") > ### * cnSearchSA > > flush(stderr()); flush(stdout()) > > ### Name: cnSearchSA > ### Title: Stochastic Network Search > ### Aliases: cnSearchSA > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=6, maxParents=2, numCategories=2) > psamples <- cnSamples(object=cnet, numsamples=100) > nets <- cnSearchSA(data=psamples, perturbations=NULL, + maxParentSet=1, maxComplexity=16) > cc <- cnComplexity(object=cnet) > cnFind(object=nets, complexity=cc) A catNetwork object with 6 nodes, 1 parents, 2 categories, Likelihood = -3.620086 , Complexity = 9 . > > > > cleanEx() > nameEx("cnSetProb") > ### * cnSetProb > > flush(stderr()); flush(stdout()) > > ### Name: cnSetProb-method > ### Title: Set Probability from Data > ### Aliases: cnSetProb cnSetProb,catNetwork-method > ### cnSetProb,catSampleNetwork-method > ### Keywords: methods graphs > > ### ** Examples > > library(catnet) > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3) > psamples <- matrix(as.integer(1+rbinom(10*100, 2, 0.4)), nrow=10) > rownames(psamples) <- cnet@nodes > newcnet <- cnSetProb(object=cnet, data=psamples) > > > > cleanEx() > nameEx("cnSubNetwork") > ### * cnSubNetwork > > flush(stderr()); flush(stdout()) > > ### Name: cnSubNetwork-method > ### Title: Sub-Network > ### Aliases: cnSubNetwork cnSubNetwork,catNetwork-method > ### cnSubNetwork,catNetwork,vector,logical-method > ### Keywords: methods graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=2) > cnet1 <- cnSubNetwork(object=cnet, nodeIndices=c(1,2,3,4,5), indirectEdges=TRUE) > cnNodes(object=cnet) [1] "N1" "N2" "N3" "N4" "N5" "N6" "N7" "N8" "N9" "N10" > cnNodes(object=cnet1) [1] "N1" "N2" "N3" "N4" "N5" > > > > cleanEx() > nameEx("isDAG") > ### * isDAG > > flush(stderr()); flush(stdout()) > > ### Name: isDAG > ### Title: Check Direct Acyclic Graph (DAG) Condition > ### Aliases: isDAG > ### Keywords: graphs > > ### ** Examples > > cnet <- cnRandomCatnet(numnodes=20, maxParents=3, numCategories=2) > isDAG(lnodes=cnet@nodes, lpars=cnet@parents) [1] TRUE > > > > ### *