Research Paper in Ecology Lab
1
Lab 10 Forest Edge Effect (Data Analysis) Objectives:
To compare arthropod species richness and abundance between forest edge and interior habitats at BOLOS.
To fit simple linear regression model on arthropod species richness and canopy cover.
To fit simple linear regression model on arthropod abundance and canopy cover. To plot the data of arthropod species richness against canopy cover. To plot the data of arthropod abundance against canopy cover.
Background Information
To compare the abundance and species richness (α diversity) of arthropods between forest edge and interior habitats, we will use analysis of variance (ANOVA). Although fairly robust, this method makes some assumptions about the data, so we need to test those assumptions about our data first.
1. What are some of the assumptions of ANOVA and how can they be tested?
To examine the relationship between the species richness of arthropods and some environmental characters (e.g., canopy cover %), we will use simple linear regression. This statistical method analyzes the statistical relationship between two quantitative variables (predictor and response) with hypothesized causality between them (Fig. 10.1).
2
A simple linear regression model represents the relationship between the mean (expected value) of the response and the predictor by the function
μy = a + bx,
where x is the predictor, y is the response, and a is the intercept. Notice that y does not always equal to a + bx. Rather, the observations have variations around the regression line and their mean (μy) is given by the function.
A linear regression model makes a few assumptions:
1. The mean of responses (μy) at each predictor value (xi) is described by a linear function of xi.
2. The errors of responses are independent. 3. The errors of responses at each predictor value are normally distributed. 4. The errors of responses at different predictor value have equal variances
(σ2).
Sometimes the linear regression relationship between the predictor and response entails transformation of both variables. A common transformation is the log10 transformation, which gives the data points a better fit to the linear regression model.
We will model the abundance of arthropods by the canopy cover percentage using simple linear regression in R. You will then plot the two variables and draw the least squares linear regression line.
2. What is α (alpha) diversity?
3. Which variable is the predictor? Which variable is the response?
Fig. 10.1. Liner regression between predictor (x) and response (y). https://cdn-images-1.medium.com/max/1600/1*LEmBCYAttxS6uI6rEyPLMQ.png
3
Activity
Work in groups, download the OneDrive spreadsheet as an Excel file. Next, import the data into R, using RStudio. Be sure to select the correct sheet from your Excel file, and give it a concise name that’s easy to type with no spaces (e.g., yourDF). You can view your data frame by clicking on it in the RStudio Environment.
We first need to create two new variables in our data frame, the α (alpha) diversity and total abundance for each cover board (row). Use this line of code to create a column named “Alpha”:
yourDF$Alpha <- rowSums(yourDF[,c(9:21)]>0)
Use this line of code to create a column named “Abundance”:
yourDF$Abundance <- rowSums(yourDF[,c(9:21)])
Now let’s test for the normality and homogeneity of our data. We will first test normality using Q-Q plots. We will do this for both alpha diversity,
qqnorm(yourDF$Alpha) qqline(yourDF$Alpha)
and abundance.
qqnorm(yourDF$Abundance) qqline(yourDF$Abundance)
Normally distributed data plots should look something like Fig. 10.2. Any major deviations from the line suggest non-normality.
We will then test the homogeneity of the variances our data using the Bartlett Test.
bartlett.test(Abundance~Habitat, data = yourDF)
The hypotheses tested by the Bartlett test are:
H0: σ12 = σ22 = ... = σk2 Ha: σi2 ≠ σj2 for at least one pair (i,j).
H0 is rejected if p < 0.05. Fig. 10.2. Q-Q plot of normally distributed data.
4
To perform ANOVA, use the R function aov().
yourmodel1 <- aov(Alpha ~ Habitat, data = yourDF)
summary(yourmodel1)
yourmodel2 <- aov(Abundance ~ Habitat, data = yourDF)
summary(yourmodel2)
4. What are the p-values for each model?
5. Is the null hypothesis rejected for each metric (alpha diversity and abundance)? Why or why not?
Next, we will perform the linear regressions of alpha diversity and abundance based on canopy cover. However, it turns out that R does not like the “%” character in the title of the “Canopy_cover_%” column of the data frame, so let us fix that first. We will do so by making a new column in our data frame with a simplified title “Canopy” and copy the values from the original column. Use this line of code:
yourDF$Canopy <- yourDF$`Canopy_cover_%`
To construct simple linear regression model on the predictor and response variables, use the lm() function. First, construct the model for alpha diversity:
canopyreg1 <- lm(Alpha~Canopy, data = yourDF)
Then show results of the regression using the summary() function.
summary(canopyreg1)
5
6. What are the p-values for the intercept and the predictor (canopy)? Is this model a good fit for the data? Why or why not?
7. What is the linear function of this simple linear regression model?
Now plot the transformed variables and draw a regression line through the data points. Use the following codes:
attach(yourDF)
plot(Canopy, Alpha, xlab = “Canopy cover %”, ylab = “no. of species”)
abline(lm(Alpha~Canopy), col = “red”) #drawing regression line
Save a copy of your plot. Does the regression line look like a good fit?
Repeat the linear model construction and graph plotting for arthropod abundance against canopy cover. Copy the R codes that you used below:
6
References
Engineering Statistics Handbook. Bartlett’s Test. https://www.itl.nist.gov/div898/handbook/eda/section3/eda357.htm
Pardoe, I. 2018. STAT 501 Online course material website. The Pennsylvania State University. https://newonlinecourses.science.psu.edu/stat501/
Quick-R. Assessing Classical Test Assumptions. https://www.statmethods.net/stats/anovaAssumptions.html
Sokal, R. R. and F. J. Rohlf. 1995. Biometry: the principles and practice of statistics in biological research. W. H. Freeman and Company, New York, NY. 887 p.