I am working on a dataset composed of different sites, where several replications were carried out on each site to measure abundance and biomass of observed species. Each site has its own level of protection. The idea would be to carry out a multivariate analysis to show the possible effect of protection levels on the biomass and abundance indices of the sites, while taking into account possible site and species effects. However, the sampling effort is not the same for each site (6 or 8 replications), which is a problem for my further statistical analysis, as it seems to me that the sampling effort should be the same between sites to avoid any statistical bias.
A short overview of the data (only two of the total number of sites are shown in this table):
table_biomass_abundance_Site_Replicate
site | replicate | biomass | abundance |
---|---|---|---|
1.1 | 1 | 359.4 | 31 |
1.1 | 2 | 449.9 | 52 |
1.1 | 3 | 6326.7 | 50 |
1.1 | 4 | 290.2 | 30 |
1.1 | 5 | 323.5 | 29 |
1.1 | 6 | 569.9 | 18 |
10.2 | 123 | 6513.7 | 278 |
10.2 | 124 | 24988.4 | 338 |
10.2 | 125 | 36618.8 | 309 |
10.2 | 126 | 2418.6 | 309 |
10.2 | 127 | 6193.6 | 309 |
10.2 | 128 | 54410.3 | 155 |
10.2 | 129 | 11290.6 | 378 |
10.2 | 130 | 12284.9 | 347 |
My idea would be to randomly collect 6 transects per site (to have the same sampling effort per site) and to repeat this sampling a large number of times using a for loop.
# loop random sampling
split_test_site <- split(table_biomass_abundance_Site_Replicate,
table_biomass_abundance_Site_Replicate$site)
table_test <- matrix(ncol = 4)
colnames(table_test) <- c("site", "replicate", "biomass",
"abundance")
for (i in 1:100){
for (i in 1:length(split_test_site)) {
temp_002 <- as.data.frame(split_test_site[[i]])
temp_003 <- sample_n(temp_002,6)
table_test <- rbind(table_test, temp_003)
}
}
This is how my result looks like, with the loop selecting randomly only 6 out of 8 replications per site :
site | replicate | biomass | abundance |
---|---|---|---|
10.2 | 128 | 54410.3 | 155 |
10.2 | 123 | 6513.7 | 278 |
10.2 | 129 | 11290.6 | 378 |
10.2 | 124 | 24988.4 | 338 |
10.2 | 130 | 12284.9 | 347 |
10.2 | 125 | 36618.8 | 309 |
This is however not the result I am hoping for, as I would like to repeat the sampling many times for each site and not just have a single run for each site, which gives me a different total biomass and abundance per site each time I rerun my script due to the different random draws.
Any ideas how I could achieve this?
I hope my approach makes sense and is clear enough.