I apologize if the question is considered too broad, but I'm hoping to get at least a basic starting point as I'm somewhat stuck with how to approach this. I am working with community ecological data-counts of species collected. The main goal of the project is to see if there is a difference between diversity across hot and cold years. Alpha diversity and ordinations are calculated on top of this but I need to show that there is no likely effect due to sites where data was collected.

For each temp. type(warm or cold) there are four years/type being used(so total of 8 communities). For each year, there are 6 different sites where species were collected. I am keeping months separated-so within a month, two trips were taken per site(these are replicates).

Essentially I have {Temp Type:(Cold vs Warm)-->4 Years/type-->6 sites/year-->and 2 replicates/site}

So main factors are site, replicate within site, and temp. type. response is species counts for each given year. I need to test to make sure there is no significant effect of sites and replicates within sites. I assume a nested anova may be appropriate?


1 Answer 1


Not very neat to do by hand, but multi-way ANOVA is completely possible here and runs easily in R or other languages. Consider the following example data set:

temp <- c("Warm", "Cold")
year <- paste("Year", 1:4)
site <- paste("Site", LETTERS[1:6])
reps <- 1:2

data_df <- expand.grid(reps, factor(year), factor(temp), factor(site))[,4:1]
colnames(data_df) <- c("Site", "Temperature", "Year", "Replicate")
data_df$Measurement <- round(
  15 + 
  1.5 * (data_df$Temperature == "Warm") +
  0.1*(as.numeric(data_df$Site)-3.5) + 
  rnorm(nrow(data_df), 0.4 * (as.numeric(data_df$Year)-2.5), 1) + 
  rnorm(nrow(data_df), 0, 4)

I need to test to make sure there is no significant effect of sites and replicates within sites

Then you simply run

anova_model <- aov(Measurement ~ Site * Replicate, data = data_df)

Notice the * operator that gives us the interaction term. The results are

               Df Sum Sq Mean Sq F value Pr(>F)  
Site            5  146.4  29.285   1.950 0.0946 .
Replicate       1    0.1   0.094   0.006 0.9372  
Site:Replicate  5   58.3  11.669   0.777 0.5690  
Residuals      84 1261.4  15.016                 
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Now this is obviously fabricated data and hence a complete rubbish, but once you put your measurements in, you will get your answers.

  • $\begingroup$ Not sure if count data will meet the assumptions of traditional ANOVA. $\endgroup$ Commented Nov 5, 2023 at 11:51
  • $\begingroup$ It might be the best shot, possibly later adding a Poisson VST. Also, consider the essence of the question - this shouldn't provide predictions but rather estimate the effects of Size and Replicate $\endgroup$
    – Spätzle
    Commented Nov 5, 2023 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.