# Two Way ANOVA repeated measurement

I am trying to compare the three replicate samples taken at different time point to see if the replicate one differ from replicate two and three and visa verse. My interest is to see if the three replicates represent the same community by have the same species abundance or not? From the reading I have done, I think that Two Way ANOVA repeated measurement would do the job for me but I am not quite sure that would be right?

https://gist.github.com/plxsas/9ec2a528f94bd2dff46d

Can anybody advice me on that and how to achieve it in R, please?

• Have you tried Google? ww2.coastal.edu/kingw/statistics/R-tutorials/repeated.html – Ladislav Naďo Jun 13 '14 at 13:52
• Or, if you do not have any experience with R. Please tell me more about your variables. – Ladislav Naďo Jun 13 '14 at 14:01
• I have conducted study by collecting samples from three sites on monthly basis and for a period of one year. Within each site, I have taken three replicates. After looking at the sampling, I have found that each of the replicate sample has about 4-5 species with roughly the same percentage of abundance. My goal is to prove statistically that the three replicate within each site have been sampled from the same assemblage based on the similarity in the species composition and there is no much difference if you samples 2 meter away from the original sample. – user48386 Jun 13 '14 at 14:12
• Why is "BranC" at May-12 missing? It do not exist, or you are posting only a fragment from full dataset? – Ladislav Naďo Jun 13 '14 at 14:28
• Yes, I have just posted a small portion of my data but the same concept follow for the rest of the year.Your help would be appreciated. – user48386 Jun 13 '14 at 14:37

At first, you must reorganize your table:

Months  Replicate2      Species.1   Species.2  Species.3   Species.4
Jan-12  BranA           778         41         19          1
Jan-12  BranB           800         18         18          2
Jan-12  BranC           537         48         20          2
Feb-12  BranA           465         29         19          1
Feb-12  BranB           444         45         14          1
Feb-12  BranC           671         13         10          2
...

# reorganisation procedure
# (need to be optimalized according to your full datatable!!!)
# create vectors...
spec_abund <- c(my.data$Species.1, my.data$Species.2,
my.data$Species.3, my.data$Species.4) # species abundance
sites <- rep(my.data$Replicate2, times = 4) # sites my.date <- rep(my.data$Months, times = 4) # date of collection
spec.no <- rep(c("spec1","spec2","spec3","spec4"),
each = nrow(my.data)) # spec.ID
# ...and bind them into new data.frame
my.reorg <- data.frame(abundance = spec_abund, sites = sites,
months = my.date, spec.no = spec.no) # final table


It should looks like this:

my.reorg
abundance sites months spec.no
1        778 BranA Jan-12   spec1
2        800 BranB Jan-12   spec1
3        537 BranC Jan-12   spec1
4        465 BranA Feb-12   spec1
5        444 BranB Feb-12   spec1
6        671 BranC Feb-12   spec1
...


Than try to fit the model:

aov.out <- aov(abundance ~ sites * months + Error(spec.no/months), data=my.reorg)
summary(aov.out)


It looks like that sites are non-significantly different (in species composition) from each other during the "whole time". Is this what you need?

• btw I do not use last two rows in your data table...due to "BranC" at May-12 missing. – Ladislav Naďo Jun 16 '14 at 13:41
• Yes, that is what I really want , thank you very much for your help – user48386 Jun 19 '14 at 8:39