# Analyzing Grouped Data

In this unit, you will learn classical statistical tests and how to compare means between groups.

Follow the links to each lecture, lab, and reading.

Scroll down to download the SWIRL lessons.

## Lesson 1. How to choose a statistical test

Lectures:

Which test? Which assumptions?

Formulae

Learning Goals:

- Understand the different arrangements and distributions of data,
- Understand what tests are appropriate for what questions and data,
- Test assumptions such as normality, homogeneity of variance, outliers,
- Plot data to examine distributions.

SWIRL: Testing assumptions and exploring data

Lab: Unit 3: Lab 1

Readings:

Zuur et al. 2010. A protocol for data exploration to avoid common statistical problems. *Methods in Ecology & Evolution* 1, 3–14.

Läärä, E. 2009. Statistics: reasoning on uncertainty, and the insignificance of testing null. *Ann. Zool. Fennici* 46: 138–157.

Functions: `qqplot()`

, `ks.test()`

, `shapiro.test()`

, `bartlett.test()`

## Lesson 2. How to compare counts between groups

Lecture: Testing ratios and tabulating data

Learning Goals:

- Use of
`table()`

and `hist()`

,
- Convert continuous data to groups,
- Run simple sign, proportion, binomial, and Chi-square tests.

SWIRL: Testing Ratios

Lab: Unit 3: Lab 2

Reading:

Functions: `table()`

, `prop.test()`

, `binom.test()`

, `chisq.test()`

## Lesson 3. How to calculate group-level stats in dataframes

Lecture: The Split-Apply-Combine approach

Learning Goals:

- Understand and use
`tapply()`

, `sapply()`

, `lapply()`

, `apply()`

.
- Calculate and plot group-level means and sd.

SWIRL: The *apply() group of functions:

Lab: Unit 3: Lab 3

Reading: Wickham, H. 2001. The Split-Apply-Combine Strategy for Data Analysis. *Journal of Statistical Software* 40.

- (This paper describes the idea and principles, but also a specific R package (plyr) that we do not cover).

Functions: `apply()`

, `tapply()`

, `sapply()`

, `lapply()`

## Lesson 4. How to compare means from different groups or populations

Lecture: t-tests and ANOVAS

Best Practice: Writing

Learning Goals:

- Run t-tests and ANOVAs,
- Test assumptions of normality, homogeneity of variance
- Extract details from model output,
- Plot these data with boxplots and barplots.

SWIRL: Testing Populations

Lab: Unit 3: Recap

Reading:

Functions: `t.test()`

, `aov()`

,

Updated: 2018-10-01