Learn R Programming

NetworkToolbox (version 1.4.2)

network.permutation: Permutation Test for Network Measures

Description

Computes a permutation test to determine whether there are difference in centrality and global network measures

Usage

network.permutation(
  sample1 = NULL,
  sample2 = NULL,
  iter,
  network = c("glasso", "ising", "TMFG", "LoGo"),
  measure = c("betweenness", "closeness", "strength", "eigenvector", "rspbc", "hybrid",
    "ASPL", "CC", "S", "Q"),
  alternative = c("less", "greater", "two.tailed"),
  ncores,
  prev.perm = NULL
)

Arguments

sample1

Matrix or data frame. Sample to be compared with sample2

sample2

Matrix or data frame. Sample to be compared with sample1

iter

Numeric. Number of iterations to perform. Defaults to 1000

network

Character. Network estimation method to apply to the datasets. Defaults to "glasso"

measure

Character. Network measure to be compared in the permutation test

alternative

Character. Alternative hypothesis test to perform. Defaults to "two.tailed"

ncores

Numeric. Number of computer processing cores to use for bootstrapping samples. Defaults to n - 1 total number of cores. Set to any number between 1 and maximum amount of cores on your computer (see parellel::detectCores())

prev.perm

network.permutation class object. An object of previously performed permutation test. The networks generated in the previous permutation will be used to compute other network measures. This saves time when computing multiple permutation tests

Value

Returns a list containing two objects:

result

The results of the permutation test. For centrality measures, this is a matrix where the rows represent each node and the columns are the observed values of the centrality measure for sample1, sample2, and the p-value from the permutation test. For global network measures, this is a vector with the observed values of the global network measure for sample1, sample2, and the p-value from the permutation test.

networks

A list containing two lists: network1 and network2. The network lists correspond to the networks generated in the permutation test for sample1 and sample2, respectively. This output is used primarily for the computation of other network measures using the same datasets (see prev.perm explanation)

Examples

Run this code
# NOT RUN {
# Split data (only for example)
split1 <- neoOpen[c(1:401),]
split2 <- neoOpen[c(402:802),]

# }
# NOT RUN {
# Perform permutation test
perm.str <- network.permutation(split1, split2, iter = 1000, network = "glasso",
measure = "strength", alternative = "two.tailed", ncores = 2)

# Check results
perm.str$result

# Permutation to check other measures (using networks from previous result)
perm.aspl <- network.permutation(prev.perm = perm.str, measure = "ASPL", ncores = 2)

# Check results
perm.aspl$result
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab