-
Notifications
You must be signed in to change notification settings - Fork 0
/
05-ET_pupil_prp_lmm.Rmd
60 lines (54 loc) · 1.91 KB
/
05-ET_pupil_prp_lmm.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "02-pupil_size_peak_lmm"
output: html_document
date: "2023-08-22"
---
```{r setup, include=FALSE}
# install all needed packages
pacman::p_load('dplyr', 'ggdist', 'ggeffects', 'ggpubr', 'lme4', 'emmeans', 'rstatix', 'car', 'rsq', 'sjPlot', 'MASS')
library(lme4) # for the analysis
# library(tidyverse) # needed for data manipulation.
library(emmeans)
library(lmerTest)
library(MASS)
```
## Setting the parameters
Setting the parameters. This is where the user can change the parameters if needed
```{r Housekeeping and parameters setting}
rm(list = ls())
bids_root <- getwd()
```
# Experiment 1
## Model RT2 as a function of pupil latency
```{r Loading and transform the data}
# Generate the file name:
full_path = file.path(bids_root, 'bids', 'derivatives', 'pupil_beh_correlation', 'prp', 'pupil_RT2_correlation.csv')
data_exp1 <- read.csv(full_path)
# Remove the targets:
data_exp1 = data_exp1 %>% filter(task != "target")
# Convert the task relevance to a binary variable:
data_exp1 = data_exp1 %>% filter(SOA_lock != "offset")
# Modelling:
model_exp1 <- lmer(formula = RT2 ~ 1 + pupil_latency + (pupil_latency | sub_id),
data = data_exp1)
summary(model_exp1)
# Save to file:
plot(fitted(model_exp1),residuals(model_exp1))
qqnorm(residuals(model_exp1))
```
# Experiment 2
## Model RT2 as a function of pupil latency
```{r Loading and transform the data}
# Generate the file name:
full_path = file.path(bids_root, 'bids', 'derivatives', 'pupil_beh_correlation', 'introspection', 'pupil_RT2_correlation.csv')
data_exp2 <- read.csv(full_path)
# Remove the targets:
data_exp2 = data_exp2 %>% filter(task != "target")
data_exp2 = data_exp2 %>% filter(SOA_lock != "offset")
# Modelling:
model_exp2 <- lmer(formula = RT2 ~ 1 + pupil_latency + (pupil_latency | sub_id),
data = data_exp2)
summary(model_exp2)
plot(fitted(model_exp2),residuals(model_exp2))
qqnorm(residuals(model_exp2))
```