---
title: "Statistics - rMA Thesis"
author: "Eugenio Palombella"
date: "13/7/2020"
output: html_document
---

```{r}
table <- read.delim("data/restable.txt", stringsAsFactors=T)
table
```

```{r}
levels (table$condition)   # condition to which participants were exposed
```

```{r}
contrast <- cbind (c(-1/2, +1/2))
colnames (contrast) <- c("-A+B")
contrasts (table$condition) <- contrast
contrast
```

```{r}
levels (table$age)   # age of the speakers
```

```{r}
contrast <- cbind (c(-1/2, +1/2))
colnames (contrast) <- c("-O+Y")
contrasts (table$age) <- contrast
contrast
```

```{r}
library (lmerTest)
modelpal <- lmer (palscore ~ age * condition  + (1 | participant), data = table, REML = TRUE)
summary (modelpal)
```

```{r}
coefficients <- coef (summary(modelpal))
coefficients
```

```{r}
confint (modelpal)
```

```{r}
library (lmerTest)
modelret <- lmer (retscore ~ age * condition  + (1 | participant), data = table, REML = TRUE)
summary (modelret)
```

```{r}
coefficients <- coef (summary(modelret))
coefficients
```

```{r}
confint (modelret)
```