---
title: "Two-way ANOVA"
author: "Emma Rand"
output:
  html_document:
    depth: 3
    highlight: pygments
    theme: lumen
    toc: yes
    toc_float:
      collapsed: no
      smooth_scroll: no
  pdf_document:
    toc: yes
  word_document: default
bibliography: "../refs/references.bib"
---

![](../../pics/06C.png)

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
                      message = FALSE,
                      warning = FALSE)
```

# Introduction

## Aims

In this practical you will learn how to run, in R, a two-way ANOVA, interpret the output and report the results including figures. You will also learn how you can read data from a different file format.


## Learning Outcomes 

By actively following the lecture and practical and carrying out the independent study the successful student will be able to:

* Explain the rationale behind ANOVA and complete a partially filled ANOVA table (MLO 1 and 4)
* Read in data formatted for other statistical packages (MLO 3)
* Apply (appropriately), interpret and evaluate the legitimacy of, two-way ANOVA in R (MLO 2, 3 and 4)
* Explain the meaning of a significant interaction (MLO 4)
* Summarise and illustrate with appropriate figures test results scientifically (MLO 3 and 4)
* Use RStudio projects (MLO 4)


## Philosophy

Workshops are not a test. It is expected that you often don't know how to start, make a lot of mistakes and need help.
Do not be put off and don't let what you can not do interfere with what you can do. You will benefit from collaborating with others and/or discussing your results.

The lectures and the workshops are [closely integrated](../BIO00017C.html) and it is expected that you are familar with the lecture content before the workshop. You need not understand every detail as the workshop should build and consolidate your understanding. You may wish to refer to the slides as you work through the workshop schedule.

## Slides

Two-way ANOVA: [pdf](../lects/web08Two way ANOVA.pdf) (recommended) / [pptx](../lects/web08Two way ANOVA.pptx)

# Exercises

![W](../../pics/W.png) Start RStudio from the [Start menu](../../pics/startmenu.png).

## Using RStudio projects

An [RStudio project](https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects) is associated with a directory (folder). 

You create a new project with File | New Project...

When a new project is created RStudio:

1. Creates a project file (with an .Rproj extension) within the project directory. This file contains various project options.  
2. Creates a hidden directory (named .Rproj.user) where project-specific temporary files (e.g. auto-saved source documents, window-state, etc.) are stored.  
3. Loads the project into RStudio and display its name in the Projects toolbar (far right on the menu bar).

Using a project helps you manage file paths. The working directory is the project directory (i.e., the location of the .Rproj file).

You can open a project with:

1. File | Open Project or  File | Recent Projects  
2. Double-clicking the  .Rproj file  
3. Using the option on the far right of the tool bar  

When you open project, a new R session starts and various settings are restored to their condition when the project was closed.

We are going to create an RStudio project to carry out the analysis of the Periwinkle data(below).

![R](../../pics/R.png) Make a new project with File | New Project and chose New directory and then New project. Be purposeful about where you create it by using the Browse button. I suggest using your 17C folder. Give the Project (directory) a name, perhaps "periwinkle_workshop7"

![R](../../pics/R.png) Make a new folder 'raw_data' where you will later save the original data file.

![R](../../pics/R.png) Make a new folder 'processed_data' where you will later save the processed data file.

![R](../../pics/R.png) Make a new folder 'figures' where you will later save your figures.

Reading [Chapter 2 Project-oriented workflow](https://whattheyforgot.org/project-oriented-workflow.html) of What they forgot to teach you about R [@Bryan-Hester].

![R](../../pics/R.png) Make a [new script](../../pics/newscript.png) file called workshop7.R to carry out the rest of the work.


## Load packages

![R](../../pics/R.png) You probably want to load the `tidyverse` with `library(tidyverse)`.
```{r echo=FALSE, results='hide'}
library(tidyverse)
```

## Parasites on two species of periwinkle 

This example is about the effect of season on the parasite load of two species of periwinkle. 

![photo of periwinkles](../../pics/littorina.jpg)

A group of amateur conchologists have collected live specimens of two species of rough periwinkle (intertidal, gastropod molluscs) from sites in northern England in the Spring (1) and Summer (2). Among other variables, they take a measure of the gut parasite load.  Number of parasites is related to the number of parasites seen on a slide of gut contents and larger numbers indicate a higher parasite load. The data are in SPSS file called [periwinkle.sav](../data/periwinkle.sav). SPSS is a well known commercial statistical package.

There are several R packages that allow to read in data in different file formats. My personal favourite is `haven`. If you are working on your own pc you will need to install it, but it is already installed on the university system.

![R](../../pics/R.png) Load `haven` with a library statement
```{r load-haven, include=FALSE}
library(haven)
```

Now we can read the SPSS file in using one of the functions from `haven`. Look it up in the manual `?read_sav`

![R](../../pics/R.png) Save a copy of [periwinkle.sav](../data/periwinkle.sav) to you `raw_data` folder and import it with `read_sav()`:
```{r importperi, include=FALSE}
periwinkle <- read_sav("../data/periwinkle.sav")
```

```{r eval=FALSE}
periwinkle <- read_sav("raw_data/periwinkle.sav")
```

```{r}
glimpse(periwinkle)
```

The values used in the SPSS file were labelled integers and the `read_sav()` has made them objects of type "haven_labelled". You can see this with `str(periwinkle$season)`

![R](../../pics/R.png) The labels of these can be viewed in R using:
```{r}
attr(periwinkle$season, "labels")
attr(periwinkle$species, "labels")
```

![R](../../pics/R.png) And the "haven_labelled" type of variables can be made factors using:

```{r}
periwinkle <- periwinkle %>% 
  mutate(season = as_factor(season),
         species = as_factor(species))
```

This will replace those integers with the actual labels which will make your analysis and plots easier to understand.

It's often a good idea to save a copy of your processed and now analysis-ready data. We save write to files using `write.table()`

![R](../../pics/R.png) Write the dataframe to a plain text format file in your `processed_data` folder:
```{r eval=FALSE}
write.table(periwinkle, "processed_data/periwinkle.txt")
```

### Exploring

![Q](../../pics/Q.png) What type of variable is 'para'? What are the implications for the test? 
<!--
#---THINKING ANSWER---
it's discrete. ANOVA assumes data are normally distributed so you might feel that it is not appropriate to use ANOVA here. However, there is no easily available non-parametric equivalent for this design. In addition, there are a large number of possible values, and the difference between each value relative to the range is small so we can reasonably treat the data as continuous. 
-->

![Q](../../pics/Q.png) Do a quick plot of the data. We have two explanatory variables so whilst one can be mapped to the *x*-axis as was the case for *t*-test and ANOVA scenarios, the other needs to be mapped to the 'colour' or 'fill' aesthetics.


```{r}
ggplot(data = periwinkle, aes(x = season, y = para, fill = species)) +
  geom_boxplot()
```


![R](../../pics/R.png) Calculate summary statistics on parasite for each species-season combination. You've calculated summary statistics on a response for a single explanatory before. Adding an additional explanatory variable is straightforward with the `group_by()` function. We just add the additional variable to the function:

```{r perisum}
perisum <- periwinkle %>% 
  group_by(season, species) %>% 
  summarise(mean = mean(para),
            median = median(para),
            sd = sd(para),
            n = length(para),
            se = sd / sqrt(n))

```
Make sure you have assigned the output as you will need it later for plotting.

Our plotting and summarising exploration gives us an idea of what we expect to find on statistical analysis.

![Q](../../pics/Q.png) What three effects can we test with these data using a two-way ANOVA?
<!--
#---THINKING ANSWER---
There are three null hypotheses: 
1. there is no effect of species (i.e., no difference between species on average)
2. there is no effect of season (i.e., no difference between seasons on average) 
3. the effect of season is the same for both species (i.e., season and species act independently). 
-->

### Applying, interpreting and reporting

We now carry out a two-way ANOVA assigning the result of the `aov()` procedure to a variable and examining it with `summary()`.
We put a * between the predictors ('independent' or 'grouping' variables) to indicate we want to consider both factors AND the interaction.

![R](../../pics/R.png) Create the ANOVA model with both main effects and the interaction:
```{r anovatestperi}
mod <- aov(data = periwinkle, para ~ season * species)
summary(mod)
```
  
![Q](../../pics/Q.png) What do you conclude so far from the test? 
<!--
#---THINKING ANSWER---
 There was a significantly greater number of parasites in the Summer than the Spring (ANOVA: F = 25.6; d.f. = 1,96; p < 0.001). There is no difference between the species when averaged across the season but there was significant interaction (F = 6.1; d.f. = 1,96; p = 0.016) between season and species with higher numbers infecting L.nigrolineata in the Spring whilst L.saxatilis was more heavily parasitized in the Summer. . 
 -->

We have significant effects but which means differ? We need a post-hoc test. A post-hoc ("after this") test is done after (and only after) a significant ANOVA test. The ANOVA tells you at least two of means differ, the post-hoc test tells you where the differences are. There are several possible post-hoc tests. A popular option is the Tukey Honest Significant Difference test.

![R](../../pics/R.png) Carry out a Tukey HSD with:

```{r posthoc}
TukeyHSD(mod)
```

We have three bits of output, eaching corresponding to the three null hypotheses. There is a siginificant difference between the season with a difference between the means of 11.1 parasites.We then have significant comparions between: Spring and Summer for *L. saxatilis*; *L.nigrolineata* in the Summer and *L.saxatilis* in the Spring; *L.nigrolineata* in Spring and *L.saxatilis* in Summer.



### Checking selection

![R](../../pics/R.png) Check the assumptions of the test by looking at the distribution of the 'residuals'.
```{r assumptionperi, include=FALSE}
#---CODING AND THINKING ANSWER---
plot(mod, which = 1)
hist(mod$residuals)
shapiro.test(mod$residuals)
#These look ok
```


### Illustrating

Producing a figure to go with this result using ggplot2.
We will again need the means and standard errors calculated earlier and stored in `perisum`

We are going to create a figure like this:

```{r echo=FALSE, fig.height=5, fig.width=6}

ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para, shape = species),
             position = position_jitterdodge(dodge.width = 1, jitter.width = 0.4, jitter.height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se, group = species),
                width = 0.4, position = position_dodge(width = 1)) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean, group = species),
                width = 0.3, position = position_dodge(width = 1) ) +
  ylab("Number of parasites") +
  ylim(0, 125) +
  xlab("Season") +
  theme_classic() +
  theme(legend.title = element_blank())

  
```

Figure 1. The effect of season on the parasite load in two species of periwinkle. Thick lines give the means and error bars are $\pm$ 1 S.E. 


We will plot the means and error bars. Look this up in the [Oneway ANOVA workshop](06One-wayAnovaAndKW.html#illustrating). 

![R](../../pics/R.png)  Let's try doing the same here

```{r fig.height=5, fig.width=5}

ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para),
             position = position_jitter(width = 0.1, height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se),
                width = 0.4, size = 1) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean),
                width = 0.3, size = 1 )

  
```

How can we show the species separately? 

![R](../../pics/R.png)  We can map the species variable to the shape aesthetic!
```{r fig.height=5, fig.width=6}

ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para, shape = species),
             position = position_jitter(width = 0.1, height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se),
                width = 0.4, size = 1) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean),
                width = 0.3, size = 1)
  
```

Oh, that isn't quite what we want! We want the species side-by-side, not on top of each other.

![R](../../pics/R.png)  We can achieve that by using setting the `position` argument  `position_jitterdodge()` in the `geom_point()` and to `position_dodge()` in the two `geom_errorbar()`. We also have to specify that the error bars are grouped by species since they are not otherwise mapped to a shape, colour or fill.

```{r fig.height=5, fig.width=6}
ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para, shape = species),
             position = position_jitterdodge(dodge.width = 1, 
                                             jitter.width = 0.4, 
                                             jitter.height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se, group = species),
                width = 0.4, size = 1,
                position = position_dodge(1)) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean, group = species),
                width = 0.3, size = 1, 
                position = position_dodge(1))

  
```


![R](../../pics/R.png) Finally we add axis labels, specify the *y*-axis limits and add `theme_classic()`. I've also altered the legend position.


```{r fig.height=5, fig.width=6}

ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para, shape = species),
             position = position_jitterdodge(dodge.width = 1,
                                             jitter.width = 0.4,
                                             jitter.height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se, group = species),
                width = 0.4, size = 1,
                position = position_dodge(width = 1)) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean, group = species),
                width = 0.3, size = 1,
                position = position_dodge(width = 1) ) +
  ylab("Number of parasites") +
  ylim(0, 125) +
  xlab("Season") +
  theme_classic() +
  theme(legend.title = element_blank(),
        legend.position = c(0.2, 0.2))

  
```

We are nearly there!

![R](../../pics/R.png) Now you add the annotation for the post-hoc result. You may want to look up [last week's workshop](06One-wayAnovaAndKW.html).

```{r include = FALSE, results = 'hide', fig.height=5, fig.width=6}

# the signifcant comparisons are                           p adj
# Summer:Littorina saxatilis-Spring:Littorina saxatilis    0.0000041
# Summer:Littorina nigrolineata-Spring:Littorina saxatilis 0.0003558
# Spring:Littorina nigrolineata-Summer:Littorina saxatilis 0.0198124
perfig <- ggplot() +
  geom_point(data = periwinkle, aes(x = season, y = para, shape = species),
             position = position_jitterdodge(dodge.width = 1,
                                             jitter.width = 0.4,
                                             jitter.height = 0),
             colour = "gray50") +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean - se, ymax = mean + se, group = species),
                width = 0.4, size = 1,
                position = position_dodge(width = 1)) +
  geom_errorbar(data = perisum, 
                aes(x = season, ymin = mean, ymax = mean, group = species),
                width = 0.3, size = 1,
                position = position_dodge(width = 1) ) +
  ylab("Number of parasites") +
  ylim(0, 125) +
  xlab("Season") +
  # Spring:Littorina nigrolineata-Summer:Littorina saxatilis *
  annotate("segment", 
           x = 1.25, xend = 1.75, 
           y = 110, yend = 110,
           colour = "black") +
  annotate("segment", 
           x = 1.25, xend = 1.25,
           y = 110, yend = 105,
           colour = "black") +
  annotate("segment", 
           x = 1.75, xend = 1.75,
           y = 110, yend = 105,
           colour = "black") +
  annotate("text", 
           x = 1.5,  y = 112,
           label = "***", size = 6) +
  # Summer:Littorina nigrolineata-Spring:Littorina saxatilis: ***
  annotate("segment", 
           x = 1.25, xend = 0.75,
           y = 90, yend = 90,
           colour = "black") +
  annotate("segment", 
           x = 1.25, xend = 1.25,
           y = 90, yend = 85,
           colour = "black") +
  annotate("segment", 
           x = 0.75, xend = 0.75,
           y = 90, yend = 85,
           colour = "black") +
  annotate("text", x = 1,  y = 92,
           label = "**", size = 6) +
# Summer:Littorina saxatilis-Spring:Littorina saxatilis: ***
  annotate("segment",
           x = 0.75, xend = 1.75,
           y = 120, yend = 120,
           colour = "black") +
  annotate("segment",
           x = 0.75, xend = 0.75,
           y = 120, yend = 115,
           colour = "black") +
  annotate("segment",
           x = 1.75, xend = 1.75,
           y = 120, yend = 115,
           colour = "black") +
  annotate("text", x = 1.25,  y = 123,
           label = "***", size = 6) +
  theme_classic() +
  theme(legend.title = element_blank(),
        legend.position = c(0.2, 0.2))
```

![R](../../pics/R.png) Use `ggsave()` to save your figure to file. You can use what ever format you prefer (png, jpg, tiff eps). You may want to look up [last week's workshop](06One-wayAnovaAndKW.html).

```{r echo = FALSE}
# you will need figures/periwinkle.tif to save in your figures directory
ggsave("periwinkle.tif",
       plot = perfig,
       device = "tiff",
       width = 5,
       height = 4,
       units = "in",
       dpi = 300)
# or
ggsave("periwinkle.png",
       plot = perfig,
       width = 5,
       height = 4,
       units = "in",
       dpi = 300)

```



# Independent study

## Analysis

### Fertilising a crop with Nitrogen and Potassium

The STATA file [yield.dta](../data/yield.dta) contains data from a two-factor design in which crop yield (in kilograms) was determined from plots treated with low and high levels of nitrogen and low and high levels of potassium. Analyse these data as you see fit and write up the results including some appropriate figures and/or tables. You will need to:

* use an RStudio project to organise the analysis and create appropriate folders for the data and figures.
* read in the data
* make any changes needed to analyse the data
* graphically explore and summarise the data
* carry out an analysis
* check the validity of the analysis
* report the results including a figure
* give a conclusion about the effect of the two fertilisers on growth


![](../../pics/nk.png)




```{r, include=FALSE, results='hide'}
#---CODING AND THINKING ANSWER---

# import the data using the haven package
yield <- read_dta("../data/yield.dta")
str(yield)

# make explanatory variables factors 
# I've renamed them as nitrogen and potassium too
yield <- yield %>% 
  mutate(n = as_factor(n),
         k = as_factor(k)) %>% 
  rename(Nitrogen = n,
         Potassium = k)


#looking at the dataset there doesn't seem to be anything very obviously non-normal (lots of values the same, too many zeros, or extreme values)
#we will check the assumptions after we have run the anova

# Do a rough plot of the data
ggplot(data = yield, aes(x = Nitrogen, y = kg, fill = Potassium)) +
  geom_boxplot()



#a summary of the data (means and se) is useful both to help us understand the data and for plotting later
yieldsum <- yield %>% 
  group_by(Nitrogen, Potassium) %>% 
  summarise(mean = mean(kg),
            median = median(kg),
            sd = sd(kg),
            n = length(kg),
            se = sd/sqrt(n))
# # A tibble: 4 x 7
# # Groups:   Nitrogen [2]
#   Nitrogen Potassium  mean median    sd     n    se
#   <fct>    <fct>     <dbl>  <dbl> <dbl> <int> <dbl>
# 1 low      low        9.72   9.93  4.29    10  1.36
# 2 low      high      16.5   16.0   5.26    10  1.66
# 3 high     low       15.6   16.4   3.74    10  1.18
# 4 high     high      21.0   21.8   3.75    10  1.19


# build the anova model
mod <- aov(data = yield, kg ~ Nitrogen * Potassium)
summary(mod)

#                    Df Sum Sq Mean Sq F value   Pr(>F)    
# Nitrogen            1  273.2   273.2  14.741  0.00048 ***
# Potassium           1  369.7   369.7  19.945 7.58e-05 ***
# Nitrogen:Potassium  1    4.3     4.3   0.232  0.63283    
# Residuals          36  667.2    18.5   
 # There was a significantly greater yield at high nitrogen than at low nitrogen (ANOVA: F = 14.7; d.f. = 1,36; p < 0.001) and at high potassium than at low potassium (F = 19.9; d.f. = 1,36; p < 0.001). These effects were independent.

# check the assumptions
plot(mod, which = 1)
hist(mod$residuals)
shapiro.test(mod$residuals)
# the variance is a bit lower in the group with the highest mean
# and the histogram has a bit of bumpat the low end but it looks ok

 
# it is questionable whether we really need a post-hoc test as
# the effect of nitorgen must be between high and low and the 
# effect of potassium must be between high and low (there are only two
# categories in each explanatory) and there is no interaction.
# However, lets do one any way
TukeyHSD(mod) 

# $`Nitrogen:Potassium`
#                      diff        lwr       upr     p adj
# high:low-low:low    5.883  0.6976609 11.068339 0.0209708
# low:high-low:low    6.736  1.5506609 11.921339 0.0066292
# high:high-low:low  11.307  6.1216609 16.492339 0.0000060
# low:high-high:low   0.853 -4.3323391  6.038339 0.9705373
# high:high-high:low  5.424  0.2386609 10.609339 0.0374574
# high:high-low:high  4.571 -0.6143391  9.756339 0.1004742
# All means differ except
#   low N:high K - high N:low K  p = 0.9705373 (red and blue boxes in the middle)
#   high N:high K - low N:high K p = 0.1004742 (the two blue boxes).
# In this situation, I might label those means that do NOT differ with the same letter code
# rather than adding a lot of lines indicating significance.

# figure
ggplot() +
  geom_point(data = yield, aes(x = Nitrogen, y = kg, shape = Potassium),
             position = position_jitterdodge(dodge.width = 1,
                                             jitter.width = 0.4,
                                             jitter.height = 0),
             colour = "gray50", size = 2) +
  geom_errorbar(data = yieldsum, 
                aes(x = Nitrogen, ymin = mean - se, ymax = mean + se, group = Potassium),
                width = 0.4, size = 1,
                position = position_dodge(width = 1)) +
  geom_errorbar(data = yieldsum, 
                aes(x = Nitrogen, ymin = mean, ymax = mean, group = Potassium),
                width = 0.3, size = 1,
                position = position_dodge(width = 1) ) +
  ylab("Yield (kg)") +
  ylim(0, 30) +
  annotate("text", x = 1.25,  y = 5,
           label = "a", size = 5) +
  annotate("text", x = 1.75,  y = 5,
           label = "a", size = 5) +
  annotate("text", x = 1.25,  y = 3,
           label = "b", size = 5) +
  annotate("text", x = 2.25,  y = 3,
           label = "b", size = 5) +
  theme_classic() +
  theme(legend.position = c(0.1, 0.9))

```

## Reading

[Chapter 2 Project-oriented workflow](https://whattheyforgot.org/project-oriented-workflow.html) of What they forgot to teach you about R [@Bryan-Hester].


# The Code files

These contain answers and code even though they do not appear on the webpage itself.

[Rmd file](07Two-wayAnova.Rmd)
The Rmd file is the file I use to compile the practical. Rmd stands for R markdown allow R code and ordinary text to be inter weaved to produce well-formatted reports including webpages.

[Plain script file](../scripts/07Two-wayAnova.R)
This is plain script (.R) version of the practical


# Script example
This is an example of a well formatted analysis script for one of the independent study problems.

[Script example](../scripts/exampleprac7.R)


# Objectives from previous sessions

[Introduction to module and RStudio](01IntroductionToModuleAndRStudio.html)

* to explain why we need statistical tests and the logic of hypothesis testing (MLO 1)
* use the R command line as a calculator and to assign variables (MLO 3)
* create and use the basic data types in R (MLO 3)
* find their way around the RStudio windows (MLO 3)
* create, use and save a script file to run r commands (MLO 3)
* search and understand manual pages (MLO 3)

[Testing, Data types and reading in data](02TestingDataTypesReadingInData.html)

* to able to explain what response and explanatory variables are, distinguish between data types and describe how these impact choice of test (MLO 1 and 2)
* demonstrate the process of hypothesis testing with an example and evaluate potential inferences (MLO 1 and 2)
* read in data in to RStudio, create simple summaries and plots using manual pages where necessary (MLO 3)
* create neat reports in Word which include text and figures (MLO 4)

[Goodness of Fit and Contingency chi-squared tests](03ChiSquaredTests.html)

* recognise when to use chi-squared Goodness of Fit and Contingency tests (MLO 2)
* be able to carry out, interpret and report scientifically both types of test by hand and in R (MLO 3 and 4)

[Calculating summary statistics, probabilities and confidence intervals](04CalculatingSummaryStatisticsProbabilitiesAndCI.html)

* Explain the properties of 'normal distributions' and their use in statistics (MLO 1 and 2)
* Define, select and calculate with R probabilities, quantiles and confidence intervals (MLO 3 and 4)

[One- and two- sample tests](05OneAndTwoSampleTests.html)

* Explain dependent and independent samples (MLO 2)
* Select, appropriately, t-tests and their non-parametric equivalents (MLO 2)
* Apply, interpret and evaluate the legitimacy of  the tests in R (MLO 3 and 4)
* Summarise and illustrate with appropriate R figures test results scientifically (MLO 3 and 4)

[One-way ANOVA and Kruskal-Wallis](06One-wayAnovaAndKW.html)

* Explain the rationale behind ANOVA and complete a partially filled ANOVA table (MLO 1 and 2)
* Apply (appropriately), interpret and evaluate  the legitimacy of, one-way ANOVA and Kruskal-Wallis including post-hoc tests in R (MLO 2, 3 and 4)
* Summarise and illustrate with appropriate R figures test results scientifically (MLO 3 and 4)


![](../../pics/06Cend.png)

# References
