0

in order I need do:

measuring the targeted variable on the original network and save it Shuffling my original data (correlation matrix) - randomly (100x) create the graph measuring the targeted variable for this random network Save this data end of the loop Comparing the distribution of the random targeted variable with the original one saved at the begging. Then if the original data is outside of the 95% of the distribution of the random variable, this mean that it's significative (the random is different of the original variable).

library(igraph)
 ###DADOSEXEMPLO##
valores <- c(1, 5, 3, 8, 2, 9, 3, 2, 3 ,2, 5, 3, 6, 5, 1, 5, 3, 4, 2, 2, 5, 6, 5, 7, 1, 2, 
             8, 12, 5, 1, 5, 3, 6, 5, 9, 3,3,4,5,7,8,2,7,8,4,3,1,4,4 ) matrixnet <- matrix(valores, 7, 7) matcor <- cor(matrixnet, method = "spearman")

cor_pequena <- 0.1 matcor[] <- ifelse(matcor < cor_pequena, 0, matcor) matrixnetwork = graph.adjacency(matcor, mode = "undirected", weighted = TRUE, add.colnames = NULL, diag = FALSE) degree(matrixnetwork) #> [1] 3 4 3 3 1 2 2

plot(matrixnetwork)

Here I calculate the unique value for the graph, in this case for the measure betw

`centr_betw(matrixnetwork, directed = FALSE, normalized = TRUE)$res`

Here I apply the permutation "change value in vertes" in conjunction with the specific function I want to apply, in this case Betw

set.seed(123) bootcentr_Betw <- lapply(seq_len(Nperm), function(x){
randomnet <- rewire(matrixnetwork, with=each_edge(0.5)) #rewire vertices with constant probability E(randomnet)$weight <- sample(E(matrixnetwork)$weight) #shuffle initial weights and assign them randomly to edges return(centr_betw(randomnet)$res) }) 

Now I need to compare the original value with the bootstrap of the randomized graph.

Below I tried to plot the original unique value against bootstrap, replicating the code I got from elsewhere

`orig <- centr_betw(matrixnetwork, directed = FALSE, normalized = TRUE)$res

Nperm <- 1e2 set.seed(123) bootcentr_Betw <- replicate(Nperm, { randomnet <- rewire(matrixnetwork, with = each_edge(0.5)) E(randomnet)$weight <- sample(E(matrixnetwork)$weight) centr_betw(randomnet)$res })

op <- par(mfrow = c(2, 4)) for(k in seq_along(orig)) { main <- sprintf("Vértice: %d", k) bootcentr_Betw[k,] |> density() |> plot(main = main, sub = "Observed vs. randomized") abline(v = orig[k], col = "red") }

par(op)`

MY QUESTION:

The difference to the other questions is that I only have 1 original sample and its permutation, not two original samples and their permutations

I need to compare my value coming from a matrix bootstrap, with the original unique value, but I don't know exactly how to do this for my data. If the original data is outside of the 95% of the distribution of the random variable, this mean that it's significative (the random is different of the original variable).

I cant do statistic to compare this datas: Observed value And permutation from this value.

I can use this form to p-value: number of values (statistics) that are greater than or equal to the observed value, and divide by the number of values. In code, pval = sum(s >= s0)/N;

I found several other formulas on the internet. But basically in summary I just wanted to know a correct formula to calculate the value of p, considering that I want to compare an original value and the permutation of that value 100x.

In short, I have a single value (x), I permuted this value (x), and I want to compare the two obtained a p value, but I don't know exactly how

0 Answers0