Intro to Quantitative Ecology:
Group Assignment - Penguins: Tests for Differences
In your group, you’ll conduct some tests for differences using the penguin dataset.
palmerpenguins
package.Check out the template code below if you need help getting started.
I can use the t.test()
function to conduct a simple
two-tailed test for the hypothesis that penguin body mass is different
between male and female penguins. Note the use of the alternative
argument.
t.test(body_mass_g ~ sex, data = penguins, alternative = "two.sided")
##
## Welch Two Sample t-test
##
## data: body_mass_g by sex
## t = -8.5545, df = 323.9, p-value = 4.794e-16
## alternative hypothesis: true difference in means between group female and group male is not equal to 0
## 95 percent confidence interval:
## -840.5783 -526.2453
## sample estimates:
## mean in group female mean in group male
## 3862.273 4545.685
If I want to test the hypothesis that female penguins weighed less, I could use:
t.test(body_mass_g ~ sex, data = penguins, alternative = "less")
##
## Welch Two Sample t-test
##
## data: body_mass_g by sex
## t = -8.5545, df = 323.9, p-value = 2.397e-16
## alternative hypothesis: true difference in means between group female and group male is less than 0
## 95 percent confidence interval:
## -Inf -551.6295
## sample estimates:
## mean in group female mean in group male
## 3862.273 4545.685
As an example, I could also use ANOVA to test the alternative hypothesis that penguins observed on different islands have different bill lengths:
lm()
.anova()
with my fitted model to produce the
ANOVA table.fit_bill_island = lm(bill_length_mm ~ island, data = penguins)
anova(fit_bill_island)
## Analysis of Variance Table
##
## Response: bill_length_mm
## Df Sum Sq Mean Sq F value Pr(>F)
## island 2 1565.6 782.80 30.862 4.86e-13 ***
## Residuals 339 8598.6 25.36
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The example is for bill length and island, but you need to conduct an analysis on the alternative hypothesis that penguin bill length differs by penguin species.
Compile your answers to the following into a single document and upload to the file input box on Moodle.