Individual Assignment - Salamander ANOVA
Intro to Quantitative Ecology:
Although this is an individual assignment, I encourage students to work through the analyses together. Your submission, however, will be individual and responses must be in your own words.
You are part of a research team studying populations of Eastern Red-Backed Salamander (Plethodon cinereus) in Massachusetts.
Dave Huth from Allegany County, NY, USA / CC BY
Species description from Salamander Species in Massachusetts page from Mass Audubon:
This small salamander may be the most abundant vertebrate (backboned animal) in the northeast, and it’s found all across the state. It is lungless, and breathes through its moist skin. Despite its name, its color varies; it’s often gray with a red stripe down its back, but it may be entirely red or entirely gray. Its belly is finely speckled with white and gray. Unlike our other salamanders, it spends its entire life on land, and lays its eggs on the moist forest floor. The young skip the typical aquatic stage and emerge as tiny terrestrial salamanders.
Your research team has collected data on salamanders from several populations near vernal pools in the Pioneer Valley in Western Massachusetts.
We are interested in whether salamander snout-to-vent length (SVL) varies by sex and/or site.
You can find the data file mander_anova.csv
on the
course GitHub page. Make sure you save it to your data
subfolder.
Read the data into a data.frame
called sals
using here()
and read.csv()
.
The first few rows of the data look like this:
sals = read.csv(here("data", "mander_anova.csv"))
head(sals)
## Collector Year Season Site SVL Total_length Sex
## 1 Chris 2014 Fall A 36 72 female
## 2 Chris 2014 Fall A 46 83 female
## 3 Chris 2014 Fall A 42 89 female
## 4 Chris 2014 Fall A 34 75 female
## 5 Chris 2014 Fall A 37 80 female
## 6 Chris 2014 Fall A 40 79 female
Site
: there are four sites (P1A
,
P1B
, P2A
, P2B
)Sex
: M
(male) and F
(female)SVL
: the snout-to-vent length in mmYou’ll conduct all analyses in R. You’ll need to do download the data file and start a new R script to store your code for the assignment.
You can use the following code templates to see how Analysis of Variance can be implemented in R. Note that you will need to adjust the code to analyze the variables of interest for this assignment.
Note that while we could use aov()
to output the ANOVA
directly to the console window, it is better to first create a
linear model fit object using lm()
.
The close connection between ANOVA and linear models will become clear later on when we look at linear regression.
I want to know if there is a significant difference between measurements collected by different observers.
First, I’ll make a boxplot:
boxplot(SVL ~ Collector, data = sals)
There seems to be a difference, but I need to do a statistical test to confirm my intuition.
I can use the following syntax to conduct a 1-way ANOVA of total length explained by collector in R:
fit_collector = lm(SVL ~ Collector, data = sals)
anova(fit_collector)
## Analysis of Variance Table
##
## Response: SVL
## Df Sum Sq Mean Sq F value Pr(>F)
## Collector 2 4788.5 2394.24 110.58 < 2.2e-16 ***
## Residuals 270 5846.2 21.65
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
How do you interpret the formula notation above?
I also want to know if salamanders differ by collection site:
boxplot(SVL ~ Site, data = sals)
I can use the following syntax to conduct a 2-way additive ANOVA of total length explained by collector and site in R:
fit2 = lm(SVL ~ Site + Collector, data = sals)
anova(fit2)
## Analysis of Variance Table
##
## Response: SVL
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 3 738.7 246.22 11.541 3.882e-07 ***
## Collector 2 4199.8 2099.88 98.427 < 2.2e-16 ***
## Residuals 267 5696.3 21.33
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
We will conduct three analyses using the salamander data.
Before you begin a formal statistical analysis, make some exploratory plots of your data.
Review the template code I used to build a model of SVL as explained by Site.
lm()
to create a 1-way ANOVA model of SVL as
explained by sex.fit_sex
.Review the template code I used to build a model of SVL as explained by Site.
lm()
to create a 1-way ANOVA model of SVL as
explained by sex.fit_site
.lm()
to create a 2-way ANOVA model of SVL as
explained by site and sex.fit_sex_site
.Create a report that contains plots and answers to the following questions. Save your report as a single pdf document and upload it via the file input box on the Moodle assignment page.
Include your histogram and two boxplots with appropriate titles and axes labels.
Use the results of your analysis of SVL and Sex to answer the following questions:
Use the results of your analysis of SVL and collection site to answer the following questions:
Use the results of your analysis of SVL and sex + collection site to answer the following questions:
The following questions require you to compare the output of all 3 analyses. Assume you are using a significance level of \(p < 0.05\) to determine whether a factor is significant.