Skip to content
Snippets Groups Projects
Commit 1aa40d6c authored by Xianzong (Alex) Meng's avatar Xianzong (Alex) Meng
Browse files

contrast at individual postion, cohen'd calculation based on estimatite_contrasts

parent 447a3704
Branches main
No related tags found
No related merge requests found
......@@ -127,6 +127,17 @@ df.SD_Rday1 <- df %>% filter(df$robot.day == 1, df$group == "SD")
SD_foraging <- lmer(foraging.score~ sex + trials + age + sex:trials + sex:age + trials:age + (1|rat_ID), df.SD_Rday1)
eta_squared(SD_foraging)
```
## contrast at individual postion
```{r}
library(modelbased)
estimate_contrasts(SD_foraging, contrast = "trials:age")
t_to_d( -3.46,64.47)
t_to_d( -3.68,64.47)
t_to_d( -3.24,64.47)
t_to_d( -3.35,64.47)
t_to_d( -3.57,64.47)
```
## age effect plot, fig 1a 1b
```{r}
......@@ -151,9 +162,44 @@ ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig1a_1b.svg', pl
## restriciton effect, (data: LE rat, 45%/60% restrction, foraging, Rday1)
```{r}
library(modelbased)
df.LE_Rday1 <- df %>% filter(df$robot.day == 1, df$group == "LE")
LE_foraging <- lmer(foraging.score~ sex + trials + restriction + sex:trials + sex:restriction + trials:restriction + (1|rat_ID), df.LE_Rday1)
eta_squared(LE_foraging)
estimate_contrasts(LE_foraging, contrast = "trials:restriction")
#put relevant t value and df from the table to get cohen's d and 95% CI
t_to_d( -2.45,76.61)
t_to_d( -2.45,76.61)
t_to_d( -2.45,76.61)
t_to_d( -2.70,76.61)
t_to_d( -0.13,76.61)
```
```{r}
df.LE_Rday1 <- df %>% filter(df$robot.day == 1, df$group == "LE")
LE_foraging <- lmer(foraging.score~ sex + trials + restriction + sex:trials + sex:restriction + trials:restriction + (1|rat_ID), df.LE_Rday1)
eta_squared(LE_foraging)
df.LE_Rday1_1 <- df %>% filter(df$robot.day == 1, df$group == "LE", df$trials == "1")
df.LE_Rday1_2 <- df %>% filter(df$robot.day == 1, df$group == "LE", df$trials == "2")
df.LE_Rday1_3 <- df %>% filter(df$robot.day == 1, df$group == "LE", df$trials == "3")
df.LE_Rday1_4 <- df %>% filter(df$robot.day == 1, df$group == "LE", df$trials == "4")
df.LE_Rday1_5 <- df %>% filter(df$robot.day == 1, df$group == "LE", df$trials == "5")
LE_foraging_1 <- aov(foraging.score ~ restriction + sex + restriction:sex, data = df.LE_Rday1_1)
LE_foraging_2 <- aov(foraging.score ~ restriction + sex + restriction:sex, data = df.LE_Rday1_2)
LE_foraging_3 <- aov(foraging.score ~ restriction + sex + restriction:sex, data = df.LE_Rday1_3)
LE_foraging_4 <- aov(foraging.score ~ restriction + sex + restriction:sex, data = df.LE_Rday1_4)
LE_foraging_5 <- aov(foraging.score ~ restriction + sex + restriction:sex, data = df.LE_Rday1_5)
eta_squared(LE_foraging_1)
eta_squared(LE_foraging_2)
eta_squared(LE_foraging_3)
eta_squared(LE_foraging_4)
eta_squared(LE_foraging_5)
emmeans(LE_foraging, pairwise ~ restriction|trials)
```
## restriction effect plot, fig 2a 2b
......@@ -354,3 +400,14 @@ Fig4c_d <- ggarrange(Fig_LE_leaving,Fig_LE_approaching,fig4c,fig4d,ncol=2,nrow=2
Fig4c_d
ggsave('C:/Users/xiamen/Desktop/modified robogator/result figs/Fig4c_d.svg', plot = Fig4c_d, device = 'svg',dpi = 300, width = 176, height = 140, units = "mm")
```
## body weight effect
```{r}
df.weight.LE <- df %>% filter(df$robot.day == 1, df$group == "LE")
mod.weight.LE<- lmer(foraging.score~ weight.before.sacrifice + restriction + trials + sex + (1|rat_ID), df.weight.LE)
eta_squared(mod.weight.LE)
df.weight.SD <- df %>% filter(df$robot.day == 1, df$group == "SD")
mod.weight.SD<- lmer(foraging.score~ weight.before.sacrifice + age + trials + sex + age:weight.before.sacrifice + (1|rat_ID), df.weight.SD)
eta_squared(mod.weight.SD)
```
\ No newline at end of file
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