Statistical Analysis

network analytics statistics CUG test statnet

Using Univariate Conditional Uniform Graph Tests

Kristina Becvar http://gratefulnetwork.live/ (UMass DACSS Program (My Academic Blog Link))https://kristinabecvar.com
2022-05-10
Show code

Loading Networks

I previously analyzed the network using igraph and statnet, and need to make a decision about which package serves the network best.

Affiliation Matrix

Loading the dataset and creating the network to begin my analysis:

Show code
gd_affiliation <- read.csv('gd_affiliation_matrix.csv', row.names = 1, header = TRUE, check.names = FALSE)
gd_matrix <- as.matrix(gd_affiliation)

Bipartite Projection

Show code
gd_projection <- gd_matrix%*%t(gd_matrix)
write.csv(gd_projection, file = "gd_projection.csv")

Create statnet Object

Show code
set.seed(11)
gd_statnet <- as.network(gd_projection,
               directed = FALSE, 
               bipartite = FALSE,
               loops = FALSE,
               connected = TRUE)

Centrality and Node Data

I am going to load the data frame I saved from the statnet package analysis as well as a dataframe with key comparable results from each package

Show code
gd_stat_nodes <- read.csv("gd_stat_nodes.csv")
gd_compare <- read.csv("gd_comparison_packages.csv")

Comparing Network Properties

In the semester assignment, we looked at what to do if we are interested in testing whether or not a specific network property, such as transitivity, is higher in the network we are interested in than we would expect from a random network. To test our network against a null hypothesis, we can use the function cug.test() and set the parameters on which we plan to condition. Possible parameters for this function include: size, edges, and dyad.census for sna/statnet.

Create t-stat Function

Show code
cug.t<-function(cug.object){
  (cug.object$obs.stat-mean(cug.object$rep.stat))/sd(cug.object$rep.stat)
}

Network Transitivity to Null

Comparing transitivity to null conditional on size

Show code
#compare network transitivity to null conditional on size
trans.cug<-cug.test(gd_projection,FUN=gtrans,mode="graph",cmode="size")
trans.cug

Univariate Conditional Uniform Graph Test

Conditioning Method: size 
Graph Type: graph 
Diagonal Used: FALSE 
Replications: 1000 

Observed Value: 0.5240964 
Pr(X>=Obs): 0.189 
Pr(X<=Obs): 0.811 

Plot Results

Show code
plot(trans.cug)

Inspect Details

Show code
#inspect CUG test
trans.cug

Univariate Conditional Uniform Graph Test

Conditioning Method: size 
Graph Type: graph 
Diagonal Used: FALSE 
Replications: 1000 

Observed Value: 0.5240964 
Pr(X>=Obs): 0.189 
Pr(X<=Obs): 0.811 

T-Stat Test

Show code
#inspect CUG test
cug.t(trans.cug)
[1] 0.8395548

Evaluation

There is a reasonable probability that the observed network transitivity of 0.524 could be randomly generated, conditional only on the size of the network. In this case, I cannot accept the alternative hypothesis that the observed transitivity is higher than would be expected from a random network. In fact, the probability that X <= 0.524 is 19.6% and the probability that x >= 0.524 is 80.4%. The t-stat evaluation tells us that the observed transitivity value is less than 1 standard error away from what we would expect, on average.

Network Degree Centralization to Null

Comparing network degree centralization to null conditional on size

Show code
#compare network degree centralization to null conditional on size
c.degree.cug <-cug.test(gd_projection,FUN=centralization,  FUN.arg=list(FUN=degree, cmode="degree"), mode="graph", cmode="size")

Plot Results

Show code
#plot vs simulation results
plot(c.degree.cug)

Inspect Details

Show code
#inspect CUG test
c.degree.cug

Univariate Conditional Uniform Graph Test

Conditioning Method: size 
Graph Type: graph 
Diagonal Used: FALSE 
Replications: 1000 

Observed Value: 5.206522 
Pr(X>=Obs): 0 
Pr(X<=Obs): 1 

T-Stat Test

Show code
#t-stat between observed and simulated networks
cug.t(c.degree.cug)
[1] 101.9499

Evaluation

There is an extremely remote probability that the observed network degree centrality of 5.21 could be randomly generated, conditional only on the size of the network. In this case, I can accept the alternative hypothesis that the observed network degree centrality is higher than would be expected from a random network. .

Betweenness Centrality

Comparing network betweenness centralization to null conditional on size

Show code
#compare network betweenness centralization to null conditional on size
b.degree.cug <-cug.test(gd_projection,FUN=centralization,  FUN.arg=list(FUN=betweenness, cmode="undirected"), mode="graph", cmode="size", reps=100) 

Plot Results

Show code
#plot vs simulation results
plot(b.degree.cug)

Inspect Details

Show code
#inspect CUG test
b.degree.cug

Univariate Conditional Uniform Graph Test

Conditioning Method: size 
Graph Type: graph 
Diagonal Used: FALSE 
Replications: 100 

Observed Value: 0.3759561 
Pr(X>=Obs): 0 
Pr(X<=Obs): 1 

T-Stat Test

Show code
#t-stat between observed and simulated networks
cug.t(b.degree.cug)
[1] 34.06653

Evaluation

Again, there is an extremely remote probability that the observed betweenness centrality of 0.376 could be randomly generated, conditional only on the size of the network. In this case, I can accept the alternative hypothesis that the observed network degree centrality is higher than would be expected from a random network. This makes sense with the rest of my network evaluations.

Transitivity

Comparing transitivity to null conditional on dyad

Show code
t.degree.cug <-cug.test(gd_projection,FUN=gtrans, mode="graph", cmode="dyad", reps=100) 

Plot Results

Show code
#plot vs simulation results
plot(t.degree.cug)

Inspect Details

Show code
#inspect CUG test
t.degree.cug

Univariate Conditional Uniform Graph Test

Conditioning Method: dyad.census 
Graph Type: graph 
Diagonal Used: FALSE 
Replications: 100 

Observed Value: 0.5240964 
Pr(X>=Obs): 0 
Pr(X<=Obs): 1 

T-Stat Test

Show code
#t-stat between observed and simulated networks
cug.t(t.degree.cug)
[1] 8.463895

Evaluation

Unlike the first evaluation of transitivity on size, this evaluation of transivity on dyad gives a result that is more in line with subsequent calculations.

Multiple Evaluations

For my research in particular, I want to look at the measures of centrality and through the different modes of evaluation.

Show code
cug_cent_size <- cug.test(gd_statnet,
                       centralization,
                       FUN.arg=list(FUN=degree), 
                       mode="graph", 
                       cmode="size")
cug_cent_edge <- cug.test(gd_statnet,
                        centralization,
                        FUN.arg=list(FUN=degree), 
                        mode="graph", 
                        cmode="edges")
cug_cent_dyad <- cug.test(gd_statnet,
                       centralization,
                       FUN.arg=list(FUN=degree), 
                       mode="graph", 
                       cmode="dyad.census")

Visualization

Show code
degree_centralization <- c(cug_cent_size$obs.stat,
                        cug_cent_edge$obs.stat, 
                        cug_cent_dyad$obs.stat)

rt_tail <- c(cug_cent_size$pgteobs, 
             cug_cent_edge$pgteobs, 
             cug_cent_dyad$pgteobs)

lt_tail <- c(cug_cent_size$plteobs, 
             cug_cent_edge$plteobs, 
             cug_cent_dyad$plteobs)

centrality <- cbind(degree_centralization,
                     rt_tail, 
                     lt_tail)

rownames(centrality) <- c("Size", "Edges", "Dyads")

par(mfrow=c(1,3))
plot(cug_cent_size, main="Centrality \nConditioned on Size" )
plot(cug_cent_edge, main="Centrality \nConditioned on Edges" )
plot(cug_cent_dyad, main="Centrality \nConditioned on Dyads" )

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Becvar (2022, May 11). Data Analytics and Computational Social Science: Statistical Analysis. Retrieved from http://gratefulnetwork.live/posts/statistics/

BibTeX citation

@misc{becvar2022statistical,
  author = {Becvar, Kristina},
  title = {Data Analytics and Computational Social Science: Statistical Analysis},
  url = {http://gratefulnetwork.live/posts/statistics/},
  year = {2022}
}