I have samples from animal subjects from two years, three regions, and two behavioral groups. The data are all observational, and the design of the study is very unbalanced. I want to know whether subjects that do a behavior (ch.binary) have different microbial communities, controlling for year of sample collection and region. For some, but not all subjects, I have multiple samples. Some animals have a samples taken from both years of the study, and some have a sample from both before and after the focal behavior occurred. How can I design a test to see whether microbial communities differ between behavioral groups while controlling for repeated measures of animals.
I think what I need is to allow permutations within subjects, but I am unsure of how to deal with year.
So far, I have tried defining subjects as strata at the Plot level. I'm confused about whether I also need to add a Block level for year. And if so, how to specify this.
I attempted to include an example below, with the permutation design, model, and my factors. Thank you in advance for any help or tips on how to better ask this question.
h <- how(plots = Plots(strata = subject, type = "none"),
nperm = 499)
adonis2(dist.mat ~ year + region + ch.binary, permutations = h,
nperm = 9999, set.seed(1), by = "margin")
year = as.factor(c(rep("2015", 15), rep ("2016", 34)))
region = as.factor(c("me", "me", "me", "w", "me", "e", "e", "w", "w", "e", "w", "e", "me", "w", "w", "me", "e", "w", "me", "w", "w", "me", "w", "w", "me", "e", "w", "w", "e", "me", "w", "w", "me", "me", "w", "me", "me", "w", "me", "w", "me", "w", "me", "me", "w", "w", "me", "me", "me"))
ch.binary = as.factor(c(1,1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2, 1,
1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2,
1, 1,1, 1, 1, 1,1, 1, 1, 1, 2, 1, 1))
subject = as.factor(c("sadie","djibouti","wallace","ariel","dusty","texas","paula",
"tiger","bridget","larissa","tiger","texas","serenac","sarah",
"ariel","texas","darcy","biff","paula","julikmi","julikmi",
"kelty","lassie","lassie","sadie","larissa","juniper","sarah",
"darcy","serenac","alexa","sawathu","hardee","dusty","shira",
"tatya","noir","wanaka","wallace","liani","donoma","shira",
"texas","hezakiah","delphi,II","bridget","hoorah","hezakiah","donoma"))