I need do test t for this data, but "lapply" generates a variable in the list, and within this list it is necessary to get some specific information, normality and statistics for each column [,1]
library(igraph)
vetor <- c(1, 5, 3, 8, 2, 9, 3, 2:15, 1, 5, 3, 6, 5, 9, 3 )
matrixnet<-matrix(vetor, 7, 7)
matcor <- cor(matrixnet, method = "spearman")
matrixnetwork = graph.adjacency(matcor, mode="undirected", weighted = TRUE, add.colnames=NULL, diag=FALSE)
plot(matrixnetwork)
##Boot
N <- 7L
set.seed(2023)
R <- 100L
BIPERMUT<- vector("list", length = R)
for(i in seq.int(R)) {
indices <- sample(N, replace = TRUE)
BIPERMUT[[i]] <- permute(matrixnetwork, sample(vcount(matrixnetwork)))
}
plot (BIPERMUT[[1]])
degree(BIPERMUT[[1]], normalized = FALSE, loops = FALSE)
matrix
#degree analyse
boot_degree2 <- lapply(BIPERMUT, degree, normalized = FALSE, loops = FALSE)
#Statist
shapiro.test (boot_degree2)
t.test(boot_degree2,mu = 0)
this is show:
shapiro.test (boot_degree2)
Error in shapiro.test(boot_degree2) : is.numeric(x) is not TRUE
> t.test(boot_degree2, mu = 0)
Error in var(x) : is.atomic(x) is not TRUE Além disso: Warning message: In mean.default(x) : argumento não é numérico nem lógico: retornando NA
I think you could do
sapply(boot_degree2,
function(x) unlist(shapiro.test(x)[c("statistic", "p.value")]))
(you might want to transpose the result), and a similar function for t.test()
. Both t.test()
and shapiro.test(0
return an object of class htest
, which is a list including (at least) elements "statistic" and "p.value".
(As a side point, I'm not sure either of these tests makes much sense statistically, but that's not what you asked ...)
If you want to run these tests nodewise/columnwise:
dmat <- do.call("rbind", boot_degree2)
## apply tests columnwise
apply(dmat, 2,
function(x) unlist(shapiro.test(x)[c("statistic", "p.value")]))
As before, this fails because all of the degrees in the matrix are equal ...