library(dplyr)
library(mosaic)
## Warning: package 'mosaic' was built under R version 4.3.3
## Change File Path for Handwriting
Handwriting <- read.csv("C:/Users/casey/Downloads/Handwriting.csv")
View(Handwriting)
glimpse(Handwriting)
## Rows: 203
## Columns: 8
## $ Individual <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, …
## $ Gender <int> 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1,…
## $ Survey1 <int> 72, 56, 68, 80, 76, 76, 60, 68, 52, 64, 64, 64, 64, 68, 60,…
## $ Survey2 <int> 68, 68, 48, 80, 72, 60, 60, 68, 48, 72, 72, 72, 56, 76, 72,…
## $ FemaleID <dbl> 75.0, 41.7, 75.0, 83.3, 83.3, 75.0, 66.7, 75.0, 33.3, 75.0,…
## $ MaleID <dbl> 69.2, 69.2, 61.5, 76.9, 69.2, 76.9, 53.8, 61.5, 69.2, 53.8,…
## $ Both <int> 68, 48, 36, 76, 68, 60, 36, 64, 36, 64, 44, 64, 44, 60, 60,…
## $ DIFF <int> 4, -12, 20, 0, 4, 16, 0, 0, 4, -8, -8, -8, 8, -8, -12, -16,…
ggplot(Handwriting, aes(x=Survey1)) +
geom_histogram(bins=15, color ="white")
## Warning: Removed 3 rows containing non-finite outside the scale range
## (`stat_bin()`).

favstats(Handwriting$Survey1)
## min Q1 median Q3 max mean sd n missing
## 36 56 64 68 88 62.52 9.525929 200 3
Handwriting <- Handwriting %>%
mutate(Residuals = Survey1-62.52)
ggplot(Handwriting, aes(x=Residuals)) +
geom_histogram(bins=15, color ="white")
## Warning: Removed 3 rows containing non-finite outside the scale range
## (`stat_bin()`).

t.test(Handwriting$Residuals)
##
## One Sample t-test
##
## data: Handwriting$Residuals
## t = -4.6417e-15, df = 199, p-value = 1
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -1.32828 1.32828
## sample estimates:
## mean of x
## -3.126559e-15
df1 <- mutate(Handwriting, gender = ifelse(Gender == 1, "Female",
ifelse(Gender == 0, "Male", "N/A")))
dfm <- filter(Handwriting, Gender == 0)
dff <- filter(Handwriting, Gender == 1)
ggplot(data = df1, aes(x = gender, y = FemaleID)) + geom_boxplot() + labs(title = "") + theme_classic()

favstats(dfm$FemaleID)
## min Q1 median Q3 max mean sd n missing
## 16.7 41.7 58.3 66.7 100 55.63187 16.75522 91 0
dfm <- dfm %>%
mutate(Residuals = FemaleID-55.63)
dff <- dff %>%
mutate(Residuals = FemaleID-70.62)
ggplot(dff, aes(x=Residuals)) +
geom_histogram(bins=25, color ="white")

ggplot(dfm, aes(x=Residuals)) +
geom_histogram(bins=25, color ="white")

t.test(MaleID ~ Gender, data =Handwriting)
##
## Welch Two Sample t-test
##
## data: MaleID by Gender
## t = -0.92805, df = 154.73, p-value = 0.3548
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -5.635513 2.032903
## sample estimates:
## mean in group 0 mean in group 1
## 60.12637 61.92768