Reputation: 11
I want to do a MANOVA analysis with community data. I think I've understood the purpose of this analysis but not the principle or how to carry it out.
These are two random data frames that simulate all the data from my communities. On the one hand I have the relative abundance of several reef fish species and on the other hand the percentage cover of several coral species for the same sites.
Here, I have 20 sites in total, 5 sites in each of 4 different major regions.
# FISH MATRIX #
n_sites <- 20
n_fish <- 20
n_regions <- 4
abundance_fish_matrix <- matrix(
runif(n_sites * n_fish),
nrow = n_sites,
ncol = n_fish
)
abundance_fish_matrix <- t(apply(abundance_fish_matrix, 1, function(x) x / sum(x)))
rownames(abundance_fish_matrix) <- paste0("Site_", 1:n_sites)
colnames(abundance_fish_matrix) <- paste0("Fish_", 1:n_fish)
abundance_fish_df <- as.data.frame(abundance_fish_matrix)
head(abundance_fish_df)
REGION <- rep(paste0("Region_", 1:n_regions), each = 5)
abundance_fish_df$REGION <- REGION
head(abundance_fish_df)
# CORAL MATRIX #
n_coral <- 20
set.seed(456)
coverage_coral_matrix <- matrix(
runif(n_sites * n_coral, min = 0, max = 100),
nrow = n_sites,
ncol = n_coral
)
coverage_coral_matrix <- t(apply(coverage_coral_matrix, 1, function(x) x / sum(x) * 100))
rownames(coverage_coral_matrix) <- paste0("Site_", 1:n_sites)
colnames(coverage_coral_matrix) <- paste0("Coral_", 1:n_coral)
coverage_coral_df <- as.data.frame(coverage_coral_matrix)
coverage_coral_df$REGION <- REGION
head(coverage_coral_df)
I don't know what I need to do to carry out my MANOVA analysis. My explanatory variable would be my coral, I want to know if my coral cover can explain my fish composition in each site.
Upvotes: 0
Views: 53
Reputation: 791
In the situation where there multiple response variables you can test them simultaneously using a multivariate analysis of variance (MANOVA).
You can run a MANOVA if you apply the corals coverage at different sites (independent variables) to your fish species and fish abundance (dependent variables). The hypothesis is that both together are affected by the difference in coral cover per each location.
First combine your fish and your coral data frames but leave out the region column so we're not duplicating anything, maybe something like:
combined_data <- cbind(abundance_fish_df, coverage_coral_df[, -ncol(coverage_coral_df)])
Next we pull the variables for all our fish species with abundance, and the variables for coral, using these and adding in REGION
, now you have everything you need to run the manova() function. Something like:
fish_vars <- paste("Fish_", 1:n_fish, sep="")
coral_vars <- paste("Coral_", 1:n_coral, sep="")
manova_formula <- as.formula(paste("cbind(", paste(fish_vars, collapse=","), ") ~ REGION +", paste(coral_vars, collapse="+")))
Finally, run your MANOVA:
manova_result <- manova(manova_formula, data=combined_data)
Upvotes: 0