Repository navigation
random effect of repetition of individuals in adonis2 #765
Unanswered
GuillaumeLeonVerchere
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello everyone,
I am trying to add a random effect to the adonis2 function. I want to compare distances between two statuses, but the problem is that I have several observations per individual for one type of status. If I had been using a mixed model, I would have written my model as lmer(distance~status+(1|name)). The problem is that if I do this with strata, my block corresponds to one individual. One solution I had thought of was to specify a new block for each permutation in strata, or one value per individual for each individual selected. But I'm not sure how to go about it.
Here is the code I wrote to try to create the visualisation I am interested in.
change my table for each permutation
fonction_tirage <- function(x){
data = x
liste_name <- unique(data_cross_dF_C30$NAME)
data_cross_dF_C30_S<-NULL
for (n in liste_name) {
tab_i <- subset(data_cross_dF_C30, NAME == n)
tab_i_1 <- tab_i[sample(nrow(tab_i), size = 1, replace = FALSE),]
tab_i_1$sample <- 1
} else {
data_cross_dF_C30_S<- rbind(data_cross_dF_C30_S,tab_i_1)}
}
observatrion_verctor<- as.vector(row.names(data_cross_dF_C30_S))
return(observatrion_verctor)
}
perma_T_statut<-adonis2(matrix_T_philr~statu, method = "euclidean", data=data_cross_dF_C30,permutations=5000, by= "margin", strata = data_cross_dF_C30[fonction_tirage(data_cross_dF_C30),])
Thank you for your help.
All reactions