---
title: "Assignment: Linear Mixed-Effects Models"
output: html_document
---

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


# Exercise 1

`languageR` library contains `beginningReaders` data set which contains visual lexical decision latencies for beginning readers (8 year-old Dutch children). You can read more about the data set in documentation of the `languageR` library using `?beginningReaders` command. 

Load the data into you R environment. Then **identify** outliers (using Q-Q plots or some other technique) and **remove** them from the data set. Then **describe** your method and the results of its application (how many observations were removed, did it improve the distributions, etc.).

You can use:
- three standard deviations method (not recommended), 
- Tukey's method (sometimes called "Tukey's Fence")
- some other, more sophisticated technique (look it up!)

Remember, that when you try to identify outliers, you should think about each individual subject separately. If you just delete particularly high or low latencies, you will probably delete valid observations from some particularly quick/slow participant!

```{r}
# Your code here
```

*Your answer here*

# Exercise 2

**Fit** a linear mixed-effects model to the data. Your main goal is to investigate:
- fatigue/familiarization effects 
- whether the effect of trial number is moderated by reading proficiency.

Take into account two linguistic covariates - frequency of the word and its length. Following the standard practice, include in the model random effects for Subject and Word. **Describe** and **interpret** the results.

```{r}
# Your code here
```

*Your answer here*

# Exercise 3 

Which words have largest adjustments to the grand intercept (let's say top 10)? Prepare a table and print it using `kable`, `pander`, `flextable` or other library designed to produce formatted tables.

```{r}
# Your code here
```

*Your answer here*

# Exercise 4

Check whether inclusion of random intercept for each word is justified by better fit of the model. **Describe** and **interpret** the results of the appropriate test.

```{r}
# Your code here
```

*Your answer here*