==35685== Memcheck, a memory error detector ==35685== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==35685== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==35685== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla ==35685== R Under development (unstable) (2018-02-06 r74224) -- "Unsuffered Consequences" Copyright (C) 2018 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 <- "gRapHD" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('gRapHD') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("CI.test") > ### * CI.test > > flush(stderr()); flush(stdout()) > > ### Name: CI.test > ### Title: Test of conditional independence > ### Aliases: CI.test > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="BIC") > CI.test(20,29,c(9,11),dsCont) $deviance [1] 0.7617515 $numP [1] 1 > #$deviance > #[1] 0.7617515263220724 > # > #$numP > #[1] 1 > > > > cleanEx() > nameEx("DFS") > ### * DFS > > flush(stderr()); flush(stdout()) > > ### Name: DFS > ### Title: Depth-first search > ### Aliases: DFS > ### Keywords: graphs > > ### ** Examples > > set.seed(7,kind="Mersenne-Twister") > dataset <- matrix(rnorm(1000),nrow=100,ncol=10) > m <- minForest(dataset,stat="BIC") > > DFS(edges=m@edges,v=1,p=10) [1] 5 2 9 8 > # [1] 5 2 9 8 > ####################################################################### > data(dsDiscr) > m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="BIC") > vertices <- DFS(edges=m1@edges, v=1, p=m1@p) > > # result > vertices integer(0) > # numeric(0) > # meaning that 1 is an isolated vertex > > # OR > m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="LR") > vertices <- DFS(edges=m1@edges, v=1, p=m1@p) > > # result > vertices [1] 4 8 12 19 18 14 7 17 5 3 10 13 15 9 6 20 16 11 2 > # [1] 4 8 12 19 18 14 7 17 5 3 10 13 15 9 6 20 16 11 2 > # meaning that 1 reachs all vertices (a tree) > > > > cleanEx() > nameEx("Degree") > ### * Degree > > flush(stderr()); flush(stdout()) > > ### Name: Degree > ### Title: Degree > ### Aliases: Degree > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > Degree(model=m1) 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 1 1 4 3 2 1 2 1 3 2 2 1 1 1 2 1 4 1 1 1 3 4 2 2 2 4 27 28 29 30 31 32 33 34 4 1 1 1 1 4 1 1 > > > > cleanEx() > nameEx("MCS") > ### * MCS > > flush(stderr()); flush(stdout()) > > ### Name: MCS > ### Title: Maximum cardinality search > ### Aliases: MCS > ### Keywords: graphs > > ### ** Examples > > set.seed(7,kind="Mersenne-Twister") > dataset <- matrix(rnorm(1000),nrow=100,ncol=10) > m <- minForest(dataset,stat="BIC") > > MCS(edges=m@edges,v=1,p=10) [1] 1 3 6 9 2 10 7 5 4 8 > > > > cleanEx() > nameEx("SubGraph") > ### * SubGraph > > flush(stderr()); flush(stdout()) > > ### Name: SubGraph > ### Title: Generates a subgraph > ### Aliases: SubGraph > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > v <- c(1,11,21,19,30,25,22,24,34,9,20,29) > subM1 <- SubGraph(model=m1,v=v) > plot(subM1,numIter=1500) > > > > cleanEx() > nameEx("adjMat") > ### * adjMat > > flush(stderr()); flush(stdout()) > > ### Name: adjMat > ### Title: Adjacency matrix > ### Aliases: adjMat > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > edges <- SubGraph(edges=m1@edges,v=1:10)@edges > adjMat(edges=edges,p=10) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 0 [3,] 0 0 0 1 0 0 1 0 0 0 [4,] 0 0 1 0 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 0 0 0 0 [6,] 0 0 0 0 0 0 0 0 0 0 [7,] 0 0 1 0 0 0 0 1 0 0 [8,] 0 0 0 0 0 0 1 0 0 0 [9,] 0 0 0 0 0 0 0 0 0 0 [10,] 0 0 0 0 0 0 0 0 0 0 > > > > cleanEx() > nameEx("calcStat") > ### * calcStat > > flush(stderr()); flush(stdout()) > > ### Name: calcStat > ### Title: Pairwise weights > ### Aliases: calcStat > ### Keywords: graphs > > ### ** Examples > > set.seed(7,kind="Mersenne-Twister") > dataset <- matrix(rnorm(1000),nrow=100,ncol=10) > m <- calcStat(dataset,stat="BIC") > > data(dsCont) > # m1 <- calcStat(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. in this case, there is no use for homog > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > v <- calcStat(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > > # result > head(v) $stat [,1] [,2] [,3] [,4] [1,] 17 27 3.930072e+02 1 [2,] 21 27 3.435780e+02 1 [3,] 22 25 3.060097e+02 1 [4,] 17 21 3.029414e+02 1 [5,] 27 32 3.000275e+02 1 [6,] 21 32 2.894179e+02 1 [7,] 17 32 2.599355e+02 1 [8,] 9 22 2.338344e+02 1 [9,] 4 32 1.998849e+02 1 [10,] 12 17 1.969194e+02 1 [11,] 3 22 1.937230e+02 1 [12,] 11 21 1.935715e+02 1 [13,] 3 14 1.928666e+02 1 [14,] 12 27 1.927812e+02 1 [15,] 16 26 1.918948e+02 1 [16,] 15 26 1.906713e+02 1 [17,] 2 17 1.873917e+02 1 [18,] 13 32 1.859587e+02 1 [19,] 23 27 1.842663e+02 1 [20,] 2 21 1.836640e+02 1 [21,] 9 25 1.809908e+02 1 [22,] 3 25 1.796451e+02 1 [23,] 3 4 1.776349e+02 1 [24,] 5 15 1.769144e+02 1 [25,] 14 25 1.762765e+02 1 [26,] 4 21 1.746475e+02 1 [27,] 4 11 1.731809e+02 1 [28,] 17 23 1.683505e+02 1 [29,] 13 27 1.678751e+02 1 [30,] 10 17 1.650624e+02 1 [31,] 26 31 1.642712e+02 1 [32,] 3 9 1.589041e+02 1 [33,] 13 21 1.576646e+02 1 [34,] 10 26 1.572169e+02 1 [35,] 2 27 1.533325e+02 1 [36,] 13 17 1.495015e+02 1 [37,] 16 17 1.485984e+02 1 [38,] 2 32 1.419080e+02 1 [39,] 5 26 1.385510e+02 1 [40,] 14 22 1.372589e+02 1 [41,] 12 23 1.358899e+02 1 [42,] 11 32 1.341870e+02 1 [43,] 12 16 1.339009e+02 1 [44,] 12 32 1.334448e+02 1 [45,] 23 32 1.305972e+02 1 [46,] 12 26 1.296924e+02 1 [47,] 23 26 1.294977e+02 1 [48,] 10 16 1.285830e+02 1 [49,] 11 27 1.260357e+02 1 [50,] 4 13 1.249816e+02 1 [51,] 10 27 1.223199e+02 1 [52,] 12 21 1.211114e+02 1 [53,] 16 27 1.205769e+02 1 [54,] 10 23 1.200105e+02 1 [55,] 17 26 1.186366e+02 1 [56,] 4 27 1.174676e+02 1 [57,] 10 12 1.166338e+02 1 [58,] 9 14 1.158274e+02 1 [59,] 10 32 1.128797e+02 1 [60,] 16 23 1.074654e+02 1 [61,] 15 16 1.065098e+02 1 [62,] 1 11 1.055705e+02 1 [63,] 4 14 1.055680e+02 1 [64,] 10 21 1.049240e+02 1 [65,] 28 32 1.032821e+02 1 [66,] 1 3 1.004591e+02 1 [67,] 1 14 9.808852e+01 1 [68,] 10 13 9.725168e+01 1 [69,] 2 23 9.707416e+01 1 [70,] 21 23 9.631026e+01 1 [71,] 4 9 9.557736e+01 1 [72,] 4 17 9.541709e+01 1 [73,] 3 11 9.468455e+01 1 [74,] 2 4 9.235943e+01 1 [75,] 2 11 9.157020e+01 1 [76,] 11 14 9.003386e+01 1 [77,] 2 10 8.950948e+01 1 [78,] 1 4 8.933284e+01 1 [79,] 16 31 8.921594e+01 1 [80,] 27 28 8.805636e+01 1 [81,] 9 11 8.754510e+01 1 [82,] 25 31 8.626179e+01 1 [83,] 25 30 8.583110e+01 1 [84,] 4 28 8.522673e+01 1 [85,] 6 23 8.465072e+01 1 [86,] 11 17 8.464007e+01 1 [87,] 4 22 8.391688e+01 1 [88,] 16 32 8.390921e+01 1 [89,] 26 27 8.351934e+01 1 [90,] 12 13 8.338733e+01 1 [91,] 13 28 8.184450e+01 1 [92,] 1 9 8.176370e+01 1 [93,] 15 23 8.158346e+01 1 [94,] 15 31 8.058814e+01 1 [95,] 2 12 8.046308e+01 1 [96,] 9 30 7.975969e+01 1 [97,] 13 23 7.958836e+01 1 [98,] 25 26 7.930942e+01 1 [99,] 15 17 7.919607e+01 1 [100,] 2 13 7.696541e+01 1 [101,] 10 15 7.571132e+01 1 [102,] 22 24 7.504257e+01 1 [103,] 11 13 7.479219e+01 1 [104,] 17 28 7.369010e+01 1 [105,] 16 21 7.324231e+01 1 [106,] 21 28 7.287203e+01 1 [107,] 24 25 7.280735e+01 1 [108,] 5 31 7.153262e+01 1 [109,] 1 32 6.929947e+01 1 [110,] 4 25 6.863832e+01 1 [111,] 22 31 6.787942e+01 1 [112,] 5 23 6.742836e+01 1 [113,] 11 22 6.734431e+01 1 [114,] 11 25 6.733366e+01 1 [115,] 14 30 6.605168e+01 1 [116,] 6 16 6.581701e+01 1 [117,] 22 30 6.538038e+01 1 [118,] 1 25 6.449367e+01 1 [119,] 10 31 6.413684e+01 1 [120,] 6 17 6.302915e+01 1 [121,] 5 10 6.284735e+01 1 [122,] 6 27 6.263025e+01 1 [123,] 2 16 6.043067e+01 1 [124,] 23 28 6.032156e+01 1 [125,] 26 32 5.971504e+01 1 [126,] 12 15 5.962270e+01 1 [127,] 24 26 5.757124e+01 1 [128,] 1 22 5.747689e+01 1 [129,] 5 13 5.745524e+01 1 [130,] 4 18 5.734117e+01 1 [131,] 1 21 5.670748e+01 1 [132,] 3 32 5.556796e+01 1 [133,] 30 31 5.501376e+01 1 [134,] 14 31 5.492661e+01 1 [135,] 5 16 5.464320e+01 1 [136,] 5 17 5.448293e+01 1 [137,] 11 18 5.351235e+01 1 [138,] 12 31 5.297555e+01 1 [139,] 22 26 5.270039e+01 1 [140,] 15 32 5.144131e+01 1 [141,] 26 30 5.088906e+01 1 [142,] 5 32 5.086806e+01 1 [143,] 23 31 5.035329e+01 1 [144,] 11 30 4.985583e+01 1 [145,] 13 26 4.945509e+01 1 [146,] 15 27 4.928200e+01 1 [147,] 6 26 4.895486e+01 1 [148,] 14 18 4.842440e+01 1 [149,] 5 12 4.741102e+01 1 [150,] 1 30 4.682311e+01 1 [151,] 12 28 4.564690e+01 1 [152,] 4 10 4.519067e+01 1 [153,] 2 15 4.474194e+01 1 [154,] 11 28 4.453491e+01 1 [155,] 17 31 4.448037e+01 1 [156,] 9 31 4.350695e+01 1 [157,] 2 26 4.312066e+01 1 [158,] 4 23 4.303263e+01 1 [159,] 3 18 4.267108e+01 1 [160,] 18 22 4.260978e+01 1 [161,] 1 18 4.220139e+01 1 [162,] 1 27 4.191295e+01 1 [163,] 13 16 4.166406e+01 1 [164,] 9 18 4.130600e+01 1 [165,] 6 12 4.124392e+01 1 [166,] 9 24 4.121993e+01 1 [167,] 18 25 4.084191e+01 1 [168,] 2 28 4.070643e+01 1 [169,] 18 32 4.031450e+01 1 [170,] 16 28 4.011082e+01 1 [171,] 11 23 3.995484e+01 1 [172,] 18 21 3.943869e+01 1 [173,] 5 27 3.851028e+01 1 [174,] 1 28 3.846110e+01 1 [175,] 13 15 3.818620e+01 1 [176,] 2 6 3.779414e+01 1 [177,] 3 30 3.749191e+01 1 [178,] 3 21 3.746155e+01 1 [179,] 4 12 3.720402e+01 1 [180,] 3 28 3.694559e+01 1 [181,] 6 31 3.673137e+01 1 [182,] 1 13 3.539421e+01 1 [183,] 3 7 3.511524e+01 1 [184,] 6 10 3.462047e+01 1 [185,] 11 12 3.383128e+01 1 [186,] 6 15 3.348740e+01 1 [187,] 3 31 3.346076e+01 1 [188,] 10 28 3.345295e+01 1 [189,] 15 28 3.341059e+01 1 [190,] 14 32 3.291574e+01 1 [191,] 6 21 3.269681e+01 1 [192,] 21 26 3.239687e+01 1 [193,] 5 28 3.174779e+01 1 [194,] 9 32 3.156118e+01 1 [195,] 3 13 3.147422e+01 1 [196,] 14 21 3.131649e+01 1 [197,] 9 21 3.089488e+01 1 [198,] 1 2 3.067873e+01 1 [199,] 18 30 2.992155e+01 1 [200,] 4 7 2.990081e+01 1 [201,] 24 31 2.847981e+01 1 [202,] 15 30 2.708525e+01 1 [203,] 15 25 2.707386e+01 1 [204,] 14 26 2.689123e+01 1 [205,] 5 24 2.638819e+01 1 [206,] 26 28 2.625229e+01 1 [207,] 1 17 2.610946e+01 1 [208,] 6 32 2.606172e+01 1 [209,] 15 21 2.563353e+01 1 [210,] 19 21 2.527321e+01 1 [211,] 4 30 2.518567e+01 1 [212,] 9 26 2.509351e+01 1 [213,] 18 27 2.508520e+01 1 [214,] 27 31 2.487867e+01 1 [215,] 5 30 2.451565e+01 1 [216,] 7 16 2.423221e+01 1 [217,] 13 18 2.411108e+01 1 [218,] 19 27 2.404298e+01 1 [219,] 15 24 2.396864e+01 1 [220,] 7 14 2.379870e+01 1 [221,] 9 20 2.350318e+01 1 [222,] 16 24 2.343859e+01 1 [223,] 7 32 2.324295e+01 1 [224,] 6 22 2.319300e+01 1 [225,] 23 24 2.305678e+01 1 [226,] 19 32 2.293366e+01 1 [227,] 2 5 2.290908e+01 1 [228,] 4 16 2.283545e+01 1 [229,] 4 19 2.263944e+01 1 [230,] 17 19 2.233499e+01 1 [231,] 7 8 2.145021e+01 1 [232,] 14 28 2.127572e+01 1 [233,] 6 25 2.080219e+01 1 [234,] 1 23 2.032210e+01 1 [235,] 2 9 1.964412e+01 1 [236,] 16 25 1.959798e+01 1 [237,] 2 3 1.957327e+01 1 [238,] 11 19 1.895932e+01 1 [239,] 19 28 1.853586e+01 1 [240,] 1 20 1.850018e+01 1 [241,] 2 19 1.848153e+01 1 [242,] 21 22 1.832765e+01 1 [243,] 24 34 1.825593e+01 1 [244,] 6 28 1.821637e+01 1 [245,] 2 18 1.819568e+01 1 [246,] 7 34 1.796520e+01 1 [247,] 4 15 1.793013e+01 1 [248,] 13 19 1.789696e+01 1 [249,] 16 30 1.779061e+01 1 [250,] 13 14 1.766872e+01 1 [251,] 5 8 1.737238e+01 1 [252,] 10 11 1.727901e+01 1 [253,] 18 28 1.706162e+01 1 [254,] 5 25 1.699460e+01 1 [255,] 9 13 1.699328e+01 1 [256,] 9 28 1.693643e+01 1 [257,] 14 24 1.680549e+01 1 [258,] 16 22 1.668729e+01 1 [259,] 8 9 1.643545e+01 1 [260,] 20 28 1.604762e+01 1 [261,] 3 27 1.577047e+01 1 [262,] 17 18 1.570372e+01 1 [263,] 14 15 1.556687e+01 1 [264,] 5 21 1.506382e+01 1 [265,] 24 30 1.488005e+01 1 [266,] 4 5 1.482227e+01 1 [267,] 22 32 1.476012e+01 1 [268,] 6 13 1.463189e+01 1 [269,] 19 23 1.436194e+01 1 [270,] 5 33 1.434246e+01 1 [271,] 11 20 1.426786e+01 1 [272,] 31 32 1.404449e+01 1 [273,] 3 24 1.378560e+01 1 [274,] 14 27 1.373276e+01 1 [275,] 3 8 1.344206e+01 1 [276,] 8 15 1.340075e+01 1 [277,] 11 24 1.332176e+01 1 [278,] 15 33 1.312599e+01 1 [279,] 5 14 1.309065e+01 1 [280,] 20 21 1.300264e+01 1 [281,] 21 25 1.298567e+01 1 [282,] 14 20 1.281016e+01 1 [283,] 20 22 1.267914e+01 1 [284,] 13 31 1.255952e+01 1 [285,] 6 33 1.218842e+01 1 [286,] 4 20 1.211998e+01 1 [287,] 7 27 1.200531e+01 1 [288,] 8 33 1.199725e+01 1 [289,] 1 31 1.196703e+01 1 [290,] 7 28 1.185740e+01 1 [291,] 1 19 1.149768e+01 1 [292,] 15 22 1.096479e+01 1 [293,] 5 6 1.094271e+01 1 [294,] 12 19 1.092289e+01 1 [295,] 20 32 1.089732e+01 1 [296,] 12 24 1.084990e+01 1 [297,] 1 12 1.080518e+01 1 [298,] 14 33 1.060051e+01 1 [299,] 9 29 1.036466e+01 1 [300,] 7 10 1.034419e+01 1 [301,] 3 19 1.028808e+01 1 [302,] 23 33 1.026641e+01 1 [303,] 22 29 1.025521e+01 1 [304,] 7 11 1.015289e+01 1 [305,] 33 34 9.988765e+00 1 [306,] 21 30 9.664544e+00 1 [307,] 7 21 9.655128e+00 1 [308,] 29 30 9.524572e+00 1 [309,] 2 31 9.457282e+00 1 [310,] 7 13 9.447235e+00 1 [311,] 23 25 9.405189e+00 1 [312,] 3 17 9.244462e+00 1 [313,] 25 29 9.198665e+00 1 [314,] 25 32 9.192324e+00 1 [315,] 10 19 9.130935e+00 1 [316,] 7 26 9.106506e+00 1 [317,] 7 24 9.014547e+00 1 [318,] 2 20 8.956791e+00 1 [319,] 7 12 8.940372e+00 1 [320,] 4 29 8.935597e+00 1 [321,] 1 24 8.933913e+00 1 [322,] 20 30 8.817678e+00 1 [323,] 18 24 8.734574e+00 1 [324,] 22 23 8.665172e+00 1 [325,] 6 24 8.596678e+00 1 [326,] 13 20 8.527912e+00 1 [327,] 7 15 8.520297e+00 1 [328,] 3 20 8.496261e+00 1 [329,] 28 33 8.464411e+00 1 [330,] 2 22 8.332357e+00 1 [331,] 10 25 8.187821e+00 1 [332,] 10 24 8.164370e+00 1 [333,] 22 28 8.098092e+00 1 [334,] 8 22 7.903468e+00 1 [335,] 16 19 7.859577e+00 1 [336,] 12 25 7.726594e+00 1 [337,] 5 22 7.615848e+00 1 [338,] 7 22 7.539826e+00 1 [339,] 7 17 7.483007e+00 1 [340,] 3 26 7.433837e+00 1 [341,] 9 16 7.383785e+00 1 [342,] 7 23 7.251472e+00 1 [343,] 18 20 7.245518e+00 1 [344,] 14 29 7.233467e+00 1 [345,] 13 22 7.154846e+00 1 [346,] 15 19 7.143546e+00 1 [347,] 6 11 7.091439e+00 1 [348,] 12 22 7.062199e+00 1 [349,] 2 14 7.016082e+00 1 [350,] 10 30 6.970199e+00 1 [351,] 7 25 6.907101e+00 1 [352,] 26 33 6.904618e+00 1 [353,] 20 25 6.870696e+00 1 [354,] 9 27 6.858892e+00 1 [355,] 11 16 6.810556e+00 1 [356,] 20 27 6.762133e+00 1 [357,] 11 31 6.735848e+00 1 [358,] 4 26 6.601460e+00 1 [359,] 26 34 6.443491e+00 1 [360,] 5 34 6.331716e+00 1 [361,] 21 31 6.292459e+00 1 [362,] 18 19 6.283434e+00 1 [363,] 11 29 6.001952e+00 1 [364,] 5 7 5.992783e+00 1 [365,] 3 6 5.827330e+00 1 [366,] 5 19 5.774815e+00 1 [367,] 17 20 5.706459e+00 1 [368,] 18 31 5.676619e+00 1 [369,] 12 30 5.603283e+00 1 [370,] 19 30 5.408174e+00 1 [371,] 3 29 5.265633e+00 1 [372,] 6 7 5.221755e+00 1 [373,] 9 19 4.949856e+00 1 [374,] 32 34 4.907585e+00 1 [375,] 8 24 4.846874e+00 1 [376,] 6 14 4.700922e+00 1 [377,] 2 7 4.595057e+00 1 [378,] 8 21 4.585419e+00 1 [379,] 29 31 4.570163e+00 1 [380,] 14 34 4.549420e+00 1 [381,] 12 18 4.534744e+00 1 [382,] 13 34 4.386890e+00 1 [383,] 9 17 4.348251e+00 1 [384,] 1 29 4.340919e+00 1 [385,] 2 29 4.208298e+00 1 [386,] 31 33 4.206215e+00 1 [387,] 8 27 4.198486e+00 1 [388,] 28 31 4.164734e+00 1 [389,] 14 16 4.129889e+00 1 [390,] 21 24 4.112976e+00 1 [391,] 25 28 4.090089e+00 1 [392,] 8 19 4.077113e+00 1 [393,] 2 30 4.059259e+00 1 [394,] 13 25 4.020386e+00 1 [395,] 29 32 3.962820e+00 1 [396,] 4 24 3.933882e+00 1 [397,] 4 6 3.914196e+00 1 [398,] 19 22 3.900819e+00 1 [399,] 30 32 3.897594e+00 1 [400,] 21 29 3.890286e+00 1 [401,] 19 26 3.843279e+00 1 [402,] 20 31 3.835915e+00 1 [403,] 1 7 3.825010e+00 1 [404,] 16 34 3.662841e+00 1 [405,] 23 29 3.504383e+00 1 [406,] 8 28 3.473454e+00 1 [407,] 8 26 3.320904e+00 1 [408,] 16 33 3.318582e+00 1 [409,] 4 8 3.309478e+00 1 [410,] 9 15 3.282499e+00 1 [411,] 27 34 3.247742e+00 1 [412,] 25 33 3.109388e+00 1 [413,] 7 9 3.083575e+00 1 [414,] 20 23 3.017632e+00 1 [415,] 2 33 2.992980e+00 1 [416,] 8 34 2.936177e+00 1 [417,] 6 8 2.853499e+00 1 [418,] 12 34 2.784540e+00 1 [419,] 7 18 2.705431e+00 1 [420,] 7 33 2.639546e+00 1 [421,] 24 27 2.613395e+00 1 [422,] 1 10 2.605808e+00 1 [423,] 19 25 2.591230e+00 1 [424,] 23 34 2.554045e+00 1 [425,] 6 9 2.534599e+00 1 [426,] 1 6 2.531476e+00 1 [427,] 2 25 2.523563e+00 1 [428,] 10 29 2.498016e+00 1 [429,] 24 29 2.494246e+00 1 [430,] 14 19 2.466267e+00 1 [431,] 10 34 2.441935e+00 1 [432,] 10 22 2.436036e+00 1 [433,] 6 20 2.421787e+00 1 [434,] 8 11 2.405017e+00 1 [435,] 14 17 2.389918e+00 1 [436,] 24 33 2.338125e+00 1 [437,] 4 34 2.245946e+00 1 [438,] 28 30 2.228969e+00 1 [439,] 8 30 2.094186e+00 1 [440,] 10 33 2.044582e+00 1 [441,] 27 30 1.827184e+00 1 [442,] 19 20 1.820275e+00 1 [443,] 20 24 1.707429e+00 1 [444,] 1 26 1.671748e+00 1 [445,] 8 20 1.659269e+00 1 [446,] 8 10 1.597595e+00 1 [447,] 22 34 1.588240e+00 1 [448,] 3 23 1.542477e+00 1 [449,] 8 17 1.512450e+00 1 [450,] 5 9 1.493583e+00 1 [451,] 17 33 1.486465e+00 1 [452,] 10 18 1.471440e+00 1 [453,] 18 23 1.425424e+00 1 [454,] 12 20 1.418106e+00 1 [455,] 4 31 1.404881e+00 1 [456,] 30 34 1.311838e+00 1 [457,] 24 28 1.309870e+00 1 [458,] 18 29 1.302378e+00 1 [459,] 18 33 1.263265e+00 1 [460,] 8 25 1.219224e+00 1 [461,] 3 34 1.163992e+00 1 [462,] 2 24 1.115218e+00 1 [463,] 13 30 1.094195e+00 1 [464,] 16 18 1.070585e+00 1 [465,] 11 15 1.065964e+00 1 [466,] 6 19 1.056937e+00 1 [467,] 27 29 1.039676e+00 1 [468,] 13 29 1.039060e+00 1 [469,] 15 34 1.020498e+00 1 [470,] 9 34 1.009864e+00 1 [471,] 1 34 9.542846e-01 1 [472,] 17 34 9.533672e-01 1 [473,] 32 33 9.259554e-01 1 [474,] 7 19 9.189566e-01 1 [475,] 7 29 8.323348e-01 1 [476,] 9 33 8.169982e-01 1 [477,] 7 30 8.120767e-01 1 [478,] 10 14 8.025204e-01 1 [479,] 28 34 7.801384e-01 1 [480,] 20 26 7.705793e-01 1 [481,] 2 34 7.615467e-01 1 [482,] 3 10 7.580051e-01 1 [483,] 17 24 7.274849e-01 1 [484,] 8 13 7.143643e-01 1 [485,] 10 20 7.108098e-01 1 [486,] 8 12 6.916721e-01 1 [487,] 6 18 6.854297e-01 1 [488,] 5 11 6.725091e-01 1 [489,] 6 34 6.627845e-01 1 [490,] 6 29 6.463188e-01 1 [491,] 17 25 6.403813e-01 1 [492,] 9 12 6.223189e-01 1 [493,] 26 29 6.118895e-01 1 [494,] 31 34 6.008859e-01 1 [495,] 8 32 5.981908e-01 1 [496,] 19 29 5.526115e-01 1 [497,] 22 33 4.933672e-01 1 [498,] 1 8 4.677617e-01 1 [499,] 19 24 4.144195e-01 1 [500,] 3 12 4.139415e-01 1 [501,] 12 29 4.066235e-01 1 [502,] 1 33 3.669072e-01 1 [503,] 18 26 3.501867e-01 1 [504,] 22 27 3.427936e-01 1 [505,] 25 34 3.192776e-01 1 [506,] 29 34 3.174999e-01 1 [507,] 19 31 3.003879e-01 1 [508,] 8 14 2.891089e-01 1 [509,] 17 29 2.833880e-01 1 [510,] 8 29 2.802653e-01 1 [511,] 27 33 2.717693e-01 1 [512,] 1 15 2.589140e-01 1 [513,] 5 20 2.532249e-01 1 [514,] 17 30 2.221317e-01 1 [515,] 30 33 2.101157e-01 1 [516,] 11 34 2.032808e-01 1 [517,] 3 16 1.977027e-01 1 [518,] 8 23 1.938347e-01 1 [519,] 25 27 1.927973e-01 1 [520,] 19 33 1.495416e-01 1 [521,] 5 29 1.466237e-01 1 [522,] 16 29 1.453376e-01 1 [523,] 20 29 1.450353e-01 1 [524,] 21 34 1.436818e-01 1 [525,] 13 24 1.313336e-01 1 [526,] 20 33 1.239256e-01 1 [527,] 24 32 1.207969e-01 1 [528,] 3 5 1.171594e-01 1 [529,] 23 30 1.170729e-01 1 [530,] 12 33 1.168170e-01 1 [531,] 5 18 1.080816e-01 1 [532,] 21 33 9.737301e-02 1 [533,] 4 33 7.413258e-02 1 [534,] 7 31 7.201388e-02 1 [535,] 15 29 6.883324e-02 1 [536,] 8 18 6.638611e-02 1 [537,] 1 5 6.507251e-02 1 [538,] 8 31 5.775762e-02 1 [539,] 3 33 5.640480e-02 1 [540,] 11 33 4.883771e-02 1 [541,] 13 33 4.836949e-02 1 [542,] 11 26 4.456820e-02 1 [543,] 28 29 4.103129e-02 1 [544,] 12 14 3.683548e-02 1 [545,] 29 33 3.121679e-02 1 [546,] 14 23 2.795619e-02 1 [547,] 17 22 2.081342e-02 1 [548,] 7 20 1.419877e-02 1 [549,] 9 23 6.243545e-03 1 [550,] 9 10 6.068253e-03 1 [551,] 15 18 3.755484e-03 1 [552,] 1 16 2.011324e-03 1 [553,] 3 15 1.459289e-03 1 [554,] 18 34 1.218201e-03 1 [555,] 20 34 1.195965e-03 1 [556,] 16 20 6.683552e-04 1 [557,] 2 8 6.235203e-04 1 [558,] 6 30 6.222314e-04 1 [559,] 19 34 5.940927e-04 1 [560,] 15 20 4.484711e-04 1 [561,] 8 16 1.515888e-04 1 $errors [,1] [,2] > # column 1: first vertex of the edge > # column 2: second vertex of the edge > # column 3: in this case, -LR > # column 4: number of parameters for the edge > # [,1] [,2] [,3] [,4] > # [1,] 17 27 393.0072 1 > # [2,] 21 27 343.5780 1 > # [3,] 22 25 306.0097 1 > # [4,] 17 21 302.9414 1 > # [5,] 27 32 300.0275 1 > # [6,] 21 32 289.4179 1 > > > > cleanEx() > nameEx("ccoeff") > ### * ccoeff > > flush(stderr()); flush(stdout()) > > ### Name: ccoeff > ### Title: Clustering coefficient > ### Aliases: ccoeff > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="BIC") > m1 <- stepw(m,dsCont) > cc <- ccoeff(edges=m1@edges,p=m1@p) > mean(cc) [1] 0.4717707 > > > > cleanEx() > nameEx("chStat") > ### * chStat > > flush(stderr()); flush(stdout()) > > ### Name: chStat > ### Title: Internal use > ### Aliases: chStat > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > ch <- findEd(m1@edges,m1@p,NULL,0) ==35685== Invalid read of size 4 ==35685== at 0x16AB985C: mcsFE (packages/tests-vg/gRapHD/src/findEd.c:150) ==35685== by 0x16AB9EF7: findEd (packages/tests-vg/gRapHD/src/findEd.c:477) ==35685== by 0x498279: R_doDotCall (svn/R-devel/src/main/dotcode.c:596) ==35685== by 0x4987A3: do_dotcall (svn/R-devel/src/main/dotcode.c:1252) ==35685== by 0x4CBE21: bcEval (svn/R-devel/src/main/eval.c:6766) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4DA4DC: Rf_eval (svn/R-devel/src/main/eval.c:747) ==35685== by 0x4DE4BF: do_set (svn/R-devel/src/main/eval.c:2774) ==35685== by 0x4DA6FB: Rf_eval (svn/R-devel/src/main/eval.c:699) ==35685== by 0x505EFC: Rf_ReplIteration (svn/R-devel/src/main/main.c:258) ==35685== by 0x5062C7: R_ReplConsole (svn/R-devel/src/main/main.c:308) ==35685== Address 0x19dde90c is 6,892 bytes inside a block of size 7,960 alloc'd ==35685== at 0x4C2DB6B: malloc (/builddir/build/BUILD/valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c:299) ==35685== by 0x510040: GetNewPage (svn/R-devel/src/main/memory.c:888) ==35685== by 0x511CB9: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2536) ==35685== by 0x453066: Rf_allocVector (svn/R-devel/src/include/Rinlinedfuns.h:566) ==35685== by 0x453066: do_c_dflt (svn/R-devel/src/main/bind.c:833) ==35685== by 0x453483: do_c (svn/R-devel/src/main/bind.c:779) ==35685== by 0x4CBE21: bcEval (svn/R-devel/src/main/eval.c:6766) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4D140A: bcEval (svn/R-devel/src/main/eval.c:6734) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4D140A: bcEval (svn/R-devel/src/main/eval.c:6734) ==35685== ==35685== Invalid read of size 4 ==35685== at 0x16AB990A: mcsFE (packages/tests-vg/gRapHD/src/findEd.c:206) ==35685== by 0x16AB9EF7: findEd (packages/tests-vg/gRapHD/src/findEd.c:477) ==35685== by 0x498279: R_doDotCall (svn/R-devel/src/main/dotcode.c:596) ==35685== by 0x4987A3: do_dotcall (svn/R-devel/src/main/dotcode.c:1252) ==35685== by 0x4CBE21: bcEval (svn/R-devel/src/main/eval.c:6766) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4DA4DC: Rf_eval (svn/R-devel/src/main/eval.c:747) ==35685== by 0x4DE4BF: do_set (svn/R-devel/src/main/eval.c:2774) ==35685== by 0x4DA6FB: Rf_eval (svn/R-devel/src/main/eval.c:699) ==35685== by 0x505EFC: Rf_ReplIteration (svn/R-devel/src/main/main.c:258) ==35685== by 0x5062C7: R_ReplConsole (svn/R-devel/src/main/main.c:308) ==35685== Address 0x19dde97c is 7,004 bytes inside a block of size 7,960 alloc'd ==35685== at 0x4C2DB6B: malloc (/builddir/build/BUILD/valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c:299) ==35685== by 0x510040: GetNewPage (svn/R-devel/src/main/memory.c:888) ==35685== by 0x511CB9: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2536) ==35685== by 0x453066: Rf_allocVector (svn/R-devel/src/include/Rinlinedfuns.h:566) ==35685== by 0x453066: do_c_dflt (svn/R-devel/src/main/bind.c:833) ==35685== by 0x453483: do_c (svn/R-devel/src/main/bind.c:779) ==35685== by 0x4CBE21: bcEval (svn/R-devel/src/main/eval.c:6766) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4D140A: bcEval (svn/R-devel/src/main/eval.c:6734) ==35685== by 0x4DA34F: Rf_eval (svn/R-devel/src/main/eval.c:624) ==35685== by 0x4DBC3E: R_execClosure (svn/R-devel/src/main/eval.c:1764) ==35685== by 0x4D140A: bcEval (svn/R-devel/src/main/eval.c:6734) ==35685== > ch <- chStat(m1,dsCont,ch,forbEdges=0) > str(ch) List of 2 $ edges.to.test: num [1:53, 1:5] 4 3 18 3 3 4 7 4 14 7 ... $ S :List of 53 ..$ : int 3 ..$ : int 4 ..$ : int 4 ..$ : int 4 ..$ : int 7 ..$ : int 32 ..$ : int 3 ..$ : int 3 ..$ : int 3 ..$ : int 3 ..$ : int 3 ..$ : int 22 ..$ : int 22 ..$ : int 22 ..$ : int 9 ..$ : int 25 ..$ : int 9 ..$ : int 9 ..$ : int 22 ..$ : int 22 ..$ : int 22 ..$ : int 32 ..$ : int 32 ..$ : int 27 ..$ : int 27 ..$ : int 27 ..$ : int 21 ..$ : int 21 ..$ : int 21 ..$ : int 27 ..$ : int 27 ..$ : int 27 ..$ : int 11 ..$ : int 17 ..$ : int 23 ..$ : int 17 ..$ : int 17 ..$ : int 17 ..$ : int 17 ..$ : int 17 ..$ : int 10 ..$ : int 26 ..$ : int 26 ..$ : int 26 ..$ : int 15 ..$ : int 5 ..$ : int 26 ..$ : int 26 ..$ : int 26 ..$ : int 32 ..$ : int 32 ..$ : int 32 ..$ : int 24 > # List of 2 > # $ edges.to.test: num [1:53, 1:5] 1 11 19 11 17 2 2 10 10 2 ... > # $ S :List of 53 > # ..$ : int 11 > # ..$ : int 21 > # ..$ : int 21 > # ..$ : int 21 > # ..$ : int 27 > # ..$ : int 17 > # ... > head(ch$edges.to.test) [,1] [,2] [,3] [,4] [,5] [1,] 4 7 1 -1.8253223 1 [2,] 3 18 2 -1.2200741 1 [3,] 18 32 3 -0.2174925 1 [4,] 3 32 4 -31.8061495 1 [5,] 3 8 5 -3.9332329 1 [6,] 4 13 6 -3.4443466 1 > # [,1] [,2] [,3] [,4] [,5] > # [1,] 1 21 1 -0.61733689 1 > # [2,] 11 19 2 -0.24637623 1 > # [3,] 19 27 3 -0.47194908 1 > # [4,] 11 27 4 -7.00259895 1 > # [5,] 17 21 5 -11.09310305 1 > # [6,] 2 27 6 -0.04690911 1 > > # the columns in ch$edges.to.test > # 1: first vertex in the edge > # 2: second vertex in the edge > # 3: index os the separator in ch$S > # 4: change in the LR for the edge > # 5: number of parameters for the edge > > > > cleanEx() > nameEx("convData") > ### * convData > > flush(stderr()); flush(stdout()) > > ### Name: convData > ### Title: Converts dataset > ### Aliases: convData > ### Keywords: graphs > > ### ** Examples > > data(dsDiscr) > ds <- convData(dsDiscr) > > > > cleanEx() > nameEx("dsCont") > ### * dsCont > > flush(stderr()); flush(stdout()) > > ### Name: dsCont > ### Title: Test dataset > ### Aliases: dsCont > ### Keywords: datasets > > ### ** Examples > > data(dsCont) > > > > cleanEx() > nameEx("dsDiscr") > ### * dsDiscr > > flush(stderr()); flush(stdout()) > > ### Name: dsDiscr > ### Title: Test dataset > ### Aliases: dsDiscr > ### Keywords: datasets > > ### ** Examples > > data(dsDiscr) > > > > cleanEx() > nameEx("dsMixed") > ### * dsMixed > > flush(stderr()); flush(stdout()) > > ### Name: dsMixed > ### Title: Test dataset > ### Aliases: dsMixed > ### Keywords: datasets > > ### ** Examples > > data(dsMixed) > > > > cleanEx() > nameEx("findEd") > ### * findEd > > flush(stderr()); flush(stdout()) > > ### Name: findEd > ### Title: Finds add-eligible edges > ### Aliases: findEd > ### Keywords: graphs > > ### ** Examples > > edges <- matrix(c(1,2,2,3,2,4,2,5,2,6,3,4,4,5,5,6),ncol=2,byrow=TRUE) > addEligible <- findEd(edges=edges,p=6,previous=NULL,numCat=rep(0,6), + from=1) > # > str(addEligible) > # List of 2 > # $ edges: num [1:7, 1:5] 1 1 3 1 4 3 1 3 4 5 ... > # $ S :List of 6 > # ..$ : int 2 > # ..$ : int [1:2] 2 4 > # ..$ : int 2 > # ..$ : int [1:2] 2 5 > # ..$ : int 2 > # ..$ : int 2 > # > addEligible$edges > # [,1] [,2] [,3] [,4] [,5] > # [1,] 1 3 1 0 0 > # [2,] 1 4 1 0 0 > # [3,] 3 5 2 0 0 > # [4,] 1 5 3 0 0 > # [5,] 4 6 4 0 0 > # [6,] 3 6 5 0 0 > # [7,] 1 6 6 0 0 > > # the columns in addEligible$edges > # 1: first vertex in the edge > # 2: second vertex in the edge > # 3: index os the separator in addEligible$S > # 4: change in the LRT for the edge (used if previous != NULL) > # 5: number of parameters for the edge (used if previous != NULL) > > # note that the edge 3-6 (row 6) is actually a "false positive". > # If it's used from=3,4,5, or 6, this does not happen. > > > > cleanEx() > nameEx("fit") > ### * fit > > flush(stderr()); flush(stdout()) > > ### Name: fit > ### Title: Log-likelihood, AIC, BIC > ### Aliases: fit > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > fit(edges=m1@edges,dataset=dsCont) Number of parameters -2*Log-likelihood AIC 101.00 23924.77 24126.77 BIC 24445.83 > > > > cleanEx() > nameEx("gRapHD-class") > ### * gRapHD-class > > flush(stderr()); flush(stdout()) > > ### Name: gRapHD-class > ### Title: Class "gRapHD" > ### Aliases: gRapHD-class initialize.gRapHD matrix.gRapHD summary.gRapHD > ### print.gRapHD show.gRapHD gRapHD.graphNEL graphNEL.gRapHD > ### Keywords: classes > > ### ** Examples > > # convertion from gRapHD to graphNEL > edges <- matrix(c(1,2,1,3,1,4),,2,byrow=TRUE) > g <- as(edges,"gRapHD") > #List of 9 > # $ edges : num [1:3, 1:2] 1 1 1 2 3 4 > # $ p : int 4 > # $ stat.user: chr "LR" > # $ statSeq : num [1:3] NA NA NA > # $ varType : int [1:4] 0 0 0 0 > # $ numCat : int [1:4] 0 0 0 0 > # $ homog : logi TRUE > # $ numP : num [1:3] NA NA NA > # $ userDef : num [1:2] 1 3 > # - attr(*, "class")= chr "gRapHD" > g1 <- as(g,"graphNEL") > # A graphNEL graph with undirected edges > # Number of Nodes = 4 > # Number of Edges = 3 > g1@nodes # the nodes names [1] "X1" "X2" "X3" "X4" > > > as(matrix(integer(0),,2),"gRapHD") gRapHD object Number of edges = 0 Number of vertices = 0 Model = continuous Statistic (minForest) = Statistic (stepw) = Statistic (user def.) = Edges (minForest) = 0...0 Edges (stepw) = 0...0 Edges (user def.) = 0...0 > # note that the vertices must be numbered consecutively from 1. In the > # following, vertex 2 is added as an isolated vertex. > m1 <- as(matrix(c(1,3,1,4),,2,byrow=TRUE),"gRapHD") > ## Not run: plot(m1) > > > > > cleanEx() > nameEx("jTree") > ### * jTree > > flush(stderr()); flush(stdout()) > > ### Name: jTree > ### Title: Junction tree > ### Aliases: jTree > ### Keywords: graphs > > ### ** Examples > > edges <- matrix(c(1,2,2,3,2,4,2,5,2,6,3,4,4, + 5,5,6,7,8,7,9,8,9,8,10,9,10),ncol=2,byrow=TRUE) > m <- new("gRapHD",edges=edges) > jT <- jTree(m) > str(jT) List of 5 $ separators :List of 5 ..$ : int(0) ..$ : int 2 ..$ : int [1:2] 2 4 ..$ : int [1:2] 2 5 ..$ : int [1:2] 8 9 $ juncTree : int [1:4, 1:2] 1 2 3 5 2 3 4 6 $ sepSubSetOfSep:List of 5 ..$ : int [1:4] 2 3 4 5 ..$ : int [1:2] 3 4 ..$ : int(0) ..$ : int(0) ..$ : int(0) $ indSepOrig : int [1:6] 1 2 3 4 1 5 $ cliques :List of 6 ..$ : int [1:2] 1 2 ..$ : int [1:3] 2 3 4 ..$ : int [1:3] 2 4 5 ..$ : int [1:3] 2 5 6 ..$ : int [1:3] 7 8 9 ..$ : int [1:3] 8 9 10 > # List of 5 > # $ separators :List of 5 > # ..$ : int(0) > # ..$ : int 2 > # ..$ : int [1:2] 2 4 > # ..$ : int [1:2] 2 5 > # ..$ : int [1:2] 8 9 > # $ juncTree : int [1:4, 1:2] 1 2 3 5 2 3 4 6 > # $ sepSubSetOfSep:List of 5 > # ..$ : int [1:4] 2 3 4 5 > # ..$ : int [1:2] 3 4 > # ..$ : int(0) > # ..$ : int(0) > # ..$ : int(0) > # $ indSepOrig : int [1:6] 1 2 3 4 1 5 > # $ cliques :List of 6 > # ..$ : int [1:2] 1 2 > # ..$ : int [1:3] 2 3 4 > # ..$ : int [1:3] 2 4 5 > # ..$ : int [1:3] 2 5 6 > # ..$ : int [1:3] 7 8 9 > # ..$ : int [1:3] 8 9 10 > > > > cleanEx() > nameEx("minForest") > ### * minForest > > flush(stderr()); flush(stdout()) > > ### Name: minForest > ### Title: Minimum forest > ### Aliases: minForest > ### Keywords: graphs > > ### ** Examples > > set.seed(7,kind="Mersenne-Twister") > dataset <- matrix(rnorm(1000),nrow=100,ncol=10) > m <- minForest(dataset,stat="BIC") > > ####################################################################### > # Example with continuous variables > data(dsCont) > # m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. in this case, there is no use for homog > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > ####################################################################### > # Example with discrete variables > data(dsDiscr) > # m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. in this case, there is no use for homog > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > ####################################################################### > # Example with mixed variables > data(dsMixed) > m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. it is to be considered homogeneous > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsMixed,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > ####################################################################### > # Example using a user defined function > # The function userFun calculates the same edges weigths as the > # option stat="LR". It means that the final result, using either > # option, is the same. > userFun <- function(newEdge,numCat,dataset) + { + sigma <- var(dataset[,newEdge]) + v <- nrow(dataset)*log(prod(diag(sigma))/det(sigma)) + return(c(v,1)) + } > > data(dsCont) > m <- minForest(dsCont,stat="LR") > m1 <- minForest(dsCont,stat=userFun) > identical(m@edges,m1@edges) [1] TRUE > > ####################################################################### > # Example with mandatory edges (the so-called conditional Chow-Liu > # algorithm). The edges (1,2), (1,3) and (2,3) are specified as > # mandatory. The algorithm returns the optimal graph containing the > # mandatory edges such that only cycles with mandatory edges are > # allowed. > data(dsCont) > m1 <- minForest(dsCont,cond=list(1:3)) > ## Not run: plot(m1) > > > > cleanEx() > nameEx("modelDim") > ### * modelDim > > flush(stderr()); flush(stdout()) > > ### Name: modelDim > ### Title: Model's dimension > ### Aliases: modelDim > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m <- minForest(dsCont,stat="BIC") > modelDim(m) [1] 102 > # 102 > > m <- stepw(m,dsCont,stat="BIC") > modelDim(m) [1] 149 > # 149 > > > > cleanEx() > nameEx("modelFormula") > ### * modelFormula > > flush(stderr()); flush(stdout()) > > ### Name: modelFormula > ### Title: Model's formula > ### Aliases: modelFormula > ### Keywords: graphs > > ### ** Examples > > data(dsMixed) > m <- minForest(dsMixed,homog=TRUE,stat="LR") > modelFormula(m) $discrete $discrete$`1` [1] 1 3 $discrete$`2` [1] 3 4 $discrete$`3` [1] 3 5 $discrete$`4` [1] 5 2 $linear list() $quadratic $quadratic[[1]] [1] 5 8 $quadratic[[2]] [1] 5 9 $quadratic[[3]] [1] 4 11 $quadratic[[4]] [1] 5 14 $quadratic[[5]] [1] 2 15 $quadratic2 $quadratic2$`1` [1] 6 11 $quadratic2$`2` [1] 7 8 $quadratic2$`3` [1] 9 10 $quadratic2$`4` [1] 9 13 $quadratic2$`5` [1] 12 15 $quadratic2$`6` [1] 14 > # str(modelFormula(m)) > #List of 4 > # $ discrete :List of 4 > # ..$ : int [1:2] 1 3 > # ..$ : int [1:2] 3 4 > # ..$ : int [1:2] 3 5 > # ..$ : int [1:2] 5 2 > # $ linear : list() > # $ quadratic :List of 5 > # ..$ : num [1:2] 5 8 > # ..$ : num [1:2] 5 9 > # ..$ : num [1:2] 4 11 > # ..$ : num [1:2] 5 14 > # ..$ : num [1:2] 2 15 > # $ quadratic2:List of 6 > # ..$ : num [1:2] 6 11 > # ..$ : num [1:2] 7 8 > # ..$ : num [1:2] 9 10 > # ..$ : num [1:2] 9 13 > # ..$ : num [1:2] 12 15 > # ..$ : num 14 > > m <- minForest(dsMixed,homog=FALSE,stat="LR") > str(modelFormula(m)) List of 4 $ discrete :List of 4 ..$ 1: int [1:2] 1 3 ..$ 2: int [1:2] 3 4 ..$ 3: int [1:2] 3 5 ..$ 4: int [1:2] 5 2 $ linear :List of 10 ..$ : num [1:2] 2 6 ..$ : num [1:2] 5 7 ..$ : num [1:2] 5 8 ..$ : num [1:2] 5 9 ..$ : num [1:2] 5 10 ..$ : num [1:2] 2 11 ..$ : num [1:2] 3 12 ..$ : num [1:2] 2 13 ..$ : num [1:2] 5 14 ..$ : num [1:2] 2 15 $ quadratic : list() $ quadratic2: list() > #List of 4 > # $ discrete :List of 4 > # ..$ : int [1:2] 1 3 > # ..$ : int [1:2] 3 4 > # ..$ : int [1:2] 3 5 > # ..$ : int [1:2] 5 2 > # $ linear :List of 10 > # ..$ : num [1:2] 2 6 > # ..$ : num [1:2] 5 7 > # ..$ : num [1:2] 5 8 > # ..$ : num [1:2] 5 9 > # ..$ : num [1:2] 5 10 > # ..$ : num [1:2] 2 11 > # ..$ : num [1:2] 3 12 > # ..$ : num [1:2] 2 13 > # ..$ : num [1:2] 5 14 > # ..$ : num [1:2] 2 15 > # $ quadratic : list() > # $ quadratic2: list() > > > > cleanEx() > nameEx("neighbourhood") > ### * neighbourhood > > flush(stderr()); flush(stdout()) > > ### Name: neighbourhood > ### Title: Neighbourhood of a vertex > ### Aliases: neighbourhood > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > aux <- neighbourhood(model=m1,orig=27,rad=2) > plot(new("gRapHD",edges=aux$edges,p=m1@p),vert=aux$v[,1]) > > > > cleanEx() > nameEx("neighbours") > ### * neighbours > > flush(stderr()); flush(stdout()) > > ### Name: neighbours > ### Title: Finds all direct neighbours > ### Aliases: neighbours > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > neigh <- neighbours(edges=m1@edges, v=22) > # > neigh > # [1] 3 9 24 25 > > > > cleanEx() > nameEx("perfSets") > ### * perfSets > > flush(stderr()); flush(stdout()) > > ### Name: perfSets > ### Title: Finds a perfect sequence > ### Aliases: perfSets > ### Keywords: graphs > > ### ** Examples > > edges <- matrix(c(1,2,2,3,2,4,2,5,2,6,3,4,4,5,5,6),ncol=2,byrow=TRUE) > setList <- perfSets(edges=edges, p=6, varType=0, from=1) > # > str(setList) > # List of 4 > # $ cliques :List of 4 > # ..$ : int [1:2] 1 2 > # ..$ : int [1:3] 2 3 4 > # ..$ : int [1:3] 2 4 5 > # ..$ : int [1:3] 2 5 6 > # $ histories :List of 4 > # ..$ : int [1:2] 1 2 > # ..$ : int [1:4] 1 2 3 4 > # ..$ : int [1:5] 1 2 3 4 5 > # ..$ : int [1:6] 1 2 3 4 5 6 > # $ separators:List of 4 > # ..$ : NULL > # ..$ : int 2 > # ..$ : int [1:2] 2 4 > # ..$ : int [1:2] 2 5 > # $ residuals :List of 4 > # ..$ : int [1:2] 1 2 > # ..$ : int [1:2] 3 4 > # ..$ : int 5 > # ..$ : int 6 > > > > cleanEx() > nameEx("plot.gRapHD") > ### * plot.gRapHD > > flush(stderr()); flush(stdout()) > > ### Name: plot.gRapHD > ### Title: Plots a gRapHD object > ### Aliases: plot.gRapHD > ### Keywords: graphs dplot > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > # or > plot(m1,numIter=1000,plotVert=FALSE,labelVert=FALSE) > > ############# > r <- 3 > edges <- rep(1,r) > x <- 2+r-1 > edges <- c(edges,sort(rep(2:x,r-1))) > edges <- c(edges,sort(rep((x+1):(x+(x-1)*(r-1)),r-2))) > edges <- c(edges,sort(rep((x+(x-1)*(r-1)+1):(x+(x-1)*(r-1)+ + (x-1)*(r-1)*(r-2)),r-3))) > edges <- cbind(edges,2:(length(edges)+1)) > a <- neighbourhood(edges=edges,orig=1,rad=r) > vs <- a$v[,2] > vs <- 1/vs > vs[1] <- 2 > vs <- vs/30 > model <- new("gRapHD",edges=edges) > plot(model,numIter=200,col.hl=colours()[386:383][a$v[,2]+1], + vert.hl=a$v[,1],vert.radii=vs,border="black",lwd.vert=2) > > > > cleanEx() > nameEx("randTree") > ### * randTree > > flush(stderr()); flush(stdout()) > > ### Name: randTree > ### Title: Random tree > ### Aliases: randTree > ### Keywords: graphs > > ### ** Examples > > tree <- randTree(p=10, seed=1) > plot(new("gRapHD",edges=tree$edges)) > tree $edges [,1] [,2] [1,] 3 4 [2,] 3 5 [3,] 2 3 [4,] 4 6 [5,] 6 9 [6,] 1 6 [7,] 6 10 [8,] 6 7 [9,] 5 8 $seed [1] 1 $p [1] 10 > # $edges > # [,1] [,2] > # [1,] 3 4 > # [2,] 3 5 > # [3,] 2 3 > # [4,] 4 6 > # [5,] 6 9 > # [6,] 1 6 > # [7,] 6 10 > # [8,] 6 7 > # [9,] 5 8 > # > # $seed > # [1] 1 > # > # $p > # [1] 10 > > > > cleanEx() > nameEx("rowProds") > ### * rowProds > > flush(stderr()); flush(stdout()) > > ### Name: rowProds > ### Title: Row products > ### Aliases: rowProds > ### Keywords: array > > ### ** Examples > > set.seed(1,kind="Mersenne-Twister") > a <- matrix(rnorm(100),nrow=5) > x <- rowProds(x=a, na.rm=TRUE) > # x > # [1] -3.359208e-07 -2.861043e-10 -2.831108e-08 > # [4] -5.451996e-07 3.057436e-04 > > > > cleanEx() > nameEx("shortPath") > ### * shortPath > > flush(stderr()); flush(stdout()) > > ### Name: shortPath > ### Title: Shortest path > ### Aliases: shortPath > ### Keywords: graphs > > ### ** Examples > > data(dsCont) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > shortPath(edges=m1@edges,v=1) 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 0 5 6 5 8 5 7 8 8 5 1 5 5 7 7 7 4 6 3 9 2 7 4 8 8 6 27 28 29 30 31 32 33 34 3 5 9 9 7 4 9 9 > > > > cleanEx() > nameEx("sortMat") > ### * sortMat > > flush(stderr()); flush(stdout()) > > ### Name: sortMat > ### Title: Sort matrix > ### Aliases: sortMat > ### Keywords: array > > ### ** Examples > > set.seed(1,kind="Mersenne-Twister") > a <- matrix(c(sample(2,6,TRUE),sample(3,6,TRUE),sample(2,6,TRUE)), + nrow=6) > x <- sortMat(mat=a, cols=c(1:3)) > a [,1] [,2] [,3] [1,] 1 3 2 [2,] 1 2 1 [3,] 2 2 2 [4,] 2 1 1 [5,] 1 1 2 [6,] 2 1 2 > # [,1] [,2] [,3] > # [1,] 1 3 2 > # [2,] 1 2 1 > # [3,] 2 2 2 > # [4,] 2 1 1 > # [5,] 1 1 2 > # [6,] 2 1 2 > x [,1] [,2] [,3] [1,] 1 1 2 [2,] 1 2 1 [3,] 1 3 2 [4,] 2 1 1 [5,] 2 1 2 [6,] 2 2 2 > # [,1] [,2] [,3] > # [1,] 1 1 2 > # [2,] 1 2 1 > # [3,] 1 3 2 > # [4,] 2 1 1 > # [5,] 2 1 2 > # [6,] 2 2 2 > > > > cleanEx() > nameEx("stepb") > ### * stepb > > flush(stderr()); flush(stdout()) > > ### Name: stepb > ### Title: Stepwise backward selection > ### Aliases: stepb > ### Keywords: ~kwd1 ~kwd2 > > ### ** Examples > > data(attitude) > am <- NULL > for (i in 1:6) for (j in (i+1):7) am <- rbind(am, c(i,j)) > satG <- new("gRapHD", edges=am, p=7, homog=TRUE, numCat=rep(0,7), vertNames=names(attitude)) > G <- stepb(satG, attitude) > > > > cleanEx() > nameEx("stepw") > ### * stepw > > flush(stderr()); flush(stdout()) > > ### Name: stepw > ### Title: Stepwise forward selection > ### Aliases: stepw > ### Keywords: graphs > > ### ** Examples > > set.seed(7,kind="Mersenne-Twister") > dataset <- matrix(rnorm(1000),nrow=100,ncol=10) > m <- minForest(dataset,stat="BIC") > > M <- stepw(m,dataset,stat="LR",NULL,NULL) > > ####################################################################### > # Example with continuous variables > data(dsCont) > # m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. in this case, there is no use for homog > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsCont,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > # m2 <- stepw(m1,dataset,stat="BIC",saveCH=NULL,forbEdges=NULL) > # 1. m1 is the result of minForest > # 2. the same dataset (this is not checked) > # 3. the default is BIC > # 4. if saveCH="XXX", a file "XXX_00000i.RData" > # is saved for each iter > # 5. no forbidden edges > m2 <- stepw(m1,dsCont,stat="BIC",saveCH=NULL,forbEdges=NULL) > plot(m2,numIter=1000) > > ####################################################################### > # Example with discrete variables > data(dsDiscr) > # m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. in this case, there is no use for homog > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > # m2 <- stepw(m1,dataset,stat="BIC",saveCH=NULL,forbEdges=NULL) > # 1. m1 is the result of minForest > # 2. the same dataset (this is not checked) > # 3. the default is BIC > # 4. if saveCH="XXX", a file "XXX_00000i.RData" > # is saved for each iter > # 5. no forbidden edges > m2 <- stepw(m1,dsDiscr,stat="BIC",saveCH=NULL,forbEdges=NULL) > plot(m2,numIter=1000) > > ####################################################################### > # Example with mixed variables > data(dsMixed) > # m1 <- minForest(dataset,homog=TRUE,forbEdges=NULL,stat="LR") > # 1. it is to be considered homogeneous > # 2. no forbidden edges > # 3. the measure used is the LR (the result is a tree) > m1 <- minForest(dsMixed,homog=TRUE,forbEdges=NULL,stat="LR") > plot(m1,numIter=1000) > > # m2 <- stepw(m1,dataset,stat="BIC",saveCH=NULL,forbEdges=NULL) > # 1. m1 is the result of minForest > # 2. the same dataset (this is not checked) > # 3. the default is BIC > # 4. if saveCH="XXX", a file "XXX_00000i.RData" > # is saved for each iter > # 5. no forbidden edges > m2 <- stepw(m1,dsMixed,stat="BIC",saveCH=NULL,forbEdges=NULL) > plot(m2,numIter=1000) > > ####################################################################### > # Example using a user defined function > # The function userFun calculates the same edges weigths as the > # option stat="BIC". It means that the final result, using either > # option, is the same. > userFun <- function(model,dataset,previous=NULL,forbEdges=NULL) + { + p <- ncol(dataset) # number of variables (vertices) + n <- nrow(dataset) # number of observations + edges.to.test <- previous$edges.to.test + SS <- previous$S # minimal separators + rm(previous) + + num <- nrow(edges.to.test) + + if (num > 0) + for (i in 1:num) + { + x <- edges.to.test[i,1] + y <- edges.to.test[i,2] + if ((edges.to.test[i,4]==0) & + (!is.element((x-1)*p-(x-1)*x/2+y-x,forbEdges))) + { + S <- SS[[edges.to.test[i,3]]] + clique <- c(edges.to.test[i,1:2],S) + CM <- cov(dataset[,clique],use="pairwise.complete.obs")* + (nrow(dataset)-1) + a <- match(edges.to.test[i,1:2],clique) + d <- log(det(CM)) + + log(det(matrix(CM[-a,-a],length(clique)-2))) + d <- d - (log(det(matrix(CM[-a[1],-a[1]],length(clique)-1))) + + log(det(matrix(CM[-a[2],-a[2]],length(clique)-1)))) + edges.to.test[i,4] <- nrow(dataset)*d + log(n) + edges.to.test[i,5] <- 1 + } + } + return(list(edges.to.test=edges.to.test,S=SS)) + } > > data(dsCont) > m <- minForest(dsCont,stat="BIC") > m1 <- stepw(m,dsCont,stat="BIC") > m2 <- stepw(m,dsCont,stat=userFun) > identical(m1@edges,m2@edges) [1] TRUE > > ####################################################################### > # Example of joining disjoint components > data(dsCont) > m <- minForest(dsCont,stat="BIC") > m1 <- stepw(m,dsCont) > m2 <- m > m2@edges <- matrix(integer(0),,2) > m3 <- stepw(m2,dsCont,join=TRUE) > identical(sortMat(m1@edges),sortMat(m3@edges)) [1] TRUE > # TRUE > > > > ### *