R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("sna-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('sna') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "add.isolates" > > ### * add.isolates > > flush(stderr()); flush(stdout()) > > ### Name: add.isolates > ### Title: Add Isolates to a Graph > ### Aliases: add.isolates > ### Keywords: manip math > > ### ** Examples > > > g<-rgraph(10,5) #Produce some random graphs > > dim(g) #Get the dimensions of g [1] 5 10 10 > > g<-add.isolates(g,2) #Add 2 isolates to each graph in g > > dim(g) #Now examine g [1] 5 12 12 > g , , 1 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 1 0 0 1 0 0 0 0 1 0 0 [2,] 0 1 1 0 0 1 1 1 0 0 0 0 [3,] 0 1 0 1 1 0 0 1 1 0 0 0 [4,] 0 1 1 1 1 0 1 0 1 1 0 0 [5,] 0 1 0 0 0 0 1 0 1 0 0 0 , , 2 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 0 0 1 0 1 0 0 1 0 0 0 [2,] 0 0 1 1 1 1 0 1 1 0 0 0 [3,] 0 0 0 0 0 1 0 0 0 1 0 0 [4,] 1 0 0 0 1 1 1 1 0 0 0 0 [5,] 0 0 0 0 0 1 1 1 0 0 0 0 , , 3 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 1 0 1 1 1 1 1 0 1 0 0 [2,] 0 1 0 1 0 1 0 1 1 0 0 0 [3,] 1 1 0 0 0 0 1 1 1 0 0 0 [4,] 0 1 0 0 0 0 0 0 1 0 0 0 [5,] 1 0 0 1 1 1 1 0 0 0 0 0 , , 4 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 0 1 0 0 0 0 1 0 1 0 0 [2,] 0 1 1 0 0 0 0 0 0 0 0 0 [3,] 1 1 1 0 1 0 0 0 1 1 0 0 [4,] 0 1 1 0 1 1 1 1 0 0 0 0 [5,] 0 1 1 0 1 0 0 1 1 0 0 0 , , 5 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 0 0 0 0 0 1 1 0 0 0 0 [2,] 0 0 1 1 0 1 1 0 1 0 0 0 [3,] 1 0 0 1 0 1 1 1 1 0 0 0 [4,] 0 1 0 1 0 1 1 1 1 0 0 0 [5,] 1 1 0 0 0 1 1 0 1 1 0 0 , , 6 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 0 1 1 1 0 1 0 0 1 0 0 [2,] 0 0 1 1 0 0 0 1 1 1 0 0 [3,] 0 0 1 0 1 0 1 1 1 0 0 0 [4,] 1 1 0 1 0 0 0 1 0 1 0 0 [5,] 0 1 1 1 1 0 0 0 0 1 0 0 , , 7 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 1 1 1 0 1 0 0 1 0 0 0 [2,] 1 0 1 0 0 1 0 1 0 1 0 0 [3,] 0 1 1 0 0 1 0 0 0 1 0 0 [4,] 1 1 0 1 0 0 0 0 0 1 0 0 [5,] 1 1 1 1 1 0 0 1 1 0 0 0 , , 8 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 0 1 1 1 0 0 0 0 0 0 0 [2,] 0 0 0 1 1 0 0 0 0 0 0 0 [3,] 1 1 1 1 1 1 1 0 1 0 0 0 [4,] 1 0 0 1 1 1 1 0 1 1 0 0 [5,] 1 0 0 1 1 1 0 0 1 0 0 0 , , 9 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 0 1 1 0 1 0 1 0 1 0 0 [2,] 1 1 0 0 0 1 0 0 0 0 0 0 [3,] 1 0 0 1 1 1 1 1 0 1 0 0 [4,] 1 0 0 0 1 1 0 0 0 0 0 0 [5,] 0 1 0 0 0 0 1 1 0 1 0 0 , , 10 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 1 1 0 0 0 0 1 1 0 0 0 0 [2,] 0 1 1 0 1 0 1 0 1 0 0 0 [3,] 1 1 0 1 0 0 1 1 1 0 0 0 [4,] 1 1 0 0 1 1 0 1 1 0 0 0 [5,] 1 0 1 1 1 1 1 0 0 0 0 0 , , 11 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 0 0 0 0 0 0 , , 12 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 0 0 0 0 0 0 > > > > > cleanEx(); ..nameEx <- "addisolates-deprecated" > > ### * addisolates-deprecated > > flush(stderr()); flush(stdout()) > > ### Name: addisolates-deprecated > ### Title: Add Isolates to a Graph (Deprecated) > ### Aliases: addisolates-deprecated > ### Keywords: manip math > > ### ** Examples > > > g<-rgraph(10,5) #Produce some random graphs > > dim(g) #Get the dimensions of g [1] 5 10 10 > > ## Not run: g<-addisolates(g,2) #Add 2 isolates to each graph in g > > dim(g) #Now examine g [1] 5 10 10 > g , , 1 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 1 0 0 1 0 0 0 0 1 [2,] 0 1 1 0 0 1 1 1 0 0 [3,] 0 1 0 1 1 0 0 1 1 0 [4,] 0 1 1 1 1 0 1 0 1 1 [5,] 0 1 0 0 0 0 1 0 1 0 , , 2 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 0 1 0 1 0 0 1 0 [2,] 0 0 1 1 1 1 0 1 1 0 [3,] 0 0 0 0 0 1 0 0 0 1 [4,] 1 0 0 0 1 1 1 1 0 0 [5,] 0 0 0 0 0 1 1 1 0 0 , , 3 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 1 0 1 1 1 1 1 0 1 [2,] 0 1 0 1 0 1 0 1 1 0 [3,] 1 1 0 0 0 0 1 1 1 0 [4,] 0 1 0 0 0 0 0 0 1 0 [5,] 1 0 0 1 1 1 1 0 0 0 , , 4 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 1 0 0 0 0 1 0 1 [2,] 0 1 1 0 0 0 0 0 0 0 [3,] 1 1 1 0 1 0 0 0 1 1 [4,] 0 1 1 0 1 1 1 1 0 0 [5,] 0 1 1 0 1 0 0 1 1 0 , , 5 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 0 0 0 0 0 1 1 0 0 [2,] 0 0 1 1 0 1 1 0 1 0 [3,] 1 0 0 1 0 1 1 1 1 0 [4,] 0 1 0 1 0 1 1 1 1 0 [5,] 1 1 0 0 0 1 1 0 1 1 , , 6 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 1 1 1 0 1 0 0 1 [2,] 0 0 1 1 0 0 0 1 1 1 [3,] 0 0 1 0 1 0 1 1 1 0 [4,] 1 1 0 1 0 0 0 1 0 1 [5,] 0 1 1 1 1 0 0 0 0 1 , , 7 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 1 1 1 0 1 0 0 1 0 [2,] 1 0 1 0 0 1 0 1 0 1 [3,] 0 1 1 0 0 1 0 0 0 1 [4,] 1 1 0 1 0 0 0 0 0 1 [5,] 1 1 1 1 1 0 0 1 1 0 , , 8 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 1 1 1 0 0 0 0 0 [2,] 0 0 0 1 1 0 0 0 0 0 [3,] 1 1 1 1 1 1 1 0 1 0 [4,] 1 0 0 1 1 1 1 0 1 1 [5,] 1 0 0 1 1 1 0 0 1 0 , , 9 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 1 1 0 1 0 1 0 1 [2,] 1 1 0 0 0 1 0 0 0 0 [3,] 1 0 0 1 1 1 1 1 0 1 [4,] 1 0 0 0 1 1 0 0 0 0 [5,] 0 1 0 0 0 0 1 1 0 1 , , 10 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 1 0 0 0 0 1 1 0 0 [2,] 0 1 1 0 1 0 1 0 1 0 [3,] 1 1 0 1 0 0 1 1 1 0 [4,] 1 1 0 0 1 1 0 1 1 0 [5,] 1 0 1 1 1 1 1 0 0 0 > > > > > cleanEx(); ..nameEx <- "bbnam" > > ### * bbnam > > flush(stderr()); flush(stdout()) > > ### Name: bbnam > ### Title: Butts' (Hierarchical) Bayesian Network Accuracy Model > ### Aliases: bbnam bbnam.actor bbnam.pooled bbnam.fixed > ### Keywords: models math > > ### ** Examples > > #Create some random data > g<-rgraph(5) > g.p<-0.8*g+0.2*(1-g) > dat<-rgraph(5,5,tprob=g.p) > > #Define a network prior > pnet<-matrix(ncol=5,nrow=5) > pnet[,]<-0.5 > #Define em and ep priors > pem<-matrix(nrow=5,ncol=2) > pem[,1]<-3 > pem[,2]<-5 > pep<-matrix(nrow=5,ncol=2) > pep[,1]<-3 > pep[,2]<-5 > > #Draw from the posterior > b<-bbnam(dat,model="actor",nprior=pnet,emprior=pem,epprior=pep, + burntime=100,draws=100) > #Print a summary of the posterior draws > summary(b) Butts' Hierarchical Bayes Model for Network Estimation/Informant Accuracy Multiple Error Probability Model Marginal Posterior Network Distribution: a1 a2 a3 a4 a5 a1 0.00 0.30 1.00 0.73 0.06 a2 0.99 0.00 0.99 0.02 0.64 a3 0.22 0.02 0.00 0.12 0.02 a4 0.06 0.01 1.00 0.00 0.97 a5 0.96 0.98 0.00 0.05 0.00 Marginal Posterior Global Error Distribution: e^- e^+ Min 0.02881 0.03609 1stQ 0.17761 0.19583 Median 0.26459 0.25546 Mean 0.27315 0.26619 3rdQ 0.35626 0.33756 Max 0.62607 0.66906 Marginal Posterior Error Distribution (by observer): Probability of False Negatives (e^-): Min 1stQ Median Mean 3rdQ Max o1 0.05669 0.20792 0.29164 0.30249 0.39543 0.62607 o2 0.05062 0.21561 0.30188 0.30139 0.38070 0.60775 o3 0.02881 0.12604 0.18597 0.19450 0.25752 0.52331 o4 0.04547 0.21913 0.32678 0.31832 0.40276 0.56781 o5 0.03211 0.16477 0.24457 0.24905 0.32250 0.50185 Probability of False Positives (e^+): Min 1stQ Median Mean 3rdQ Max o1 0.05423 0.15766 0.23034 0.22609 0.27779 0.45086 o2 0.04308 0.19715 0.26425 0.26527 0.33766 0.50089 o3 0.06532 0.26559 0.33011 0.33211 0.39099 0.66906 o4 0.04962 0.20321 0.25180 0.26506 0.32537 0.58310 o5 0.03609 0.17601 0.23423 0.24241 0.30491 0.53176 MCMC Diagnostics: Replicate Chains: 5 Burn Time: 100 Draws per Chain: 20 Total Draws: 100 Potential Scale Reduction (G&R's sqrt(Rhat)): Max: 1.017622 Med: 0.9990407 IQR: 0.003879972 > > > > cleanEx(); ..nameEx <- "bbnam.bf" > > ### * bbnam.bf > > flush(stderr()); flush(stdout()) > > ### Name: bbnam.bf > ### Title: Estimate Bayes Factors for the bbnam > ### Aliases: bbnam.bf > ### Keywords: models math > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "betweenness" > > ### * betweenness > > flush(stderr()); flush(stdout()) > > ### Name: betweenness > ### Title: Compute the Betweenness Centrality Scores of Network Positions > ### Aliases: betweenness > ### Keywords: univar graphs > > ### ** Examples > > g<-rgraph(10) #Draw a random graph with 10 members > betweenness(g) #Compute betweenness scores [1] 4.176190 6.811905 8.185714 3.128571 2.285714 4.152381 9.340476 4.830952 [9] 2.202381 3.885714 > > > > cleanEx(); ..nameEx <- "blockmodel" > > ### * blockmodel > > flush(stderr()); flush(stdout()) > > ### Name: blockmodel > ### Title: Generate Blockmodels Based on Partitions of Network Positions > ### Aliases: blockmodel > ### Keywords: classif math > > ### ** Examples > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Cluster based on structural equivalence > eq<-equiv.clust(g) > > #Form a blockmodel with distance relaxation of 10 > b<-blockmodel(g,eq,h=10) > plot(b) #Plot it [1] 1 Warning in if (labels[[1]] == labels[[2]]) text(1:o, 1:n, labels[[1]]) : the condition has length > 1 and only the first element will be used Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > > > > cleanEx(); ..nameEx <- "blockmodel.expand" > > ### * blockmodel.expand > > flush(stderr()); flush(stdout()) > > ### Name: blockmodel.expand > ### Title: Generate a Graph (or Stack) from a Given Blockmodel Using > ### Particular Expansion Rules > ### Aliases: blockmodel.expand > ### Keywords: manip math > > ### ** Examples > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Cluster based on structural equivalence > eq<-equiv.clust(g) > > #Form a blockmodel with distance relaxation of 15 > b<-blockmodel(g,eq,h=15) > > #Draw from an expanded density blockmodel > g.e<-blockmodel.expand(b,rep(2,length(b$rlabels))) #Two of each class > g.e [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0 0 0 0 1 1 0 1 0 0 0 1 [2,] 0 0 0 1 1 1 0 1 1 1 1 1 [3,] 0 0 0 1 1 1 1 0 1 1 0 0 [4,] 0 1 1 0 1 1 0 0 1 0 0 0 [5,] 0 0 1 0 0 1 0 0 1 0 1 1 [6,] 0 0 0 0 1 0 0 0 1 0 1 0 [7,] 0 0 1 1 1 1 0 1 0 0 1 1 [8,] 0 0 1 0 1 1 0 0 1 0 0 1 [9,] 0 0 1 0 1 1 0 0 0 0 1 1 [10,] 0 0 1 1 1 1 0 0 1 0 0 0 [11,] 0 0 1 0 1 1 0 1 0 0 0 1 [12,] 0 0 1 0 1 1 0 0 0 0 1 0 > > > > cleanEx(); ..nameEx <- "bonpow" > > ### * bonpow > > flush(stderr()); flush(stdout()) > > ### Name: bonpow > ### Title: Find Bonacich Power Centrality Scores of Network Positions > ### Aliases: bonpow > ### Keywords: univar math > > ### ** Examples > > #Generate some test data > dat<-rgraph(10,mode="graph") > #Compute Bonpow scores > bonpow(dat,exponent=1,tol=1e-20) [1] 1.491588e-15 -7.071068e-01 -1.414214e+00 -1.414214e+00 -1.668223e-16 [6] -1.414214e+00 -7.071068e-01 -7.071068e-01 -7.071068e-01 -1.414214e+00 > bonpow(dat,exponent=-1,tol=1e-20) [1] 0.7975790 0.5583053 0.4785474 0.1595158 0.6380632 1.5951581 0.3987895 [8] 1.8344318 1.0368527 1.1166106 > > > > cleanEx(); ..nameEx <- "centralgraph" > > ### * centralgraph > > flush(stderr()); flush(stdout()) > > ### Name: centralgraph > ### Title: Find the Central Graph of a Labeled Graph Set > ### Aliases: centralgraph > ### Keywords: math > > ### ** Examples > > #Generate some random graphs > dat<-rgraph(10,5) > #Find the central graph > cg<-centralgraph(dat) > #Plot the central graph > gplot(cg) > #Now, look at the mean matrix > cg<-centralgraph(dat,normalize=TRUE) > print(cg) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.0 0.4 0.4 0.4 0.4 0.4 0.6 0.8 0.8 0.8 [2,] 1.0 0.0 0.8 0.8 0.4 0.4 0.8 0.2 0.4 0.8 [3,] 0.4 0.2 0.0 1.0 0.2 0.8 0.8 0.4 0.2 0.4 [4,] 0.4 0.4 0.6 0.0 0.6 0.8 0.6 1.0 0.4 0.4 [5,] 0.6 0.4 0.4 0.6 0.0 0.6 0.2 1.0 0.4 0.6 [6,] 0.2 1.0 0.6 0.2 0.8 0.0 0.6 0.6 0.8 0.4 [7,] 0.6 0.4 0.6 0.2 1.0 0.4 0.0 0.4 0.4 0.8 [8,] 0.4 0.6 0.6 0.6 0.6 0.6 0.4 0.0 0.6 0.6 [9,] 0.6 0.4 0.6 0.4 0.8 0.4 0.4 0.6 0.0 0.6 [10,] 0.4 0.2 0.2 0.4 0.2 0.8 0.6 0.2 0.6 0.0 > > > > cleanEx(); ..nameEx <- "centralization" > > ### * centralization > > flush(stderr()); flush(stdout()) > > ### Name: centralization > ### Title: Find the Centralization of a Given Network, for Some Measure of > ### Centrality > ### Aliases: centralization > ### Keywords: univar math > > ### ** Examples > > #Generate some random graphs > dat<-rgraph(5,10) > #How centralized is the third one on indegree? > centralization(dat,g=3,degree,cmode="indegree") [1] 0.1875 > #How about on total (Freeman) degree? > centralization(dat,g=3,degree) [1] 0.25 > > > > cleanEx(); ..nameEx <- "closeness" > > ### * closeness > > flush(stderr()); flush(stdout()) > > ### Name: closeness > ### Title: Compute the Closeness Centrality Scores of Network Positions > ### Aliases: closeness > ### Keywords: univar math graphs > > ### ** Examples > > g<-rgraph(10) #Draw a random graph with 10 members > closeness(g) #Compute closeness scores [1] 0.7500000 0.6428571 0.6428571 0.7500000 0.6428571 0.6428571 0.6428571 [8] 0.6923077 0.5000000 0.6428571 > > > > > cleanEx(); ..nameEx <- "component.dist" > > ### * component.dist > > flush(stderr()); flush(stdout()) > > ### Name: component.dist > ### Title: Calculate the Component Size Distribution of a Graph > ### Aliases: component.dist > ### Keywords: math > > ### ** Examples > > g<-rgraph(20,tprob=0.075) #Generate a sparse random graph > > #Find weak components > cd<-component.dist(g,connected="weak") > cd$membership #Who's in what component? [1] 1 1 2 1 3 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 > cd$csize #What are the component sizes? [1] 17 1 1 1 > #Plot the size distribution > plot(1:length(cd$cdist),cd$cdist/sum(cd$cdist),ylim=c(0,1),type="h") > > #Find strong components > cd<-component.dist(g,connected="strong") > cd$membership #Who's in what component? [1] 1 2 3 4 5 6 1 7 8 9 10 11 4 12 13 14 15 1 16 4 > cd$csize #What are the component sizes? [1] 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 > #Plot the size distribution > plot(1:length(cd$cdist),cd$cdist/sum(cd$cdist),ylim=c(0,1),type="h") > > > > > cleanEx(); ..nameEx <- "components" > > ### * components > > flush(stderr()); flush(stdout()) > > ### Name: components > ### Title: Find the Number of (Maximal) Components Within a Given Graph > ### Aliases: components > ### Keywords: math > > ### ** Examples > > g<-rgraph(20,tprob=0.05) #Generate a sparse random graph > > #Find weak components > components(g,connected="weak") [1] 8 > > #Find strong components > components(g,connected="strong") [1] 18 > > > > > cleanEx(); ..nameEx <- "connectedness" > > ### * connectedness > > flush(stderr()); flush(stdout()) > > ### Name: connectedness > ### Title: Compute Graph Connectedness Scores > ### Aliases: connectedness > ### Keywords: math univar > > ### ** Examples > > #Get connectedness scores for graphs of varying densities > connectedness(rgraph(10,5,tprob=c(0.1,0.25,0.5,0.75,0.9))) [1] 0.2 1.0 1.0 1.0 1.0 > > > > cleanEx(); ..nameEx <- "consensus" > > ### * consensus > > flush(stderr()); flush(stdout()) > > ### Name: consensus > ### Title: Estimate a Consensus Structure from Multiple Observations > ### Aliases: consensus > ### Keywords: graphs > > ### ** Examples > > > #Generate some test data > g<-rgraph(5) > g.pobs<-g*0.9+(1-g)*0.5 > g.obs<-rgraph(5,5,tprob=g.pobs) > > #Find some consensus structures > consensus(g.obs) #Central graph [,1] [,2] [,3] [,4] [,5] [1,] 0 0 1 1 0 [2,] 1 0 1 0 1 [3,] 0 0 0 1 1 [4,] 1 0 1 0 1 [5,] 1 1 1 1 0 > consensus(g.obs,method="single.reweight") #Single reweighting [,1] [,2] [,3] [,4] [,5] [1,] 0.0000000 0.3881612 1.000000 0.8047952 0.3720781 [2,] 1.0000000 0.0000000 1.000000 0.3744605 0.7487870 [3,] 0.1815041 0.1791217 0.000000 0.5558306 0.5696653 [4,] 0.5558306 0.3606258 1.000000 0.0000000 1.0000000 [5,] 0.8047952 1.0000000 0.748787 0.6255395 0.0000000 > consensus(g.obs,method="PCA.reweight") #1st component in network PCA [,1] [,2] [,3] [,4] [,5] [1,] 0.0000000 0.8437443 2.196155 1.7821531 0.8241579 [2,] 2.1961545 0.0000000 2.196155 0.7873254 1.5957417 [3,] 0.3575825 0.3944150 0.000000 1.1659988 1.2013267 [4,] 1.1659988 0.7519975 2.196155 0.0000000 2.1961545 [5,] 1.7821531 2.1961545 1.595742 1.4088291 0.0000000 > > > > cleanEx(); ..nameEx <- "cugtest" > > ### * cugtest > > flush(stderr()); flush(stdout()) > > ### Name: cugtest > ### Title: Perform Conditional Uniform Graph (CUG) Hypothesis Tests for > ### Graph-Level Indices > ### Aliases: cugtest > ### Keywords: htest math > > ### ** Examples > > #Draw two random graphs, with different tie probabilities > dat<-rgraph(20,2,tprob=c(0.2,0.8)) > #Is their correlation higher than would be expected, conditioning > #only on size? > cug<-cugtest(dat,gcor,cmode="order") > summary(cug) CUG Test Results Estimated p-values: p(f(rnd) >= f(d)): 0.909 p(f(rnd) <= f(d)): 0.091 Test Diagnostics: Test Value (f(d)): -0.067113 Replications: 1000 Distribution Summary: Min: -0.2111882 1stQ: -0.03216774 Med: -0.0002495911 Mean: 0.0003475518 3rdQ: 0.03425948 Max: 0.1535455 > #Now, let's try conditioning on density as well. > cug<-cugtest(dat,gcor) > summary(cug) CUG Test Results Estimated p-values: p(f(rnd) >= f(d)): 0.908 p(f(rnd) <= f(d)): 0.092 Test Diagnostics: Test Value (f(d)): -0.067113 Replications: 1000 Distribution Summary: Min: -0.1737708 1stQ: -0.03258813 Med: 0.002957236 Mean: 0.001730916 3rdQ: 0.03695283 Max: 0.1698312 > > > > cleanEx(); ..nameEx <- "degree" > > ### * degree > > flush(stderr()); flush(stdout()) > > ### Name: degree > ### Title: Compute the Degree Centrality Scores of Network Positions > ### Aliases: degree > ### Keywords: univar math > > ### ** Examples > > #Create a random directed graph > dat<-rgraph(10) > #Find the indegrees, outdegrees, and total degrees > degree(dat,cmode="indegree") [1] 3 4 7 4 2 6 5 4 6 4 > degree(dat,cmode="outdegree") [1] 6 4 5 6 4 4 4 5 2 5 > degree(dat) [1] 9 8 12 10 6 10 9 9 8 9 > > > > cleanEx(); ..nameEx <- "diag.remove" > > ### * diag.remove > > flush(stderr()); flush(stdout()) > > ### Name: diag.remove > ### Title: Remove the Diagonals of Adjacency Matrices in a Graph Stack > ### Aliases: diag.remove > ### Keywords: manip math > > ### ** Examples > > #Generate a random graph stack > g<-rgraph(3,5) > #Remove the diagonals > g<-diag.remove(g) > > > > cleanEx(); ..nameEx <- "dyad.census" > > ### * dyad.census > > flush(stderr()); flush(stdout()) > > ### Name: dyad.census > ### Title: Compute a Holland and Leinhardt MAN Dyad Census > ### Aliases: dyad.census > ### Keywords: math > > ### ** Examples > > #Generate a dyad census of random data with varying densities > dyad.census(rgraph(15,5,tprob=c(0.1,0.25,0.5,0.75,0.9))) Mut Asym Null [1,] 1 17 87 [2,] 5 43 57 [3,] 25 54 26 [4,] 58 42 5 [5,] 85 18 2 > > > > cleanEx(); ..nameEx <- "efficiency" > > ### * efficiency > > flush(stderr()); flush(stdout()) > > ### Name: efficiency > ### Title: Compute Graph Efficiency Scores > ### Aliases: efficiency > ### Keywords: math univar > > ### ** Examples > > #Get efficiency scores for graphs of varying densities > efficiency(rgraph(10,5,tprob=c(0.1,0.25,0.5,0.75,0.9))) [1] 0.9230769 0.8641975 0.4444444 0.3086420 0.1728395 > > > > cleanEx(); ..nameEx <- "equiv.clust" > > ### * equiv.clust > > flush(stderr()); flush(stdout()) > > ### Name: equiv.clust > ### Title: Find Clusters of Positions Based on an Equivalence Relation > ### Aliases: equiv.clust > ### Keywords: cluster math > > ### ** Examples > > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Cluster based on structural equivalence > eq<-equiv.clust(g) > plot(eq) > > > > cleanEx(); ..nameEx <- "eval.edgeperturbation" > > ### * eval.edgeperturbation > > flush(stderr()); flush(stdout()) > > ### Name: eval.edgeperturbation > ### Title: Compute the Effects of Single-Edge Perturbations on Structural > ### Indices > ### Aliases: eval.edgeperturbation > ### Keywords: math > > ### ** Examples > > > #Create a random graph > g<-rgraph(5) > > #How much does a one-edge change affect reciprocity? > eval.edgeperturbation(g,1,2,grecip) [1] 0.1 > > > > cleanEx(); ..nameEx <- "evcent" > > ### * evcent > > flush(stderr()); flush(stdout()) > > ### Name: evcent > ### Title: Find Eigenvector Centrality Scores of Network Positions > ### Aliases: evcent > ### Keywords: univar math > > ### ** Examples > > > #Generate some test data > dat<-rgraph(10,mode="graph") > #Compute eigenvector centrality scores > evcent(dat) [1] 0.2250864 0.2666158 0.4567687 0.3241882 0.3000511 0.3380391 0.3161876 [8] 0.2581972 0.2289406 0.3757143 > > > > cleanEx(); ..nameEx <- "event2dichot" > > ### * event2dichot > > flush(stderr()); flush(stdout()) > > ### Name: event2dichot > ### Title: Convert an Observed Event Matrix to a Dichotomous matrix > ### Aliases: event2dichot > ### Keywords: manip math > > ### ** Examples > > #Draw a matrix of normal values > n<-matrix(rnorm(25),nrow=5,ncol=5) > > #Dichotomize by the mean value > event2dichot(n,"mean") [,1] [,2] [,3] [,4] [,5] [1,] 0 0 1 0 1 [2,] 1 1 1 0 1 [3,] 0 1 0 1 0 [4,] 1 1 0 1 0 [5,] 1 0 1 1 1 > > #Dichotomize by the 0.95 quantile > event2dichot(n,"quantile",0.95) [,1] [,2] [,3] [,4] [,5] [1,] 0 0 1 0 0 [2,] 0 0 0 0 0 [3,] 0 0 0 0 0 [4,] 1 0 0 0 0 [5,] 0 0 0 0 0 > > > > > cleanEx(); ..nameEx <- "gapply" > > ### * gapply > > flush(stderr()); flush(stdout()) > > ### Name: gapply > ### Title: Apply Functions Over Vertex Neighborhoods > ### Aliases: gapply > ### Keywords: iteration manip > > ### ** Examples > > #Generate a random graph > g<-rgraph(6) > > #Calculate the degree of g using gapply > all(gapply(g,1,rep(1,6),sum)==degree(g,cmode="outdegree")) [1] TRUE > all(gapply(g,2,rep(1,6),sum)==degree(g,cmode="degree")) [1] TRUE > all(gapply(g,c(1,2),rep(1,6),sum)==degree(symmetrize(g),cmode="freeman")/2) [1] TRUE > > #Find first and second order neighborhood means on some variable > gapply(g,c(1,2),1:6,mean) [1] 4.25 3.80 4.25 3.40 3.20 3.00 > gapply(g,c(1,2),1:6,mean,distance=2) [1] 4.0 3.8 3.6 3.4 3.2 3.0 > > > > > cleanEx(); ..nameEx <- "gclust.boxstats" > > ### * gclust.boxstats > > flush(stderr()); flush(stdout()) > > ### Name: gclust.boxstats > ### Title: Plot Statistics Associated with Graph Clusters > ### Aliases: gclust.boxstats > ### Keywords: hplot > > ### ** Examples > > #Create some random graphs > g<-rgraph(10,20,tprob=c(rbeta(10,15,2),rbeta(10,2,15))) > > #Find the Hamming distances between them > g.h<-hdist(g) > > #Cluster the graphs via their Hamming distances > g.c<-hclust(as.dist(g.h)) > > #Now display boxplots of density by cluster for a two cluster solution > gclust.boxstats(g.c,2,gden(g)) > > > > cleanEx(); ..nameEx <- "gclust.centralgraph" > > ### * gclust.centralgraph > > flush(stderr()); flush(stdout()) > > ### Name: gclust.centralgraph > ### Title: Get Central Graphs Associated with Graph Clusters > ### Aliases: gclust.centralgraph > ### Keywords: cluster math > > ### ** Examples > > #Create some random graphs > g<-rgraph(10,20,tprob=c(rbeta(10,15,2),rbeta(10,2,15))) > > #Find the Hamming distances between them > g.h<-hdist(g) > > #Cluster the graphs via their Hamming distances > g.c<-hclust(as.dist(g.h)) > > #Now find central graphs by cluster for a two cluster solution > g.cg<-gclust.centralgraph(g.c,2,g) > > #Plot the central graphs > gplot(g.cg[1,,]) > gplot(g.cg[2,,]) > > > > cleanEx(); ..nameEx <- "gcor" > > ### * gcor > > flush(stderr()); flush(stdout()) > > ### Name: gcor > ### Title: Find the (Product-Moment) Correlation Between Two or More > ### Labeled Graphs > ### Aliases: gcor > ### Keywords: univar multivariate > > ### ** Examples > > #Generate two random graphs each of low, medium, and high density > g<-rgraph(10,6,tprob=c(0.2,0.2,0.5,0.5,0.8,0.8)) > > #Examine the correlation matrix > gcor(g) 1 2 3 4 5 6 1 1.00000000 0.27477840 0.04635520 0.13557397 -0.05577787 -0.01517330 2 0.27477840 1.00000000 0.10429920 -0.03628036 0.01027487 0.05310656 3 0.04635520 0.10429920 1.00000000 0.01830783 -0.09499507 0.16366342 4 0.13557397 -0.03628036 0.01830783 1.00000000 -0.02782647 0.01797794 5 -0.05577787 0.01027487 -0.09499507 -0.02782647 1.00000000 -0.05527900 6 -0.01517330 0.05310656 0.16366342 0.01797794 -0.05527900 1.00000000 > > > > cleanEx(); ..nameEx <- "gcov" > > ### * gcov > > flush(stderr()); flush(stdout()) > > ### Name: gcov > ### Title: Find the Covariance(s) Between Two or More Labeled Graphs > ### Aliases: gcov > ### Keywords: univar multivariate > > ### ** Examples > > #Generate two random graphs each of low, medium, and high density > g<-rgraph(10,6,tprob=c(0.2,0.2,0.5,0.5,0.8,0.8)) > > #Examine the covariance matrix > gcov(g) 1 2 3 4 5 6 1 0.154931336 0.042571785 0.008988764 0.026591760 -0.009488140 -0.002496879 2 0.042571785 0.154931336 0.020224719 -0.007116105 0.001747815 0.008739076 3 0.008988764 0.020224719 0.242696629 0.004494382 -0.020224719 0.033707865 4 0.026591760 -0.007116105 0.004494382 0.248314607 -0.005992509 0.003745318 5 -0.009488140 0.001747815 -0.020224719 -0.005992509 0.186766542 -0.009987516 6 -0.002496879 0.008739076 0.033707865 0.003745318 -0.009987516 0.174781523 > > > > cleanEx(); ..nameEx <- "gden" > > ### * gden > > flush(stderr()); flush(stdout()) > > ### Name: gden > ### Title: Find the Density of a Graph > ### Aliases: gden > ### Keywords: univar math graphs > > ### ** Examples > > #Draw three random graphs > dat<-rgraph(10,3) > #Find their densities > gden(dat) [1] 0.5000000 0.4777778 0.6000000 > > > > cleanEx(); ..nameEx <- "gdist.plotdiff" > > ### * gdist.plotdiff > > flush(stderr()); flush(stdout()) > > ### Name: gdist.plotdiff > ### Title: Plot Differences in Graph-level Statistics Against Inter-graph > ### Distances > ### Aliases: gdist.plotdiff > ### Keywords: hplot > > ### ** Examples > > #Generate some random graphs with varying densities > g<-rgraph(10,20,tprob=runif(20,0,1)) > > #Find the Hamming distances between graphs > g.h<-hdist(g) > > #Plot the relationship between distance and differences in density > gdist.plotdiff(g.h,gden(g),lm.line=TRUE) > > > > cleanEx(); ..nameEx <- "gdist.plotstats" > > ### * gdist.plotstats > > flush(stderr()); flush(stdout()) > > ### Name: gdist.plotstats > ### Title: Plot Various Graph Statistics Over a Network MDS > ### Aliases: gdist.plotstats > ### Keywords: hplot > > ### ** Examples > > #Generate random graphs with varying density > g<-rgraph(10,20,tprob=runif(20,0,1)) > > #Get Hamming distances between graphs > g.h<-hdist(g) > > #Plot the association of distance, density, and reciprocity > gdist.plotstats(g.h,cbind(gden(g),grecip(g))) > > > > cleanEx(); ..nameEx <- "geodist" > > ### * geodist > > flush(stderr()); flush(stdout()) > > ### Name: geodist > ### Title: Fund the Numbers and Lengths of Geodesics Among Nodes in a Graph > ### Aliases: geodist > ### Keywords: graphs math > > ### ** Examples > > #Find geodesics on a random graph > gd<-geodist(rgraph(15)) > > #Examine the number of geodesics > gd$counts [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [1,] 1 1 1 4 4 3 1 1 5 2 3 1 1 [2,] 1 1 3 1 1 5 1 1 1 4 4 1 1 [3,] 3 4 1 1 1 1 2 1 1 4 1 1 2 [4,] 4 1 1 1 1 4 1 5 1 3 1 4 1 [5,] 1 2 1 1 1 6 2 1 1 1 7 1 2 [6,] 3 5 1 1 1 1 1 4 1 3 1 2 1 [7,] 3 1 7 1 1 1 1 2 1 1 7 2 1 [8,] 2 5 1 1 6 1 1 1 1 1 1 3 1 [9,] 6 1 3 1 1 1 3 1 1 1 1 1 3 [10,] 1 1 1 1 6 5 4 1 5 1 1 1 4 [11,] 1 1 4 1 1 1 3 1 4 1 1 4 4 [12,] 1 1 3 1 6 3 1 5 1 1 4 1 1 [13,] 4 1 1 6 1 1 1 1 1 4 1 3 1 [14,] 1 2 3 3 1 1 2 1 2 1 3 3 2 [15,] 2 1 1 1 1 1 2 2 4 15 3 2 1 [,14] [,15] [1,] 3 3 [2,] 1 1 [3,] 3 3 [4,] 1 2 [5,] 9 1 [6,] 1 1 [7,] 1 1 [8,] 5 3 [9,] 1 5 [10,] 1 1 [11,] 4 1 [12,] 6 1 [13,] 1 1 [14,] 1 2 [15,] 4 1 > > #Examine the geodesic distances > gd$gdist [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [1,] 0 1 1 2 2 2 1 1 2 2 2 1 1 [2,] 1 0 2 1 1 2 1 1 1 2 2 1 1 [3,] 2 2 0 1 1 1 2 1 1 2 1 1 2 [4,] 2 1 1 0 1 2 2 2 1 2 1 2 2 [5,] 1 2 2 2 0 3 2 2 2 2 3 1 2 [6,] 2 2 2 1 1 0 2 2 1 2 1 2 1 [7,] 2 1 3 2 1 2 0 2 2 2 3 2 2 [8,] 2 2 1 1 2 1 1 0 1 1 1 2 2 [9,] 2 1 2 1 1 1 2 1 0 1 1 1 2 [10,] 1 1 1 1 2 2 2 1 2 0 1 1 2 [11,] 1 1 2 1 1 1 2 1 2 1 0 2 2 [12,] 1 1 2 1 2 2 1 2 1 1 2 0 1 [13,] 2 1 2 2 1 1 1 1 1 2 1 2 0 [14,] 1 2 2 2 1 1 2 1 2 1 2 2 2 [15,] 2 1 2 1 1 1 2 2 2 3 2 2 1 [,14] [,15] [1,] 2 2 [2,] 1 1 [3,] 2 2 [4,] 1 2 [5,] 3 2 [6,] 1 1 [7,] 1 2 [8,] 2 2 [9,] 1 2 [10,] 1 1 [11,] 2 1 [12,] 2 1 [13,] 1 1 [14,] 0 2 [15,] 2 0 > > > > cleanEx(); ..nameEx <- "gliop" > > ### * gliop > > flush(stderr()); flush(stdout()) > > ### Name: gliop > ### Title: Return a Binary Operation on GLI Values Computed on Two Graphs > ### Aliases: gliop > ### Keywords: utilities math > > ### ** Examples > > #Draw two random graphs > g<-rgraph(10,2,tprob=c(0.2,0.5)) > > #What is their difference in density? > gliop(g,gden,"-",1,2) [1] -0.2888889 > > > > cleanEx(); ..nameEx <- "gplot" > > ### * gplot > > flush(stderr()); flush(stdout()) > > ### Name: gplot > ### Title: Two-Dimensional Visualization of Graphs > ### Aliases: gplot > ### Keywords: graphs hplot > > ### ** Examples > > gplot(rgraph(5)) #Plot a random graph > gplot(rgraph(5),usecurv=TRUE) #This time, use curved edges > gplot(rgraph(5),mode="mds") #Try an alternative layout scheme > > #A colorful demonstration... > gplot(rgraph(5,diag=TRUE),diag=TRUE,vertex.cex=1:5,vertex.sides=3:8, + vertex.col=1:5,vertex.border=2:6,vertex.rot=(0:4)*72, + displaylabels=TRUE,label.bg="gray90") > > > > > cleanEx(); ..nameEx <- "gplot.arrow" > > ### * gplot.arrow > > flush(stderr()); flush(stdout()) > > ### Name: gplot.arrow > ### Title: Add Arrows or Segments to a Plot > ### Aliases: gplot.arrow > ### Keywords: aplot graphs > > ### ** Examples > > #Plot two points > plot(1:2,1:2) > > #Add an edge > gplot.arrow(1,1,2,2,width=0.01,col="red",border="black") > > > > cleanEx(); ..nameEx <- "gplot.loop" > > ### * gplot.loop > > flush(stderr()); flush(stdout()) > > ### Name: gplot.loop > ### Title: Add Loops to a Plot > ### Aliases: gplot.loop > ### Keywords: aplot graphs > > ### ** Examples > > #Plot a few polygons with loops > plot(0,0,type="n",xlim=c(-2,2),ylim=c(-2,2),asp=1) > gplot.loop(c(0,0),c(1,-1),col=c(3,2),width=0.05,length=0.4, + offset=sqrt(2)/4,angle=20,radius=0.5,edge.steps=50,arrowhead=TRUE) > polygon(c(0.25,-0.25,-0.25,0.25,NA,0.25,-0.25,-0.25,0.25), + c(1.25,1.25,0.75,0.75,NA,-1.25,-1.25,-0.75,-0.75),col=c(2,3)) > > > > > cleanEx(); ..nameEx <- "gplot.target" > > ### * gplot.target > > flush(stderr()); flush(stdout()) > > ### Name: gplot.target > ### Title: Display a Graph in Target Diagram Form > ### Aliases: gplot.target > ### Keywords: graphs hplot > > ### ** Examples > > > #Generate a random graph > g<-rgraph(15) > > #Produce a target diagram, centering by betweenness > gplot.target(g,betweenness(g)) > > > > cleanEx(); ..nameEx <- "gplot.vertex" > > ### * gplot.vertex > > flush(stderr()); flush(stdout()) > > ### Name: gplot.vertex > ### Title: Add Vertices to a Plot > ### Aliases: gplot.vertex > ### Keywords: aplot graphs > > ### ** Examples > > > #Open a plot window, and place some vertices > plot(0,0,type="n",xlim=c(-1.5,1.5),ylim=c(-1.5,1.5),asp=1) > gplot.vertex(cos((1:10)/10*2*pi),sin((1:10)/10*2*pi),col=1:10, + sides=3:12,radius=0.1) > > > > > cleanEx(); ..nameEx <- "gplot3d" > > ### * gplot3d > > flush(stderr()); flush(stdout()) > > ### Name: gplot3d > ### Title: Three-Dimensional Visualization of Graphs > ### Aliases: gplot3d > ### Keywords: hplot graphs > > ### ** Examples > > > ## Not run: > ##D #A three-dimensional grid... > ##D gplot3d(rgws(1,5,3,1,0)) > ##D > ##D #...rewired... > ##D gplot3d(rgws(1,5,3,1,0.05)) > ##D > ##D #...some more! > ##D gplot3d(rgws(1,5,3,1,0.2)) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "graphcent" > > ### * graphcent > > flush(stderr()); flush(stdout()) > > ### Name: graphcent > ### Title: Compute the (Harary) Graph Centrality Scores of Network > ### Positions > ### Aliases: graphcent > ### Keywords: univar math > > ### ** Examples > > g<-rgraph(10) #Draw a random graph with 10 members > graphcent(g) #Compute centrality scores [1] 0.5000000 0.5000000 0.3333333 0.5000000 0.5000000 0.5000000 0.5000000 [8] 0.5000000 0.3333333 0.3333333 > > > > cleanEx(); ..nameEx <- "grecip" > > ### * grecip > > flush(stderr()); flush(stdout()) > > ### Name: grecip > ### Title: Compute the Reciprocity of an Input Graph or Graph Stack > ### Aliases: grecip > ### Keywords: math univar > > ### ** Examples > > #Calculate the dyadic reciprocity scores for some random graphs > grecip(rgraph(10,5)) [1] 0.4000000 0.4000000 0.6444444 0.5777778 0.4888889 > > > > cleanEx(); ..nameEx <- "gscor" > > ### * gscor > > flush(stderr()); flush(stdout()) > > ### Name: gscor > ### Title: Find the Structural Correlations Between Two or More Graphs > ### Aliases: gscor > ### Keywords: univar multivariate > > ### ** Examples > > #Generate two random graphs > g.1<-rgraph(5) > g.2<-rgraph(5) > > #Copy one of the graphs and permute it > perm<-sample(1:5) > g.3<-g.2[perm,perm] > > #What are the structural correlations between the labeled graphs? > gscor(g.1,g.2,exchange.list=1:5) [1] -0.2121212 > gscor(g.1,g.3,exchange.list=1:5) [1] 0.1919192 > gscor(g.2,g.3,exchange.list=1:5) [1] -0.4141414 > > #What are the structural correlations between the underlying > #unlabeled graphs? > gscor(g.1,g.2) [1] 0.5959596 > gscor(g.1,g.3) [1] 0.5959596 > gscor(g.2,g.3) [1] 1 > > > > cleanEx(); ..nameEx <- "gscov" > > ### * gscov > > flush(stderr()); flush(stdout()) > > ### Name: gscov > ### Title: Find the Structural Covariance(s) Between Two or More Graphs > ### Aliases: gscov > ### Keywords: univar multivariate > > ### ** Examples > > #Generate two random graphs > g.1<-rgraph(5) > g.2<-rgraph(5) > > #Copy one of the graphs and permute it > perm<-sample(1:5) > g.3<-g.2[perm,perm] > > #What are the structural covariances between the labeled graphs? > gscov(g.1,g.2,exchange.list=1:5) [1] -0.05526316 > gscov(g.1,g.3,exchange.list=1:5) [1] 0.05 > gscov(g.2,g.3,exchange.list=1:5) [1] -0.1078947 > > #What are the structural covariances between the underlying > #unlabeled graphs? > gscov(g.1,g.2) [1] 0.1552632 > gscov(g.1,g.3) [1] 0.1552632 > gscov(g.2,g.3) [1] 0.2605263 > > > > cleanEx(); ..nameEx <- "gtrans" > > ### * gtrans > > flush(stderr()); flush(stdout()) > > ### Name: gtrans > ### Title: Compute the Transitivity of an Input Graph or Graph Stack > ### Aliases: gtrans > ### Keywords: algebra > > ### ** Examples > > #Draw some random graphs > g<-rgraph(5,10) > > #Find transitivity scores > gtrans(g) [1] 0.17391304 0.23809524 0.40909091 0.30000000 0.30000000 0.08000000 [7] 0.40000000 0.08695652 0.35000000 0.60000000 > > > > cleanEx(); ..nameEx <- "gvectorize" > > ### * gvectorize > > flush(stderr()); flush(stdout()) > > ### Name: gvectorize > ### Title: Vectorization of Adjacency Matrices > ### Aliases: gvectorize > ### Keywords: manip math > > ### ** Examples > > #Draw two random graphs > g<-rgraph(10,2) > > #Examine the vectorized form of the adjacency structure > gvectorize(g) [,1] [,2] [1,] NA NA [2,] 1 1 [3,] 0 1 [4,] 0 0 [5,] 1 0 [6,] 0 1 [7,] 0 1 [8,] 0 1 [9,] 0 0 [10,] 1 0 [11,] 1 0 [12,] NA NA [13,] 0 1 [14,] 1 1 [15,] 0 1 [16,] 1 1 [17,] 0 0 [18,] 0 1 [19,] 1 1 [20,] 0 0 [21,] 0 0 [22,] 1 1 [23,] NA NA [24,] 1 1 [25,] 1 0 [26,] 1 1 [27,] 1 0 [28,] 1 1 [29,] 0 1 [30,] 1 0 [31,] 1 0 [32,] 0 1 [33,] 1 1 [34,] NA NA [35,] 0 0 [36,] 0 0 [37,] 0 0 [38,] 1 0 [39,] 0 0 [40,] 1 0 [41,] 0 0 [42,] 0 0 [43,] 0 1 [44,] 0 1 [45,] NA NA [46,] 0 1 [47,] 1 1 [48,] 1 0 [49,] 0 1 [50,] 0 0 [51,] 1 0 [52,] 0 0 [53,] 1 1 [54,] 1 1 [55,] 1 0 [56,] NA NA [57,] 1 0 [58,] 0 1 [59,] 0 1 [60,] 1 1 [61,] 0 1 [62,] 1 0 [63,] 1 1 [64,] 1 0 [65,] 0 0 [66,] 1 1 [67,] NA NA [68,] 0 1 [69,] 1 0 [70,] 0 1 [71,] 1 0 [72,] 0 0 [73,] 1 0 [74,] 1 1 [75,] 1 1 [76,] 0 0 [77,] 0 0 [78,] NA NA [79,] 0 0 [80,] 0 0 [81,] 1 1 [82,] 0 1 [83,] 1 0 [84,] 1 0 [85,] 0 0 [86,] 1 1 [87,] 0 0 [88,] 1 0 [89,] NA NA [90,] 1 0 [91,] 1 0 [92,] 1 1 [93,] 0 1 [94,] 0 0 [95,] 0 1 [96,] 0 0 [97,] 1 1 [98,] 1 0 [99,] 0 1 [100,] NA NA > > > > cleanEx(); ..nameEx <- "hdist" > > ### * hdist > > flush(stderr()); flush(stdout()) > > ### Name: hdist > ### Title: Find the Hamming Distances Between Two or More Graphs > ### Aliases: hdist > ### Keywords: univar multivariate > > ### ** Examples > > #Get some random graphs > g<-rgraph(5,5,tprob=runif(5,0,1)) > > #Find the Hamming distances > hdist(g) 1 2 3 4 5 1 0 11 13 16 6 2 11 0 8 11 7 3 13 8 0 7 13 4 16 11 7 0 16 5 6 7 13 16 0 > > > > cleanEx(); ..nameEx <- "hierarchy" > > ### * hierarchy > > flush(stderr()); flush(stdout()) > > ### Name: hierarchy > ### Title: Compute Graph Hierarchy Scores > ### Aliases: hierarchy > ### Keywords: math univar > > ### ** Examples > > #Get hierarchy scores for graphs of varying densities > hierarchy(rgraph(10,5,tprob=c(0.1,0.25,0.5,0.75,0.9)), + measure="reciprocity") [1] 0.08888889 0.40000000 0.35555556 0.33333333 0.31111111 > hierarchy(rgraph(10,5,tprob=c(0.1,0.25,0.5,0.75,0.9)), + measure="krackhardt") [1] 0.9285714 0.2000000 0.0000000 0.0000000 0.0000000 > > > > cleanEx(); ..nameEx <- "infocent" > > ### * infocent > > flush(stderr()); flush(stdout()) > > ### Name: infocent > ### Title: Find Information Centrality Scores of Network Positions > ### Aliases: infocent > ### Keywords: math univar > > ### ** Examples > > #Generate some test data > dat<-rgraph(10,mode="graph") > #Compute information centrality scores > infocent(dat) [1] 1.814227 2.097484 2.529590 2.107270 2.080495 2.121655 2.100136 1.752836 [9] 1.795358 2.368819 > > > > cleanEx(); ..nameEx <- "interval.graph" > > ### * interval.graph > > flush(stderr()); flush(stdout()) > > ### Name: interval.graph > ### Title: Convert Spell Data to Interval Graphs > ### Aliases: interval.graph > ### Keywords: manip math > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "is.connected" > > ### * is.connected > > flush(stderr()); flush(stdout()) > > ### Name: is.connected > ### Title: Is a Given Graph Connected? > ### Aliases: is.connected > ### Keywords: graphs logic > > ### ** Examples > > #Generate two graphs: > g1<-rgraph(10,tp=0.1) > g2<-rgraph(10) > > #Check for connectedness > is.connected(g1) #Probably not [1] FALSE > is.connected(g2) #Probably so [1] TRUE > > > > cleanEx(); ..nameEx <- "is.isolate" > > ### * is.isolate > > flush(stderr()); flush(stdout()) > > ### Name: is.isolate > ### Title: Is Ego an Isolate? > ### Aliases: is.isolate > ### Keywords: logic graphs > > ### ** Examples > > #Generate a test graph > g<-rgraph(20) > g[,4]<-0 #Create an isolate > g[4,]<-0 > > #Check for isolates > is.isolate(g,2) #2 is almost surely not an isolate [1] FALSE > is.isolate(g,4) #4 is, by construction [1] TRUE > > > > cleanEx(); ..nameEx <- "isolates" > > ### * isolates > > flush(stderr()); flush(stdout()) > > ### Name: isolates > ### Title: List the Isolates in a Graph or Graph Stack > ### Aliases: isolates > ### Keywords: math graphs > > ### ** Examples > > #Generate a test graph > g<-rgraph(20) > g[,4]<-0 #Create an isolate > g[4,]<-0 > > #List the isolates > isolates(g) [1] 4 > > > > cleanEx(); ..nameEx <- "lab.optimize" > > ### * lab.optimize > > flush(stderr()); flush(stdout()) > > ### Name: lab.optimize > ### Title: Optimize a Bivariate Graph Statistic Across a Set of Accessible > ### Permutations > ### Aliases: lab.optimize lab.optimize.anneal lab.optimize.exhaustive > ### lab.optimize.gumbel lab.optimize.hillclimb lab.optimize.mc > ### Keywords: optimize math > > ### ** Examples > > #Generate a random graph and copy it > g<-rgraph(10) > g2<-rmperm(g) #Permute the copy randomly > > #Seek the maximum correlation > lab.optimize(g,g2,gcor,seek="max",opt.method="anneal",freeze.time=50, + prob.decay=0.9) [1] 0.3333333 > > #These two don't do so well... > lab.optimize(g,g2,gcor,seek="max",opt.method="hillclimb") [1] 0.2888889 > lab.optimize(g,g2,gcor,seek="max",opt.method="mc",draws=1000) [1] 0.5111111 > > > > > cleanEx(); ..nameEx <- "lnam" > > ### * lnam > > flush(stderr()); flush(stdout()) > > ### Name: lnam > ### Title: Fit a Linear Network Autocorrelation Model > ### Aliases: lnam coef.lnam se.lnam > ### Keywords: regression multivariate > > ### ** Examples > > #Construct a simple, random example: > w1<-rgraph(100) #Draw the AR matrix > w2<-rgraph(100) #Draw the MA matrix > x<-matrix(rnorm(100*5),100,5) #Draw some covariates > r1<-0.2 #Set the model parameters > r2<-0.1 > sigma<-0.1 > beta<-rnorm(5) > #Assemble y from its components: > nu<-rnorm(100,0,sigma) #Draw the disturbances > e<-qr.solve(diag(100)-r2*w2,nu) #Draw the effective errors > y<-qr.solve(diag(100)-r1*w1,x%*%beta+e) #Compute y > > #Now, fit the autocorrelation model: > fit<-lnam(y,x,w1,w2) > summary(fit) Call: lnam(y = y, x = x, W1 = w1, W2 = w2) Residuals: Min 1Q Median 3Q Max -0.31720 -0.10094 -0.00846 0.10372 0.34995 Coefficients: Estimate Std. Error Z value Pr(>|z|) rho1 0.2008304 0.0004395 456.975 <2e-16 *** rho2 0.0425938 0.0186438 2.285 0.0223 * X1 0.6740739 0.0108347 62.214 <2e-16 *** X2 -0.6389510 0.0087708 -72.850 <2e-16 *** X3 -0.3180747 0.0084390 -37.691 <2e-16 *** X4 0.3599613 0.0075179 47.881 <2e-16 *** X5 -0.9264493 0.0085651 -108.166 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Estimate Std. Error Sigma 0.08204 0.006 Goodness-of-Fit: Residual standard error: 0.1500 on 93 degrees of freedom (w/o Sigma) Multiple R-Squared: 0.9987, Adjusted R-Squared: 0.9987 Model log likelihood: 108.2 on 92 degrees of freedom (w/Sigma) AIC: -200.3 BIC: -179.5 Null model: meanstd Null log likelihood: -282.2 on 98 degrees of freedom AIC: 568.4 BIC: 573.7 AIC difference (model versus null): 768.8 Heuristic Log Bayes Factor (model versus null): 753.1 > plot(fit) > > > > cleanEx(); ..nameEx <- "lower.tri.remove" > > ### * lower.tri.remove > > flush(stderr()); flush(stdout()) > > ### Name: lower.tri.remove > ### Title: Remove the Lower Triangles of Adjacency Matrices in a Graph > ### Stack > ### Aliases: lower.tri.remove > ### Keywords: manip math > > ### ** Examples > > #Generate a random graph stack > g<-rgraph(3,5) > #Remove the lower triangles > g<-lower.tri.remove(g) > > > > > cleanEx(); ..nameEx <- "lubness" > > ### * lubness > > flush(stderr()); flush(stdout()) > > ### Name: lubness > ### Title: Compute Graph LUBness Scores > ### Aliases: lubness > ### Keywords: math univar > > ### ** Examples > > #Get LUBness scores for graphs of varying densities > lubness(rgraph(10,5,tprob=c(0.1,0.25,0.5,0.75,0.9))) [1] 1 1 1 1 1 > > > > > cleanEx(); ..nameEx <- "make.stochastic" > > ### * make.stochastic > > flush(stderr()); flush(stdout()) > > ### Name: make.stochastic > ### Title: Make a Graph Stack Row, Column, or Row-column Stochastic > ### Aliases: make.stochastic > ### Keywords: manip array algebra > > ### ** Examples > > #Generate a test matrix > g<-rgraph(15) > > #Make it row stochastic > make.stochastic(g,mode="row") [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 0.0000000 0.1666667 0.1666667 0.0000000 0.0000000 0.0000000 0.1666667 [2,] 0.1000000 0.0000000 0.0000000 0.1000000 0.1000000 0.0000000 0.1000000 [3,] 0.0000000 0.0000000 0.0000000 0.1428571 0.1428571 0.1428571 0.0000000 [4,] 0.0000000 0.1666667 0.1666667 0.0000000 0.1666667 0.0000000 0.0000000 [5,] 0.5000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 [6,] 0.0000000 0.0000000 0.0000000 0.1428571 0.1428571 0.0000000 0.0000000 [7,] 0.0000000 0.3333333 0.0000000 0.0000000 0.3333333 0.0000000 0.0000000 [8,] 0.0000000 0.0000000 0.1428571 0.1428571 0.0000000 0.1428571 0.1428571 [9,] 0.0000000 0.1111111 0.0000000 0.1111111 0.1111111 0.1111111 0.0000000 [10,] 0.1111111 0.1111111 0.1111111 0.1111111 0.0000000 0.0000000 0.0000000 [11,] 0.1250000 0.1250000 0.0000000 0.1250000 0.1250000 0.1250000 0.0000000 [12,] 0.1250000 0.1250000 0.0000000 0.1250000 0.0000000 0.0000000 0.1250000 [13,] 0.0000000 0.1111111 0.0000000 0.0000000 0.1111111 0.1111111 0.1111111 [14,] 0.2000000 0.0000000 0.0000000 0.0000000 0.2000000 0.2000000 0.0000000 [15,] 0.0000000 0.2000000 0.0000000 0.2000000 0.2000000 0.2000000 0.0000000 [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] 0.1666667 0.0000000 0.0000000 0.0000000 0.1666667 0.1666667 0.0000000 [2,] 0.1000000 0.1000000 0.0000000 0.0000000 0.1000000 0.1000000 0.1000000 [3,] 0.1428571 0.1428571 0.0000000 0.1428571 0.1428571 0.0000000 0.0000000 [4,] 0.0000000 0.1666667 0.0000000 0.1666667 0.0000000 0.0000000 0.1666667 [5,] 0.0000000 0.0000000 0.0000000 0.0000000 0.5000000 0.0000000 0.0000000 [6,] 0.0000000 0.1428571 0.0000000 0.1428571 0.0000000 0.1428571 0.1428571 [7,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.3333333 [8,] 0.0000000 0.1428571 0.1428571 0.1428571 0.0000000 0.0000000 0.0000000 [9,] 0.1111111 0.0000000 0.1111111 0.1111111 0.1111111 0.0000000 0.1111111 [10,] 0.1111111 0.0000000 0.0000000 0.1111111 0.1111111 0.0000000 0.1111111 [11,] 0.1250000 0.0000000 0.1250000 0.0000000 0.0000000 0.0000000 0.0000000 [12,] 0.0000000 0.1250000 0.1250000 0.0000000 0.0000000 0.1250000 0.0000000 [13,] 0.1111111 0.1111111 0.0000000 0.1111111 0.0000000 0.0000000 0.1111111 [14,] 0.2000000 0.0000000 0.2000000 0.0000000 0.0000000 0.0000000 0.0000000 [15,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.2000000 0.0000000 [,15] [1,] 0.0000000 [2,] 0.1000000 [3,] 0.0000000 [4,] 0.0000000 [5,] 0.0000000 [6,] 0.1428571 [7,] 0.0000000 [8,] 0.0000000 [9,] 0.0000000 [10,] 0.1111111 [11,] 0.1250000 [12,] 0.1250000 [13,] 0.1111111 [14,] 0.0000000 [15,] 0.0000000 > > #Make it column stochastic > make.stochastic(g,mode="col") [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 0.0000000 0.1111111 0.25 0.0000000 0.0 0.0000000 0.2 0.125 0.0000000 [2,] 0.1666667 0.0000000 0.00 0.1111111 0.1 0.0000000 0.2 0.125 0.1428571 [3,] 0.0000000 0.0000000 0.00 0.1111111 0.1 0.1428571 0.0 0.125 0.1428571 [4,] 0.0000000 0.1111111 0.25 0.0000000 0.1 0.0000000 0.0 0.000 0.1428571 [5,] 0.1666667 0.0000000 0.00 0.0000000 0.0 0.0000000 0.0 0.000 0.0000000 [6,] 0.0000000 0.0000000 0.00 0.1111111 0.1 0.0000000 0.0 0.000 0.1428571 [7,] 0.0000000 0.1111111 0.00 0.0000000 0.1 0.0000000 0.0 0.000 0.0000000 [8,] 0.0000000 0.0000000 0.25 0.1111111 0.0 0.1428571 0.2 0.000 0.1428571 [9,] 0.0000000 0.1111111 0.00 0.1111111 0.1 0.1428571 0.0 0.125 0.0000000 [10,] 0.1666667 0.1111111 0.25 0.1111111 0.0 0.0000000 0.0 0.125 0.0000000 [11,] 0.1666667 0.1111111 0.00 0.1111111 0.1 0.1428571 0.0 0.125 0.0000000 [12,] 0.1666667 0.1111111 0.00 0.1111111 0.0 0.0000000 0.2 0.000 0.1428571 [13,] 0.0000000 0.1111111 0.00 0.0000000 0.1 0.1428571 0.2 0.125 0.1428571 [14,] 0.1666667 0.0000000 0.00 0.0000000 0.1 0.1428571 0.0 0.125 0.0000000 [15,] 0.0000000 0.1111111 0.00 0.1111111 0.1 0.1428571 0.0 0.000 0.0000000 [,10] [,11] [,12] [,13] [,14] [,15] [1,] 0.0 0.0000000 0.1666667 0.2 0.0000000 0.0000000 [2,] 0.0 0.0000000 0.1666667 0.2 0.1428571 0.1666667 [3,] 0.0 0.1428571 0.1666667 0.0 0.0000000 0.0000000 [4,] 0.0 0.1428571 0.0000000 0.0 0.1428571 0.0000000 [5,] 0.0 0.0000000 0.1666667 0.0 0.0000000 0.0000000 [6,] 0.0 0.1428571 0.0000000 0.2 0.1428571 0.1666667 [7,] 0.0 0.0000000 0.0000000 0.0 0.1428571 0.0000000 [8,] 0.2 0.1428571 0.0000000 0.0 0.0000000 0.0000000 [9,] 0.2 0.1428571 0.1666667 0.0 0.1428571 0.0000000 [10,] 0.0 0.1428571 0.1666667 0.0 0.1428571 0.1666667 [11,] 0.2 0.0000000 0.0000000 0.0 0.0000000 0.1666667 [12,] 0.2 0.0000000 0.0000000 0.2 0.0000000 0.1666667 [13,] 0.0 0.1428571 0.0000000 0.0 0.1428571 0.1666667 [14,] 0.2 0.0000000 0.0000000 0.0 0.0000000 0.0000000 [15,] 0.0 0.0000000 0.0000000 0.2 0.0000000 0.0000000 > > #(Try to) make it row-column stochastic > make.stochastic(g,mode="rowcol") [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.00000000 0.00000000 0.3981064 0.00000000 0.00000000 0.00000000 [2,] 0.15376968 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 [3,] 0.00000000 0.00000000 0.0000000 0.15500835 0.08337845 0.05706642 [4,] 0.00000000 0.25615733 0.2525523 0.00000000 0.00000000 0.00000000 [5,] 0.49529031 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 [6,] 0.00000000 0.00000000 0.0000000 0.06000305 0.06327338 0.00000000 [7,] 0.00000000 0.37174906 0.0000000 0.00000000 0.24388461 0.00000000 [8,] 0.00000000 0.00000000 0.1618794 0.01841851 0.00000000 0.14614819 [9,] 0.00000000 0.12388332 0.0000000 0.06085820 0.00000000 0.11939319 [10,] 0.05501227 0.16838601 0.1834995 0.19684863 0.00000000 0.00000000 [11,] 0.05791778 0.08395689 0.0000000 0.10409782 0.00000000 0.20468578 [12,] 0.06765543 0.00000000 0.0000000 0.15419417 0.00000000 0.00000000 [13,] 0.00000000 0.00000000 0.0000000 0.00000000 0.34145022 0.07347133 [14,] 0.16832758 0.00000000 0.0000000 0.00000000 0.15799229 0.19362274 [15,] 0.00000000 0.00000000 0.0000000 0.25444956 0.11169654 0.19962500 [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0.2581438 0.006846464 0.00000000 0.0000000 0.00000000 0.09157136 [2,] 0.0901148 0.000000000 0.18802628 0.0000000 0.00000000 0.06324259 [3,] 0.0000000 0.235825655 0.17167109 0.0000000 0.10141220 0.19594445 [4,] 0.0000000 0.000000000 0.28275881 0.0000000 0.06281629 0.00000000 [5,] 0.0000000 0.000000000 0.00000000 0.0000000 0.00000000 0.49592797 [6,] 0.0000000 0.000000000 0.20485447 0.0000000 0.09837772 0.00000000 [7,] 0.0000000 0.000000000 0.00000000 0.0000000 0.00000000 0.00000000 [8,] 0.2117068 0.000000000 0.14704022 0.2029312 0.11728277 0.00000000 [9,] 0.0000000 0.175076168 0.00000000 0.1417103 0.23549920 0.15409849 [10,] 0.0000000 0.215982465 0.00000000 0.0000000 0.11965812 0.00000000 [11,] 0.0000000 0.144878721 0.00000000 0.1775648 0.00000000 0.00000000 [12,] 0.2759020 0.000000000 0.00000000 0.1703317 0.00000000 0.00000000 [13,] 0.1432938 0.069916234 0.01588763 0.0000000 0.25915135 0.00000000 [14,] 0.0000000 0.159697279 0.00000000 0.3050140 0.00000000 0.00000000 [15,] 0.0000000 0.000000000 0.00000000 0.0000000 0.00000000 0.00000000 [,13] [,14] [,15] [1,] 0.2415569 0.00000000 0.000000000 [2,] 0.0000000 0.24489486 0.256241479 [3,] 0.0000000 0.00000000 0.000000000 [4,] 0.0000000 0.14703714 0.000000000 [5,] 0.0000000 0.00000000 0.000000000 [6,] 0.1817609 0.13274336 0.260550132 [7,] 0.0000000 0.38383463 0.000000000 [8,] 0.0000000 0.00000000 0.000000000 [9,] 0.0000000 0.00000000 0.000000000 [10,] 0.0000000 0.00000000 0.062489392 [11,] 0.0000000 0.00000000 0.224952827 [12,] 0.1391208 0.00000000 0.190344635 [13,] 0.0000000 0.09743411 0.001271984 [14,] 0.0000000 0.00000000 0.000000000 [15,] 0.4319601 0.00000000 0.000000000 > > > > cleanEx(); ..nameEx <- "mutuality" > > ### * mutuality > > flush(stderr()); flush(stdout()) > > ### Name: mutuality > ### Title: Find the Mutuality of a Graph > ### Aliases: mutuality > ### Keywords: univar math > > ### ** Examples > > #Create some random graphs > g<-rgraph(15,3) > > #Get mutuality and reciprocity scores > mutuality(g) [1] 25 36 25 > grecip(g) #Compare with mutuality [1] 0.5142857 0.5428571 0.4857143 > > > > cleanEx(); ..nameEx <- "netcancor" > > ### * netcancor > > flush(stderr()); flush(stdout()) > > ### Name: netcancor > ### Title: Canonical Correlation for Labeled Graphs > ### Aliases: netcancor > ### Keywords: multivariate math > > ### ** Examples > > #Generate a valued seed structure > cv<-matrix(rnorm(100),nrow=10,ncol=10) > #Produce two sets of valued graphs > x<-array(dim=c(3,10,10)) > x[1,,]<-3*cv+matrix(rnorm(100,0,0.1),nrow=10,ncol=10) > x[2,,]<--1*cv+matrix(rnorm(100,0,0.1),nrow=10,ncol=10) > x[3,,]<-x[1,,]+2*x[2,,]+5*cv+matrix(rnorm(100,0,0.1),nrow=10,ncol=10) > y<-array(dim=c(2,10,10)) > y[1,,]<--5*cv+matrix(rnorm(100,0,0.1),nrow=10,ncol=10) > y[2,,]<--2*cv+matrix(rnorm(100,0,0.1),nrow=10,ncol=10) > #Perform a canonical correlation analysis > nc<-netcancor(y,x,reps=100) > summary(nc) Canonical Network Correlation Canonical Correlations: cor1 cor2 Correlation 0.999576748 0.067893134 Coef. of Det. 0.999153675 0.004609478 Pr(>=cor): cor1 cor2 0.00 0.71 Pr(<=cor): cor1 cor2 1.00 0.29 X Coefficients: x1 x2 x3 x1 0.008818831 0.286251432 1.363914753 x2 0.037772035 0.923822887 0.922504388 x3 -0.016777394 0.010539338 -0.528592210 Pr(>=xcoef): x1 x2 x3 x1 0.10 0.00 0.00 x2 0.29 0.00 0.00 x3 0.93 0.26 1.00 Pr(<=xcoef): x1 x2 x3 x1 0.90 1.00 1.00 x2 0.71 1.00 1.00 x3 0.07 0.74 0.00 Y Coefficients: y1 y2 y1 0.01699780 0.36928642 y2 0.01352134 -0.91415772 Pr(>=ycoef): y1 y2 y1 0.39 0.00 y2 0.36 1.00 Pr(<=ycoef): y1 y2 y1 0.61 1.00 y2 0.64 0.00 Test Diagnostics: Null Hypothesis: CUG Replications: 100 Distribution Summary for Correlations: cor1 cor2 Min 0.100822 0.005184 1stQ 0.186422 0.062195 Median 0.235517 0.094926 Mean 0.237451 0.099078 3rdQ 0.284465 0.134886 Max 0.492260 0.242147 > > > > cleanEx(); ..nameEx <- "netlm" > > ### * netlm > > flush(stderr()); flush(stdout()) > > ### Name: netlm > ### Title: Linear Regression for Network Data > ### Aliases: netlm > ### Keywords: regression math > > ### ** Examples > > #Create some input graphs > x<-rgraph(20,4) > > #Create a response structure > y<-x[1,,]+4*x[2,,]+2*x[3,,] #Note that the fourth graph is unrelated > > #Fit a netlm model > nl<-netlm(y,x,reps=100) > > #Examine the results > summary(nl) OLS Network Model Coefficients: Estimate Pr(>=b) Pr(<=b) (intercept) -9.788540e-16 1.00 0.00 x1 1.000000e+00 0.00 1.00 x2 4.000000e+00 0.00 1.00 x3 2.000000e+00 0.00 1.00 x4 2.213367e-18 0.59 0.41 Residual standard error: 1.613e-15 on 375 degrees of freedom F-statistic: 1.888e+32 on 4 and 375 degrees of freedom, p-value: 0 Multiple R^2: 1 Adjusted R^2: 1 Test Diagnostics: Null Hypothesis: CUG Replications: 100 Goodness of Fit Distribution Summary: Sigma R^2 Adj. R^2 Min 2.3178032 0.0008828 -0.0097745 1stQ 2.3432535 0.0053521 -0.0052575 Median 2.3497223 0.0098553 -0.0007062 Mean 2.3503077 0.0106769 0.0001241 3rdQ 2.3585144 0.0137991 0.0032796 Max 2.3796553 0.0386960 0.0284420 Coefficient Distribution Summary: (intercept) x1 x2 x3 x4 Min 2.82137 -0.53572 -0.72948 -0.59727 -0.52273 1stQ 3.16892 -0.20031 -0.16580 -0.08244 -0.12733 Median 3.35945 -0.04868 0.04132 0.06155 0.05810 Mean 3.33273 -0.03168 0.02475 0.04128 0.05408 3rdQ 3.50151 0.11663 0.18267 0.19786 0.20849 Max 3.84579 0.59307 0.58861 0.53366 0.61356 > > > > cleanEx(); ..nameEx <- "netlogit" > > ### * netlogit > > flush(stderr()); flush(stdout()) > > ### Name: netlogit > ### Title: Logistic Regression for Network Data > ### Aliases: netlogit > ### Keywords: regression math > > ### ** Examples > > #Create some input graphs > x<-rgraph(20,4) > > #Create a response structure > y.l<-x[1,,]+4*x[2,,]+2*x[3,,] #Note that the fourth graph is > #unrelated > y.p<-apply(y.l,c(1,2),function(a){1/(1+exp(-a))}) > y<-rgraph(20,tprob=y.p) > > #Fit a netlogit model > nl<-netlogit(y,x,reps=100) > > #Examine the results > summary(nl) Network Logit Model Coefficients: Estimate Exp(b) Pr(>=b) Pr(<=b) (intercept) -0.1081237 0.8975165 1.00 0.00 x1 0.9032784 2.4676798 0.00 1.00 x2 3.1223882 22.7005275 0.00 1.00 x3 2.1820205 8.8641980 0.00 1.00 x4 0.0845688 1.0882477 0.39 0.61 Goodness of Fit Statistics: Null deviance (-2*Ln(L)): 284.3934 on 379 degrees of freedom Residual deviance (-2*Ln(L)): 198.2238 on 375 degrees of freedom Chi-Squared test of fit improvement: 86.16957 on 4 degrees of freedom, p-value 0 AIC: 208.2238 BIC: 221.9845 Pseudo-R^2 Measures: (Dn-Dr)/(Dn-Dr+dfn): 0.1852434 (Dn-Dr)/Dn: 0.3029943 Contingency Table (predicted (rows) x actual (cols)): Actual Predicted 0 1 0 22 21 1 25 312 Total Fraction Correct: 0.8789474 Fraction 1s Correct: 0.925816 Fraction 0s Correct: 0.5116279 Test Diagnostics: Null Hypothesis: CUG Replications: 100 Distribution Summary: (intercept) x1 x2 x3 x4 Min 0.9127282 -0.5525957 -0.6314192 -0.6022768 -0.6222735 1stQ 1.4156471 -0.1032095 -0.1868928 -0.1825041 -0.1425322 Median 1.6213347 0.0344098 -0.0226908 -0.0258380 0.0004769 Mean 1.6056980 0.0389803 0.0105470 -0.0283305 0.0224179 3rdQ 1.7819019 0.1530118 0.1831515 0.1297740 0.1890994 Max 2.2821289 0.6430768 0.8198984 0.5829484 0.7064901 > > > > cleanEx(); ..nameEx <- "npostpred" > > ### * npostpred > > flush(stderr()); flush(stdout()) > > ### Name: npostpred > ### Title: Take Posterior Predictive Draws for Functions of Networks > ### Aliases: npostpred > ### Keywords: models math > > ### ** Examples > > #Create some random data > g<-rgraph(5) > g.p<-0.8*g+0.2*(1-g) > dat<-rgraph(5,5,tprob=g.p) > > #Define a network prior > pnet<-matrix(ncol=5,nrow=5) > pnet[,]<-0.5 > #Define em and ep priors > pem<-matrix(nrow=5,ncol=2) > pem[,1]<-3 > pem[,2]<-5 > pep<-matrix(nrow=5,ncol=2) > pep[,1]<-3 > pep[,2]<-5 > > #Draw from the posterior > b<-bbnam(dat,model="actor",nprior=pnet,emprior=pem,epprior=pep, + burntime=100,draws=100) > #Plot a summary of the posterior predictive of reciprocity > hist(npostpred(b,grecip)) > > > > cleanEx(); ..nameEx <- "nties" > > ### * nties > > flush(stderr()); flush(stdout()) > > ### Name: nties > ### Title: Find the Number of Possible Ties in a Given Graph or Stack > ### Aliases: nties > ### Keywords: univar math > > ### ** Examples > > #How many possible edges in a loopless digraph of order 15? > nties(rgraph(15),diag=FALSE) [1] 210 > > > > cleanEx(); ..nameEx <- "numperm" > > ### * numperm > > flush(stderr()); flush(stdout()) > > ### Name: numperm > ### Title: Get the nth Permutation Vector by Periodic Placement > ### Aliases: numperm > ### Keywords: array math > > ### ** Examples > > #Draw a graph > g<-rgraph(5) > > #Permute the rows and columns > p.1<-numperm(5,1) > p.2<-numperm(5,2) > p.3<-numperm(5,3) > g[p.1,p.1] [,1] [,2] [,3] [,4] [,5] [1,] 0 1 1 0 1 [2,] 0 0 1 1 0 [3,] 0 0 0 0 0 [4,] 0 0 1 0 1 [5,] 1 1 0 0 0 > g[p.2,p.2] [,1] [,2] [,3] [,4] [,5] [1,] 0 1 1 0 1 [2,] 0 0 0 0 0 [3,] 0 1 0 1 0 [4,] 0 1 0 0 1 [5,] 1 0 1 0 0 > g[p.3,p.3] [,1] [,2] [,3] [,4] [,5] [1,] 0 1 0 1 1 [2,] 0 0 0 0 0 [3,] 0 1 0 0 1 [4,] 0 1 1 0 0 [5,] 1 0 0 1 0 > > > > cleanEx(); ..nameEx <- "plot.bbnam" > > ### * plot.bbnam > > flush(stderr()); flush(stdout()) > > ### Name: plot.bbnam > ### Title: Plotting for bbnam Objects > ### Aliases: plot.bbnam plot.bbnam.fixed plot.bbnam.pooled plot.bbnam.actor > ### Keywords: hplot > > ### ** Examples > > #Create some random data > g<-rgraph(5) > g.p<-0.8*g+0.2*(1-g) > dat<-rgraph(5,5,tprob=g.p) > > #Define a network prior > pnet<-matrix(ncol=5,nrow=5) > pnet[,]<-0.5 > #Define em and ep priors > pem<-matrix(nrow=5,ncol=2) > pem[,1]<-3 > pem[,2]<-5 > pep<-matrix(nrow=5,ncol=2) > pep[,1]<-3 > pep[,2]<-5 > > #Draw from the posterior > b<-bbnam(dat,model="actor",nprior=pnet,emprior=pem,epprior=pep, + burntime=100,draws=100) > #Print a summary of the posterior draws > summary(b) Butts' Hierarchical Bayes Model for Network Estimation/Informant Accuracy Multiple Error Probability Model Marginal Posterior Network Distribution: a1 a2 a3 a4 a5 a1 0.00 0.30 1.00 0.73 0.06 a2 0.99 0.00 0.99 0.02 0.64 a3 0.22 0.02 0.00 0.12 0.02 a4 0.06 0.01 1.00 0.00 0.97 a5 0.96 0.98 0.00 0.05 0.00 Marginal Posterior Global Error Distribution: e^- e^+ Min 0.02881 0.03609 1stQ 0.17761 0.19583 Median 0.26459 0.25546 Mean 0.27315 0.26619 3rdQ 0.35626 0.33756 Max 0.62607 0.66906 Marginal Posterior Error Distribution (by observer): Probability of False Negatives (e^-): Min 1stQ Median Mean 3rdQ Max o1 0.05669 0.20792 0.29164 0.30249 0.39543 0.62607 o2 0.05062 0.21561 0.30188 0.30139 0.38070 0.60775 o3 0.02881 0.12604 0.18597 0.19450 0.25752 0.52331 o4 0.04547 0.21913 0.32678 0.31832 0.40276 0.56781 o5 0.03211 0.16477 0.24457 0.24905 0.32250 0.50185 Probability of False Positives (e^+): Min 1stQ Median Mean 3rdQ Max o1 0.05423 0.15766 0.23034 0.22609 0.27779 0.45086 o2 0.04308 0.19715 0.26425 0.26527 0.33766 0.50089 o3 0.06532 0.26559 0.33011 0.33211 0.39099 0.66906 o4 0.04962 0.20321 0.25180 0.26506 0.32537 0.58310 o5 0.03609 0.17601 0.23423 0.24241 0.30491 0.53176 MCMC Diagnostics: Replicate Chains: 5 Burn Time: 100 Draws per Chain: 20 Total Draws: 100 Potential Scale Reduction (G&R's sqrt(Rhat)): Max: 1.017622 Med: 0.9990407 IQR: 0.003879972 > #Plot the result > plot(b) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: cleanEx(); ..naWarning in if (labels[[1]] == labels[[2]]) text(1:o, 1:n, labels[[1]]) : the condition has length > 1 and only the first element will be used Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > meEx <- "plot.blockmodel" > > ### * plot.blockmodel > > flush(stderr()); flush(stdout()) > > ### Name: plot.blockmodel > ### Title: Plotting for blockmodel Objects > ### Aliases: plot.blockmodel > ### Keywords: hplot > > ### ** Examples > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Cluster based on structural equivalence > eq<-equiv.clust(g) > > #Form a blockmodel with distance relaxation of 10 > b<-blockmodel(g,eq,h=10) > plot(b) #Plot it [1] 1 Warning in if (labels[[1]] == labels[[2]]) text(1:o, 1:n, labels[[1]]) : the condition has length > 1 and only the first element will be used Warning in par(args) : parameter "cin" cannot be set Warning in par(args) : parameter "cra" cannot be set Warning in par(args) : parameter "csi" cannot be set Warning in par(args) : parameter "cxy" cannot be set Warning in par(args) : parameter "din" cannot be set Warning in par(args) : gamma cannot be modified on this device > > > > cleanEx(); ..nameEx <- "plot.cugtest" > > ### * plot.cugtest > > flush(stderr()); flush(stdout()) > > ### Name: plot.cugtest > ### Title: Plotting for cugtest Objects > ### Aliases: plot.cugtest > ### Keywords: hplot > > ### ** Examples > > #Draw two random graphs, with different tie probabilities > dat<-rgraph(20,2,tprob=c(0.2,0.8)) > > #Is their correlation higher than would be expected, conditioning > #only on size? > cug<-cugtest(dat,gcor,cmode="order") > summary(cug) CUG Test Results Estimated p-values: p(f(rnd) >= f(d)): 0.909 p(f(rnd) <= f(d)): 0.091 Test Diagnostics: Test Value (f(d)): -0.067113 Replications: 1000 Distribution Summary: Min: -0.2111882 1stQ: -0.03216774 Med: -0.0002495911 Mean: 0.0003475518 3rdQ: 0.03425948 Max: 0.1535455 > plot(cug) > > #Now, let's try conditioning on density as well. > cug<-cugtest(dat,gcor) > plot(cug) > > > > cleanEx(); ..nameEx <- "plot.equiv.clust" > > ### * plot.equiv.clust > > flush(stderr()); flush(stdout()) > > ### Name: plot.equiv.clust > ### Title: Plot an equiv.clust Object > ### Aliases: plot.equiv.clust > ### Keywords: hplot > > ### ** Examples > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Cluster based on structural equivalence > eq<-equiv.clust(g) > plot(eq) > > > > cleanEx(); ..nameEx <- "plot.qaptest" > > ### * plot.qaptest > > flush(stderr()); flush(stdout()) > > ### Name: plot.qaptest > ### Title: Plotting for qaptest Objects > ### Aliases: plot.qaptest > ### Keywords: hplot > > ### ** Examples > > > #Generate three graphs > g<-array(dim=c(3,10,10)) > g[1,,]<-rgraph(10) > g[2,,]<-rgraph(10,tprob=g[1,,]*0.8) > g[3,,]<-1; g[3,1,2]<-0 #This is nearly a clique > > #Perform qap tests of graph correlation > q.12<-qaptest(g,gcor,g1=1,g2=2) > q.13<-qaptest(g,gcor,g1=1,g2=3) > > #Examine the results > summary(q.12) QAP Test Results Estimated p-values: p(f(perm) >= f(d)): 0 p(f(perm) <= f(d)): 1 Test Diagnostics: Test Value (f(d)): 0.8355317 Replications: 1000 Distribution Summary: Min: -0.2935652 1stQ: -0.06774581 Med: -0.02258194 Mean: -0.001761391 3rdQ: 0.06774581 Max: 0.3838929 > plot(q.12) > summary(q.13) QAP Test Results Estimated p-values: p(f(perm) >= f(d)): 0.58 p(f(perm) <= f(d)): 0.482 Test Diagnostics: Test Value (f(d)): -0.1059998 Replications: 1000 Distribution Summary: Min: -0.1059998 1stQ: -0.1059998 Med: -0.1059998 Mean: -0.002119996 3rdQ: 0.1059998 Max: 0.1059998 > plot(q.13) > > > > cleanEx(); ..nameEx <- "plot.sociomatrix" > > ### * plot.sociomatrix > > flush(stderr()); flush(stdout()) > > ### Name: plot.sociomatrix > ### Title: Plot Matrices Using a Color/Intensity Grid > ### Aliases: plot.sociomatrix > ### Keywords: hplot > > ### ** Examples > > #Plot a small adjacency matrix > plot.sociomatrix(rgraph(5)) Warning in if (labels[[1]] == labels[[2]]) text(1:o, 1:n, labels[[1]]) : the condition has length > 1 and only the first element will be used > > #Plot a much larger one > plot.sociomatrix(rgraph(100),drawlab=FALSE,diaglab=FALSE) > > > > cleanEx(); ..nameEx <- "potscalered.mcmc" > > ### * potscalered.mcmc > > flush(stderr()); flush(stdout()) > > ### Name: potscalered.mcmc > ### Title: Compute Gelman and Rubin's Potential Scale Reduction Measure for > ### a Markov Chain Monte Carlo Simulation > ### Aliases: potscalered.mcmc > ### Keywords: models univar > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "prestige" > > ### * prestige > > flush(stderr()); flush(stdout()) > > ### Name: prestige > ### Title: Calculate the Vertex Prestige Scores > ### Aliases: prestige > ### Keywords: univar math > > ### ** Examples > > g<-rgraph(10) #Draw a random graph with 10 members > prestige(g,cmode="domain") #Compute domain prestige scores [1] 9 9 9 9 9 9 9 9 9 9 > > > > cleanEx(); ..nameEx <- "print.bayes.factor" > > ### * print.bayes.factor > > flush(stderr()); flush(stdout()) > > ### Name: print.bayes.factor > ### Title: Printing for Bayes Factor Objects > ### Aliases: print.bayes.factor > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.bbnam" > > ### * print.bbnam > > flush(stderr()); flush(stdout()) > > ### Name: print.bbnam > ### Title: Printing for bbnam Objects > ### Aliases: print.bbnam print.bbnam.fixed print.bbnam.pooled > ### print.bbnam.actor > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.blockmodel" > > ### * print.blockmodel > > flush(stderr()); flush(stdout()) > > ### Name: print.blockmodel > ### Title: Printing for blockmodel Objects > ### Aliases: print.blockmodel > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.cugtest" > > ### * print.cugtest > > flush(stderr()); flush(stdout()) > > ### Name: print.cugtest > ### Title: Printing for cugtest Objects > ### Aliases: print.cugtest > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.netcancor" > > ### * print.netcancor > > flush(stderr()); flush(stdout()) > > ### Name: print.netcancor > ### Title: Printing for netcancor Objects > ### Aliases: print.netcancor > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.netlm" > > ### * print.netlm > > flush(stderr()); flush(stdout()) > > ### Name: print.netlm > ### Title: Printing for netlm Objects > ### Aliases: print.netlm > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.netlogit" > > ### * print.netlogit > > flush(stderr()); flush(stdout()) > > ### Name: print.netlogit > ### Title: Printing for netlogit Objects > ### Aliases: print.netlogit > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.qaptest" > > ### * print.qaptest > > flush(stderr()); flush(stdout()) > > ### Name: print.qaptest > ### Title: Printing for qaptest Objects > ### Aliases: print.qaptest > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.summary.bayes.factor" > > ### * print.summary.bayes.factor > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.bayes.factor > ### Title: Printing for summary.bayes.factor Objects > ### Aliases: print.summary.bayes.factor > ### Keywords: print > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "print.summary.bbnam" > > ### * print.summary.bbnam > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.bbnam > ### Title: Printing for summary.bbnam Objects > ### Aliases: print.summary.bbnam print.summary.bbnam.fixed > ### print.summary.bbnam.pooled print.summary.bbnam.actor > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.blockmodel" > > ### * print.summary.blockmodel > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.blockmodel > ### Title: Printing for summary.blockmodel Objects > ### Aliases: print.summary.blockmodel > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.cugtest" > > ### * print.summary.cugtest > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.cugtest > ### Title: Printing for summary.cugtest Objects > ### Aliases: print.summary.cugtest > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.netcancor" > > ### * print.summary.netcancor > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.netcancor > ### Title: Printing for summary.netcancor Objects > ### Aliases: print.summary.netcancor > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.netlm" > > ### * print.summary.netlm > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.netlm > ### Title: Printing for summary.netlm Objects > ### Aliases: print.summary.netlm > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.netlogit" > > ### * print.summary.netlogit > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.netlogit > ### Title: Printing for summary.netlogit Objects > ### Aliases: print.summary.netlogit > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "print.summary.qaptest" > > ### * print.summary.qaptest > > flush(stderr()); flush(stdout()) > > ### Name: print.summary.qaptest > ### Title: Printing for summary.qaptest Objects > ### Aliases: print.summary.qaptest > ### Keywords: print > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "pstar" > > ### * pstar > > flush(stderr()); flush(stdout()) > > ### Name: pstar > ### Title: Fit a p*/ERG Model Using a Logistic Approximation > ### Aliases: pstar > ### Keywords: models multivariate regression graphs > > ### ** Examples > > #Create a graph with expansiveness and popularity effects > in.str<-rnorm(20,0,3) > out.str<-rnorm(20,0,3) > tie.str<-outer(out.str,in.str,"+") > tie.p<-apply(tie.str,c(1,2),function(a){1/(1+exp(-a))}) > g<-rgraph(20,tprob=tie.p) > > #Fit a model with expansiveness only > p1<-pstar(g,effects="outdegree") > #Fit a model with expansiveness and popularity > p2<-pstar(g,effects=c("outdegree","indegree")) Warning in glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, : fitted probabilities numerically 0 or 1 occurred > #Fit a model with expansiveness, popularity, and mutuality > p3<-pstar(g,effects=c("outdegree","indegree","mutuality")) Warning in glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, : fitted probabilities numerically 0 or 1 occurred > > #Compare the model AICs > extractAIC(p1) [1] 20.0000 433.1837 > extractAIC(p2) [1] 39.0000 276.8736 > extractAIC(p3) [1] 40.0000 269.6133 > > > > cleanEx(); ..nameEx <- "qaptest" > > ### * qaptest > > flush(stderr()); flush(stdout()) > > ### Name: qaptest > ### Title: Perform Quadratic Assignment Procedure (QAP) Hypothesis Tests > ### for Graph-Level Statistics > ### Aliases: qaptest > ### Keywords: htest math > > ### ** Examples > > > #Generate three graphs > g<-array(dim=c(3,10,10)) > g[1,,]<-rgraph(10) > g[2,,]<-rgraph(10,tprob=g[1,,]*0.8) > g[3,,]<-1; g[3,1,2]<-0 #This is nearly a clique > > #Perform qap tests of graph correlation > q.12<-qaptest(g,gcor,g1=1,g2=2) > q.13<-qaptest(g,gcor,g1=1,g2=3) > > #Examine the results > summary(q.12) QAP Test Results Estimated p-values: p(f(perm) >= f(d)): 0 p(f(perm) <= f(d)): 1 Test Diagnostics: Test Value (f(d)): 0.8355317 Replications: 1000 Distribution Summary: Min: -0.2935652 1stQ: -0.06774581 Med: -0.02258194 Mean: -0.001761391 3rdQ: 0.06774581 Max: 0.3838929 > plot(q.12) > summary(q.13) QAP Test Results Estimated p-values: p(f(perm) >= f(d)): 0.58 p(f(perm) <= f(d)): 0.482 Test Diagnostics: Test Value (f(d)): -0.1059998 Replications: 1000 Distribution Summary: Min: -0.1059998 1stQ: -0.1059998 Med: -0.1059998 Mean: -0.002119996 3rdQ: 0.1059998 Max: 0.1059998 > plot(q.13) > > > > cleanEx(); ..nameEx <- "reachability" > > ### * reachability > > flush(stderr()); flush(stdout()) > > ### Name: reachability > ### Title: Find the Reachability Matrix of a Graph > ### Aliases: reachability > ### Keywords: algebra > > ### ** Examples > > #Find the reachability matrix for a sparse random graph > g<-rgraph(10,tprob=0.15) > rg<-reachability(g) > g #Compare the two structures [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 0 1 0 0 0 1 0 0 0 [2,] 0 0 0 0 0 1 0 0 0 0 [3,] 0 0 0 0 0 0 0 0 0 0 [4,] 1 0 0 0 0 0 0 0 0 1 [5,] 0 0 0 0 0 0 0 0 0 0 [6,] 1 0 0 0 0 0 0 1 0 0 [7,] 1 0 0 0 0 0 0 1 0 0 [8,] 0 1 0 0 0 0 0 0 0 0 [9,] 0 0 1 0 0 0 0 0 0 0 [10,] 0 0 0 0 0 0 1 1 0 0 > rg [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 1 1 0 0 1 1 1 0 0 [2,] 1 1 1 0 0 1 1 1 0 0 [3,] 0 0 1 0 0 0 0 0 0 0 [4,] 1 1 1 1 0 1 1 1 0 1 [5,] 0 0 0 0 1 0 0 0 0 0 [6,] 1 1 1 0 0 1 1 1 0 0 [7,] 1 1 1 0 0 1 1 1 0 0 [8,] 1 1 1 0 0 1 1 1 0 0 [9,] 0 0 1 0 0 0 0 0 1 0 [10,] 1 1 1 0 0 1 1 1 0 1 > > #Compare to the output of geodist > all(rg==(geodist(g)$counts>0)) [1] TRUE > > > > cleanEx(); ..nameEx <- "read.nos" > > ### * read.nos > > flush(stderr()); flush(stdout()) > > ### Name: read.nos > ### Title: Read (N)eo-(O)rg(S)tat Input Files > ### Aliases: read.nos > ### Keywords: file > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "rgnm" > > ### * rgnm > > flush(stderr()); flush(stdout()) > > ### Name: rgnm > ### Title: Draw Density-Conditioned Random Graphs > ### Aliases: rgnm > ### Keywords: distribution graphs > > ### ** Examples > > #Draw 5 random graphs of order 10 > all(gden(rgnm(5,10,9,mode="graph"))==0.2) #Density 0.2 [1] TRUE > all(gden(rgnm(5,10,9))==0.1) #Density 0.1 [1] TRUE > > #Plot a random graph > gplot(rgnm(1,10,20)) > > > > cleanEx(); ..nameEx <- "rgraph" > > ### * rgraph > > flush(stderr()); flush(stdout()) > > ### Name: rgraph > ### Title: Generate Bernoulli Random Graphs > ### Aliases: rgraph > ### Keywords: distribution math > > ### ** Examples > > > #Generate three graphs with different densities > g<-rgraph(10,3,tprob=c(0.1,0.9,0.5)) > > #Generate from a matrix of Bernoulli parameters > g.p<-matrix(runif(25,0,1),nrow=5) > g<-rgraph(5,2,tprob=g.p) > > > > cleanEx(); ..nameEx <- "rguman" > > ### * rguman > > flush(stderr()); flush(stdout()) > > ### Name: rguman > ### Title: Draw Dyad Census-Conditioned Random Graphs > ### Aliases: rguman > ### Keywords: distribution graphs > > ### ** Examples > > #Show some examples of extreme U|MAN graphs > gplot(rguman(1,10,mut=45,asym=0,null=0,method="exact")) #Clique > gplot(rguman(1,10,mut=0,asym=45,null=0,method="exact")) #Tournament > gplot(rguman(1,10,mut=0,asym=0,null=45,method="exact")) #Empty > > #Draw a sample of multinomial U|MAN graphs > g<-rguman(5,10,mut=0.15,asym=0.05,null=0.8) > > #Examine the dyad census > dyad.census(g) Mut Asym Null [1,] 3 1 41 [2,] 11 2 32 [3,] 8 3 34 [4,] 5 3 37 [5,] 4 2 39 > > > > cleanEx(); ..nameEx <- "rgws" > > ### * rgws > > flush(stderr()); flush(stdout()) > > ### Name: rgws > ### Title: Draw From the Watts-Strogatz Rewiring Model > ### Aliases: rgws rewire.ws rewire.ud > ### Keywords: distribution graphs > > ### ** Examples > > > #Generate Watts-Strogatz graphs, w/increasing levels of rewiring > gplot(rgws(1,100,1,2,0)) #No rewiring > gplot(rgws(1,100,1,2,0.01)) #1 > gplot(rgws(1,100,1,2,0.05)) #5 > gplot(rgws(1,100,1,2,0.1)) #10 > gplot(rgws(1,100,1,2,1)) #100 > > #Start with a simple graph, then rewire it > g<-matrix(0,50,50) > g[1,]<-1; g[,1]<-1 #Create a star > gplot(g) > gplot(rewire.ws(g,0.05)) #5 > > > > > cleanEx(); ..nameEx <- "rmperm" > > ### * rmperm > > flush(stderr()); flush(stdout()) > > ### Name: rmperm > ### Title: Randomly Permute the Rows and Columns of an Input Matrix > ### Aliases: rmperm > ### Keywords: array distribution > > ### ** Examples > > #Generate an input matrix > g<-rgraph(5) > g #Examine it [,1] [,2] [,3] [,4] [,5] [1,] 0 0 1 1 0 [2,] 1 0 1 0 1 [3,] 0 0 0 0 0 [4,] 0 0 1 0 1 [5,] 1 1 0 0 0 > > #Examine a random permutation > rmperm(g) [,1] [,2] [,3] [,4] [,5] [1,] 0 1 1 1 0 [2,] 0 0 0 1 1 [3,] 1 1 0 0 0 [4,] 0 0 0 0 0 [5,] 0 0 1 1 0 > > > > cleanEx(); ..nameEx <- "rperm" > > ### * rperm > > flush(stderr()); flush(stdout()) > > ### Name: rperm > ### Title: Draw a Random Permutation Vector with Exchangeability > ### Constraints > ### Aliases: rperm > ### Keywords: distribution array > > ### ** Examples > > rperm(c(0,0,0,0)) #All elements may be exchanged [1] 2 4 3 1 > rperm(c(0,0,0,1)) #Fix the fourth element [1] 1 2 3 4 > rperm(c(0,0,1,1)) #Allow {1,2} and {3,4} to be swapped [1] 2 1 3 4 > rperm(c("a",4,"x",2)) #Fix all elements (the identity permutation) [1] 1 2 3 4 > > > > cleanEx(); ..nameEx <- "sdmat" > > ### * sdmat > > flush(stderr()); flush(stdout()) > > ### Name: sdmat > ### Title: Estimate the Structural Distance Matrix for a Graph Set > ### Aliases: sdmat > ### Keywords: univar multivariate math > > ### ** Examples > > #Generate two random graphs > g<-array(dim=c(3,5,5)) > g[1,,]<-rgraph(5) > g[2,,]<-rgraph(5) > > #Copy one of the graphs and permute it > g[3,,]<-rmperm(g[2,,]) > > #What are the structural distances between the labeled graphs? > sdmat(g,exchange.list=1:5) [,1] [,2] [,3] [1,] 0 12 8 [2,] 12 0 14 [3,] 8 14 0 > > #What are the structural distances between the underlying unlabeled > #graphs? > sdmat(g,method="anneal", prob.init=0.9, prob.decay=0.85, + freeze.time=50, full.neighborhood=TRUE) [,1] [,2] [,3] [1,] 0 4 4 [2,] 4 0 0 [3,] 4 0 0 > > > > cleanEx(); ..nameEx <- "sedist" > > ### * sedist > > flush(stderr()); flush(stdout()) > > ### Name: sedist > ### Title: Find a Matrix of Distances Between Positions Based on Structural > ### Equivalence > ### Aliases: sedist > ### Keywords: classif cluster math > > ### ** Examples > > #Create a random graph with _some_ edge structure > g.p<-sapply(runif(20,0,1),rep,20) #Create a matrix of edge > #probabilities > g<-rgraph(20,tprob=g.p) #Draw from a Bernoulli graph > #distribution > > #Get SE distances > g.se<-sedist(g) > > #Plot a metric MDS of vertex positions in two dimensions > plot(cmdscale(as.dist(g.se))) > > > > cleanEx(); ..nameEx <- "sna.operators" > > ### * sna.operators > > flush(stderr()); flush(stdout()) > > ### Name: sna.operators > ### Title: Graphical Operators > ### Aliases: sna.operators \%c\% > ### Keywords: math graphs > > ### ** Examples > > #Create an in-star > g<-matrix(0,6,6) > g[2:6,1]<-1 > gplot(g) > > #Compose g with its transpose > gcgt<-g%c%t(g) > gplot(gcgt,diag=TRUE) > gcgt [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 0 0 [2,] 0 1 1 1 1 1 [3,] 0 1 1 1 1 1 [4,] 0 1 1 1 1 1 [5,] 0 1 1 1 1 1 [6,] 0 1 1 1 1 1 > > > > cleanEx(); ..nameEx <- "sr2css" > > ### * sr2css > > flush(stderr()); flush(stdout()) > > ### Name: sr2css > ### Title: Convert a Row-wise Self-Report Matrix to a CSS Matrix with > ### Missing Observations > ### Aliases: sr2css > ### Keywords: manip math > > ### ** Examples > > #Start with some random reports > g<-rgraph(10) > > #Transform to CSS format > c<-sr2css(g) > > > > cleanEx(); ..nameEx <- "stackcount" > > ### * stackcount > > flush(stderr()); flush(stdout()) > > ### Name: stackcount > ### Title: How Many Graphs are in a Graph Stack? > ### Aliases: stackcount > ### Keywords: utilities math > > ### ** Examples > > stackcount(rgraph(4,8))==8 [1] TRUE > > > > cleanEx(); ..nameEx <- "stresscent" > > ### * stresscent > > flush(stderr()); flush(stdout()) > > ### Name: stresscent > ### Title: Compute the Stress Centrality Scores of Network Positions > ### Aliases: stresscent > ### Keywords: univar math > > ### ** Examples > > g<-rgraph(10) #Draw a random graph with 10 members > stresscent(g) #Compute stress scores [1] 13 17 22 12 7 12 22 14 8 13 > > > > cleanEx(); ..nameEx <- "structdist" > > ### * structdist > > flush(stderr()); flush(stdout()) > > ### Name: structdist > ### Title: Find the Structural Distances Between Two or More Graphs > ### Aliases: structdist > ### Keywords: univar multivariate math > > ### ** Examples > > #Generate two random graphs > g<-array(dim=c(3,5,5)) > g[1,,]<-rgraph(5) > g[2,,]<-rgraph(5) > > #Copy one of the graphs and permute it > g[3,,]<-rmperm(g[2,,]) > > #What are the structural distances between the labeled graphs? > structdist(g,exchange.list=1:5) 1 2 3 1 0 12 8 2 12 0 14 3 8 14 0 > > #What are the structural distances between the underlying unlabeled > #graphs? > structdist(g,method="anneal", prob.init=0.9, prob.decay=0.85, + freeze.time=50, full.neighborhood=TRUE) 1 2 3 1 0 4 4 2 4 0 0 3 4 0 0 > > > > cleanEx(); ..nameEx <- "summary.bayes.factor" > > ### * summary.bayes.factor > > flush(stderr()); flush(stdout()) > > ### Name: summary.bayes.factor > ### Title: Detailed Summaries of Bayes Factor Objects > ### Aliases: summary.bayes.factor > ### Keywords: math > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "summary.bbnam" > > ### * summary.bbnam > > flush(stderr()); flush(stdout()) > > ### Name: summary.bbnam > ### Title: Detailed Summaries of bbnam Objects > ### Aliases: summary.bbnam summary.bbnam.fixed summary.bbnam.pooled > ### summary.bbnam.actor > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.blockmodel" > > ### * summary.blockmodel > > flush(stderr()); flush(stdout()) > > ### Name: summary.blockmodel > ### Title: Detailed Summaries of blockmodel Objects > ### Aliases: summary.blockmodel > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.cugtest" > > ### * summary.cugtest > > flush(stderr()); flush(stdout()) > > ### Name: summary.cugtest > ### Title: Detailed Summaries of cugtest Objects > ### Aliases: summary.cugtest > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.netcancor" > > ### * summary.netcancor > > flush(stderr()); flush(stdout()) > > ### Name: summary.netcancor > ### Title: Detailed Summaries of netcancor Objects > ### Aliases: summary.netcancor > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.netlm" > > ### * summary.netlm > > flush(stderr()); flush(stdout()) > > ### Name: summary.netlm > ### Title: Detailed Summaries of netlm Objects > ### Aliases: summary.netlm > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.netlogit" > > ### * summary.netlogit > > flush(stderr()); flush(stdout()) > > ### Name: summary.netlogit > ### Title: Detailed Summaries of netlogit Objects > ### Aliases: summary.netlogit > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "summary.qaptest" > > ### * summary.qaptest > > flush(stderr()); flush(stdout()) > > ### Name: summary.qaptest > ### Title: Detailed Summaries of qaptest Objects > ### Aliases: summary.qaptest > ### Keywords: math > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "symmetrize" > > ### * symmetrize > > flush(stderr()); flush(stdout()) > > ### Name: symmetrize > ### Title: Symmetrize an Adjacency Matrix > ### Aliases: symmetrize > ### Keywords: manip array math > > ### ** Examples > > #Generate a graph > g<-rgraph(5) > > #Weak symmetrization > symmetrize(g) [,1] [,2] [,3] [,4] [,5] [1,] 0 1 1 1 1 [2,] 1 0 1 0 1 [3,] 1 1 0 1 0 [4,] 1 0 1 0 1 [5,] 1 1 0 1 0 > > #Strong symmetrization > symmetrize(g,rule="strong") [,1] [,2] [,3] [,4] [,5] [1,] 0 0 0 0 0 [2,] 0 0 0 0 1 [3,] 0 0 0 0 0 [4,] 0 0 0 0 0 [5,] 0 1 0 0 0 > > > > cleanEx(); ..nameEx <- "triad.census" > > ### * triad.census > > flush(stderr()); flush(stdout()) > > ### Name: triad.census > ### Title: Compute the Davis and Leinhardt Triad Census > ### Aliases: triad.census > ### Keywords: math > > ### ** Examples > > #Generate a triad census of random data with varying densities > triad.census(rgraph(15,5,tprob=c(0.1,0.25,0.5,0.75,0.9))) 003 012 102 021D 021U 021C 111D 111U 030T 030C 201 120D 120U 120C 210 300 [1,] 258 155 8 8 5 14 2 2 2 0 0 1 0 0 0 0 [2,] 77 161 21 32 27 62 6 16 27 8 3 4 7 3 1 0 [3,] 10 38 22 22 17 53 39 40 41 18 17 19 26 46 42 5 [4,] 0 0 1 0 1 7 16 13 28 3 26 26 39 58 162 75 [5,] 0 0 0 0 0 1 3 3 2 0 19 7 7 14 164 235 > > > > cleanEx(); ..nameEx <- "triad.classify" > > ### * triad.classify > > flush(stderr()); flush(stdout()) > > ### Name: triad.classify > ### Title: Compute the Davis and Leinhardt Classification of a Given Triad > ### Aliases: triad.classify > ### Keywords: math > > ### ** Examples > > #Generate a random graph > g<-rgraph(10) > > #Classify the triads (1,2,3) and (2,3,4) > triad.classify(g,tri=c(1,2,3)) [1] "111D" > triad.classify(g,tri=c(1,2,3)) [1] "111D" > > #Plot the triads in question > gplot(g[1:3,1:3]) > gplot(g[2:4,2:4]) > > > > cleanEx(); ..nameEx <- "upper.tri.remove" > > ### * upper.tri.remove > > flush(stderr()); flush(stdout()) > > ### Name: upper.tri.remove > ### Title: Remove the Upper Triangles of Adjacency Matrices in a Graph > ### Stack > ### Aliases: upper.tri.remove > ### Keywords: manip array math > > ### ** Examples > > #Generate a random graph stack > g<-rgraph(3,5) > #Remove the upper triangles > g<-upper.tri.remove(g) > > > > ### *