Skip to content
Snippets Groups Projects
Commit 86c52dc5 authored by Xianzong Meng's avatar Xianzong Meng
Browse files

Merge branch 'main' of https://gitlab.socsci.ru.nl/preclinical-neuroimaging/robotmod

# Conflicts:
#	codes/stasitic.Rmd
parents f61097a3 b86c3dab
No related branches found
No related tags found
No related merge requests found
## packages loading
```{r}
#General utility packages
library(tidyverse)
library(glue)
library(knitr)
library(data.table)
#Stats packages
library(lme4)
library(multcomp)
library(parameters)
library(effectsize)
library(performance)
library(emmeans)
#Plot packages
library(ggpubr)
```
## loading table
```{r}
df <- read_csv('C:/Users/xiamen/Desktop/data_for_R/modified_robogator_paper/robotmod_distance.csv') %>%
mutate(trials = as.factor(trials)) %>%
mutate(group = as.factor(group)) %>%
mutate(sex = as.factor(sex)) %>%
mutate(rat_ID = as.factor(rat_ID)) %>%
mutate(restriction = as.factor(restriction))%>%
mutate(age = as.factor(age))%>%
mutate(food.distance.cm = as.factor(food.distance.cm))%>%
mutate(robot = as.factor(robot))%>%
# Create score based on time. Following log attribution of score as a function of time.
mutate(leaving.score = case_when(is.na(leaving.sec) ~ 7,
leaving.sec >= 200 ~ 6,
leaving.sec >= 100 ~ 5,
leaving.sec >= 50 ~ 4,
leaving.sec >= 25 ~ 3,
leaving.sec >= 12.5 ~ 2,
leaving.sec >= 6.25 ~ 1,
leaving.sec <6.25 ~ 0)) %>%
mutate(approaching.score = case_when(is.na(approaching.sec) ~ 7,
approaching.sec >= 200 ~ 6,
approaching.sec >= 100 ~ 5,
approaching.sec >= 50 ~ 4,
approaching.sec >= 25 ~ 3,
approaching.sec >= 12.5 ~ 2,
approaching.sec >= 6.25 ~ 1,
approaching.sec <6.25 ~ 0)) %>%
mutate(backing.score = case_when(is.na(backing.sec) ~ 7,
backing.sec >= 200 ~ 6,
backing.sec >= 100 ~ 5,
backing.sec >= 50 ~ 4,
backing.sec >= 25 ~ 3,
backing.sec >= 12.5 ~ 2,
backing.sec >= 6.25 ~ 1,
backing.sec <6.25 ~ 0)) %>%
mutate(foraging.score = case_when(is.na(foraging.sec) ~ 7,
foraging.sec >= 200 ~ 6,
foraging.sec >= 100 ~ 5,
foraging.sec >= 50 ~ 4,
foraging.sec >= 25 ~ 3,
foraging.sec >= 12.5 ~ 2,
foraging.sec >= 6.25 ~ 1,
foraging.sec <6.25 ~ 0))
#head(df) %>% kable("pipe")
```
## distance effect
```{r}
df.Bline <- df %>% filter(df$baseline.day == 6)
df.Rday <- df %>% filter(df$robot.day == 1)
```
## liner mixed effect model
```{r}
robot <- lmer(foraging.score~ sex + trials + robot + sex:trials + sex:robot + trials:robot + (1|rat_ID), df)
robot_sex_trials <- update(robot, . ~ . - sex:trials)
robot_sex_robot <- update(robot, . ~ . - sex:robot)
robot_trials_robot <- update(robot, . ~ . - trials:robot)
robot_robot <- lmer(foraging.score~ sex + trials + sex:trials + (1|rat_ID), df)
anova(robot, robot_robot)
eta_squared(robot)
```
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment