Loading libraries
library(ggplot2)
library(ggpubr)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ✔ purrr 0.3.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(effectsize)
library(tidyr)
library(rstatix)
##
## Attaching package: 'rstatix'
##
## The following objects are masked from 'package:effectsize':
##
## cohens_d, eta_squared
##
## The following object is masked from 'package:stats':
##
## filter
library(report)
Reading in data
PS4_DATA <- read.csv("ps4data.csv")
Changing gender into factor
PS4_DATA$id <- as.factor(PS4_DATA$id)
levels(PS4_DATA$id) <- list('Female' = "1", 'Male' = "2")
Descriptives for search eye mean by gender
mean(PS4_DATA$search_eyex_speed[PS4_DATA$id=="Male"])
## [1] 1.218702
sd(PS4_DATA$search_eyex_speed[PS4_DATA$id=="Male"])
## [1] 0.2848641
mean(PS4_DATA$search_eyex_speed[PS4_DATA$id=="Female"])
## [1] 1.36408
sd(PS4_DATA$search_eyex_speed[PS4_DATA$id=="Female"])
## [1] 0.4422632
Descriptives for search eye mean by eye movement while walking (low/high)
mean(PS4_DATA$search_eyex_speed[PS4_DATA$walk_eyex_factor=="1"])
## [1] 1.107506
sd(PS4_DATA$search_eyex_speed[PS4_DATA$walk_eyex_factor=="1"])
## [1] 0.2494364
mean(PS4_DATA$search_eyex_speed[PS4_DATA$walk_eyex_factor=="2"])
## [1] 1.47911
sd(PS4_DATA$search_eyex_speed[PS4_DATA$walk_eyex_factor=="2"])
## [1] 0.3919304
Changing eye movement while walking into factor
PS4_DATA$walk_eyex_factor <- as.factor(PS4_DATA$walk_eyex_factor)
levels(PS4_DATA$walk_eyex_factor) <- list('LowSpeed' = "1", 'HighSpeed' = "2")
ggplot(PS4_DATA, aes(fill=id, y=search_eyex_speed, x=walk_eyex_factor)) +
geom_bar(position="dodge", stat="identity")+
xlab("Eye Movement Speed Walking")+
ylab("Eye Movement Speed Searching")
Cell means table
cellDesc <- with(PS4_DATA, aggregate(x=list(Mean=search_eyex_speed, SD=search_eyex_speed),
by=list(F1=id, F2=walk_eyex_factor),
FUN=mean_sd))
View(cellDesc)
## Warning in format.data.frame(x0): corrupt data frame: columns will be truncated
## or padded with NAs
Factorial ANOVA: seeing if outcome of interest (search eye mean) is dependent on gender and walking eye movement
anova <- aov(search_eyex_speed~id*walk_eyex_factor,data=PS4_DATA)
summary(anova)
## Df Sum Sq Mean Sq F value Pr(>F)
## id 1 0.312 0.3116 3.153 0.0813 .
## walk_eyex_factor 1 1.961 1.9615 19.844 4.17e-05 ***
## id:walk_eyex_factor 1 0.432 0.4320 4.371 0.0412 *
## Residuals 55 5.436 0.0988
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
report(anova)
## Warning: Could not find Sum-of-Squares for the (Intercept) in the ANOVA table.
## The ANOVA (formula: search_eyex_speed ~ id * walk_eyex_factor) suggests that:
##
## - The main effect of id is statistically not significant and small (F(1, 55) =
## 3.15, p = 0.081; Eta2 (partial) = 0.05, 95% CI [0.00, 1.00])
## - The main effect of walk_eyex_factor is statistically significant and large
## (F(1, 55) = 19.84, p < .001; Eta2 (partial) = 0.27, 95% CI [0.11, 1.00])
## - The interaction between id and walk_eyex_factor is statistically significant
## and medium (F(1, 55) = 4.37, p = 0.041; Eta2 (partial) = 0.07, 95% CI
## [1.62e-03, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.
Simple Effects - males
simple_effects_male <- PS4_DATA %>% filter(id=="Male") %>%
aov(search_eyex_speed~walk_eyex_factor,data=.)
summary(simple_effects_male)
## Df Sum Sq Mean Sq F value Pr(>F)
## walk_eyex_factor 1 0.288 0.28802 3.905 0.0581 .
## Residuals 28 2.065 0.07376
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
report(simple_effects_male)
## Warning: Could not find Sum-of-Squares for the (Intercept) in the ANOVA table.
## The ANOVA (formula: search_eyex_speed ~ walk_eyex_factor) suggests that:
##
## - The main effect of walk_eyex_factor is statistically not significant and
## medium (F(1, 28) = 3.90, p = 0.058; Eta2 = 0.12, 95% CI [0.00, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.
Simple effects - Females
simple_effects_female <- PS4_DATA %>% filter(id=="Female") %>%
aov(search_eyex_speed~walk_eyex_factor,data=.)
summary(simple_effects_female)
## Df Sum Sq Mean Sq F value Pr(>F)
## walk_eyex_factor 1 2.105 2.1055 16.86 0.000334 ***
## Residuals 27 3.371 0.1249
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
report(simple_effects_female)
## Warning: Could not find Sum-of-Squares for the (Intercept) in the ANOVA table.
## The ANOVA (formula: search_eyex_speed ~ walk_eyex_factor) suggests that:
##
## - The main effect of walk_eyex_factor is statistically significant and large
## (F(1, 27) = 16.86, p < .001; Eta2 = 0.38, 95% CI [0.15, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.