library(languageR)
library(ggplot2)
ind_predictors2 <- read.csv("ind_predictors2.csv")
ind_predictors2
## percent_errors logmeanRT age fluency_phon fluency_sem sex
## 1 -0.53866204 -0.735166741 -1.0581600 0.55510764 1.0125209 1.3948567
## 2 -0.53866204 0.155799661 1.1769238 2.69288452 3.3200553 -0.7168889
## 3 1.69910826 -1.139946151 -0.8253388 1.54177389 0.4997355 1.3948567
## 4 -0.33911565 0.485471388 -1.1047243 0.55510764 -1.0386207 1.3948567
## 5 -1.15155455 -0.238840997 -1.2444170 0.39066326 0.8843246 -0.7168889
## 6 1.08621576 0.461594459 0.8044098 -0.76044737 -0.5258353 1.3948567
## 7 0.42343666 -0.160569523 -1.0581600 -0.10266987 -2.1923879 -0.7168889
## 8 -0.17520253 0.607637980 1.3166165 1.04844076 -0.3976390 1.3948567
## 9 -0.74533510 0.388606392 0.8509741 0.55510764 1.2689136 -0.7168889
## 10 -0.33911565 2.303779873 0.9906668 -0.43155862 -0.9104244 -0.7168889
## 11 -0.96626146 -0.194760687 -0.5459533 0.88399639 0.7561282 -0.7168889
## 12 -0.53866204 0.038609654 -0.9650315 -0.10266987 1.1407173 -0.7168889
## 13 -0.96626146 -1.150016583 -1.2444170 0.88399639 -1.4232098 -0.7168889
## 14 3.33111272 1.189764934 1.6425662 -2.07600238 -1.0386207 -0.7168889
## 15 2.71822022 0.491858354 0.9906668 -0.26711424 0.4997355 -0.7168889
## 16 -0.94488149 -0.008155017 -1.1978528 0.06177451 0.1151465 -0.7168889
## 17 0.22389026 -0.764986218 -1.1047243 -0.59600299 -0.6540317 1.3948567
## 18 -1.15155455 -0.185643933 -0.8253388 2.03510702 0.7561282 -0.7168889
## 19 1.49956187 0.486883766 1.5960020 -1.74711362 -0.1412462 -0.7168889
## 20 -0.53866204 0.977867958 -0.9184673 -0.43155862 -0.2694426 -0.7168889
## 21 -0.94488149 0.719924798 0.8975383 0.88399639 0.3715392 -0.7168889
## 22 0.88666936 0.411095334 0.8975383 -0.26711424 -0.3976390 1.3948567
## 23 -0.76671507 1.519405333 -0.5459533 3.02177327 2.5508772 -0.7168889
## 24 -0.94488149 -0.601576798 -1.1978528 -0.43155862 -0.9104244 -0.7168889
## 25 -0.56716867 1.211265365 0.7578456 0.55510764 1.1407173 -0.7168889
## 26 -0.74533510 -1.379801357 -1.1512885 -1.25378050 -0.1412462 1.3948567
## 27 -0.76671507 -0.856791524 -0.8253388 -0.43155862 -1.2950134 -0.7168889
## 28 -0.76671507 0.306992689 0.7578456 0.55510764 1.2689136 1.3948567
## 29 -0.36762227 0.068538025 -1.0581600 -0.26711424 0.7561282 -0.7168889
## 30 -0.56716867 -0.767278809 0.8044098 0.22621889 -0.3976390 -0.7168889
## 31 0.67999631 -0.041325212 -1.0581600 0.06177451 0.1151465 -0.7168889
## 32 -0.74533510 -0.643579915 0.6181528 0.22621889 0.3715392 -0.7168889
## 33 -0.33911565 -0.171761844 -0.5925176 -0.59600299 -1.5514061 1.3948567
## 34 -0.94488149 0.005991944 -1.1512885 -0.59600299 2.4226808 -0.7168889
## 35 -0.53866204 -2.974659742 -1.2444170 0.71955201 -0.2694426 1.3948567
## 36 0.48044991 0.286060838 0.9906668 -0.76044737 -0.7822280 -0.7168889
## 37 -0.13244259 -1.066836228 1.2234880 -0.59600299 -0.1412462 1.3948567
## 38 -0.74533510 0.980505883 0.8509741 -0.59600299 1.0125209 -0.7168889
## 39 -0.74533510 0.073669325 -0.7787745 0.88399639 0.1151465 -0.7168889
## 40 -1.15155455 -2.004996401 -0.5459533 1.54177389 0.3715392 1.3948567
## 41 -0.33911565 0.837338185 0.6647171 0.39066326 -0.9104244 1.3948567
## 42 -1.15155455 -0.820564399 -1.1978528 -1.41822487 -0.9104244 -0.7168889
## 43 -0.96626146 0.138575708 -0.7322103 1.37732952 0.3715392 1.3948567
## 44 0.07423046 -1.616968125 -0.9650315 -0.59600299 -0.9104244 -0.7168889
## 45 0.07423046 0.758464696 0.9441025 -1.08933612 -0.6540317 1.3948567
## 46 0.02434386 0.662018041 0.9906668 1.37732952 0.1151465 -0.7168889
## 47 -0.53866204 1.427494762 1.2234880 -0.59600299 -1.1668171 -0.7168889
## 48 2.00555451 0.617017705 -0.8253388 -0.92489175 -0.5258353 1.3948567
## 49 0.88666936 0.829451689 1.2700523 -1.25378050 -0.3976390 -0.7168889
## 50 -0.53866204 2.057258674 0.8975383 0.88399639 0.8843246 -0.7168889
## 51 0.88666936 1.451391515 -0.6856461 -0.26711424 0.6279319 -0.7168889
## 52 0.48044991 -0.645578007 0.6647171 -1.08933612 0.6279319 -0.7168889
## 53 -0.53866204 0.059855323 -1.1978528 -0.10266987 0.2433428 -0.7168889
## 54 -0.13244259 -0.812534897 -0.8719030 0.22621889 -0.6540317 -0.7168889
## 55 -0.33911565 -0.532606679 0.9906668 1.54177389 1.0125209 -0.7168889
## 56 2.10532771 -0.036131554 1.3166165 -1.58266925 -0.1412462 1.3948567
## 57 0.02434386 1.042634180 0.8044098 -0.43155862 0.1151465 -0.7168889
## 58 2.31200077 -0.245119875 1.0372310 -1.25378050 -0.2694426 -0.7168889
## 59 1.49956187 -0.333839204 0.8509741 -2.24044675 -0.2694426 1.3948567
## 60 0.27377686 0.903467279 0.8975383 0.22621889 0.6279319 1.3948567
## 61 -0.33911565 -1.108348388 -0.9650315 0.88399639 1.2689136 1.3948567
## 62 0.07423046 1.463831689 0.6647171 -0.10266987 1.0125209 1.3948567
## 63 1.41404198 -1.080889893 0.8975383 0.22621889 1.0125209 -0.7168889
## 64 1.90578132 -1.204142987 1.0372310 -1.08933612 -0.0130499 -0.7168889
## 65 -1.15155455 -0.293461208 -1.2444170 -0.76044737 -0.6540317 -0.7168889
## 66 2.31200077 -1.021324188 1.3631808 -0.26711424 0.1151465 -0.7168889
## 67 0.67999631 1.129231706 1.5494377 -1.25378050 0.4997355 -0.7168889
## 68 0.42343666 1.308167656 1.2700523 0.55510764 -0.2694426 -0.7168889
## 69 -0.36762227 -0.664605898 -1.1047243 -0.10266987 1.2689136 1.3948567
## 70 -0.74533510 -1.889877788 -0.9184673 1.21288514 -0.6540317 -0.7168889
## 71 -0.74533510 -0.112784381 0.6181528 0.71955201 0.7561282 -0.7168889
## 72 0.07423046 0.569517732 0.8044098 -0.10266987 -0.3976390 -0.7168889
## 73 -0.53866204 0.219530582 -0.6856461 -1.25378050 -1.6796025 1.3948567
## 74 -0.94488149 -0.823086201 -1.0581600 -0.26711424 -0.3976390 1.3948567
## 75 -1.35110094 0.367827347 -1.2444170 0.22621889 -0.5258353 -0.7168889
## 76 0.02434386 -0.464041607 -0.7322103 -0.10266987 -0.2694426 -0.7168889
## 77 -0.13244259 0.202828057 -0.8253388 0.06177451 2.1662881 -0.7168889
## 78 0.07423046 1.108370000 -1.1047243 -0.26711424 -0.1412462 1.3948567
## 79 0.27377686 -0.204853835 -1.2444170 0.39066326 -1.0386207 1.3948567
## 80 -0.36762227 -1.113364815 -0.7787745 1.54177389 1.2689136 -0.7168889
## 81 -0.36762227 0.965399172 0.6181528 0.06177451 -0.5258353 -0.7168889
## 82 0.88666936 -3.323266901 -1.1047243 -0.59600299 -0.3976390 1.3948567
## 83 -0.94488149 -0.650244231 -0.9650315 -0.10266987 -0.9104244 -0.7168889
## 84 0.07423046 0.635666341 0.7112813 -0.92489175 -0.9104244 1.3948567
## 85 0.88666936 -0.376101601 0.7112813 -1.41822487 -1.1668171 -0.7168889
## 86 0.07423046 -0.597938095 -1.1047243 1.87066264 0.4997355 -0.7168889
## 87 -0.33911565 -0.723756643 -0.8253388 -1.41822487 -1.6796025 -0.7168889
## 88 0.02434386 -0.792543972 1.0837953 -0.59600299 -0.3976390 -0.7168889
## 89 -0.13244259 0.361996790 0.8044098 0.55510764 -1.6796025 1.3948567
## 90 1.41404198 2.068765222 0.8509741 -0.59600299 -1.6796025 1.3948567
## 91 2.79661344 0.713548433 1.2700523 0.55510764 -1.4232098 -0.7168889
## 92 -0.74533510 1.250703723 0.8509741 1.37732952 0.3715392 1.3948567
## 93 -0.74533510 -1.420346555 -1.0581600 0.39066326 2.1662881 -0.7168889
## 94 1.29288881 0.435551837 1.1303595 -1.41822487 -0.2694426 1.3948567
## 95 0.07423046 1.818851027 0.7578456 0.71955201 -0.2694426 -0.7168889
## 96 -0.94488149 -0.424899123 -1.1512885 -0.43155862 0.1151465 -0.7168889
## 97 -0.53866204 0.381334154 1.1769238 0.22621889 0.6279319 -0.7168889
## 98 -1.15155455 -0.235441594 -0.6856461 -1.41822487 0.1151465 -0.7168889
## 99 -0.36762227 -0.437720256 0.8044098 0.06177451 1.0125209 1.3948567
## 100 -0.13244259 0.135353635 -1.0581600 1.87066264 -1.1668171 -0.7168889
## verbal_intelligence digit_span education_level reading_hours
## 1 -0.1931041 1.83606889 0.8437828 -0.4853112
## 2 0.7931324 -1.16569013 0.8437828 1.1036525
## 3 0.1356414 1.83606889 -1.3704963 -0.4853112
## 4 -3.4805591 0.63536528 -2.1085893 -1.6770340
## 5 -0.1931041 0.03501348 0.8437828 -0.4853112
## 6 0.4643869 0.03501348 -1.3704963 1.1036525
## 7 -2.8230681 0.03501348 -1.3704963 -0.4853112
## 8 1.1218779 -0.56533833 0.8437828 1.1036525
## 9 1.1218779 0.03501348 0.8437828 1.1036525
## 10 0.1356414 0.03501348 -2.1085893 -0.4853112
## 11 0.7931324 0.63536528 0.8437828 -0.4853112
## 12 -0.8505951 0.63536528 0.1056898 -1.6770340
## 13 0.4643869 2.43642070 0.8437828 -0.4853112
## 14 1.1218779 -1.76604194 0.8437828 -0.4853112
## 15 0.1356414 0.03501348 -1.3704963 1.1036525
## 16 -0.5218496 0.03501348 0.1056898 -0.4853112
## 17 0.1356414 1.83606889 0.8437828 -0.4853112
## 18 -0.1931041 0.03501348 0.8437828 -0.4853112
## 19 1.1218779 0.03501348 0.1056898 -0.4853112
## 20 -1.1793406 0.03501348 NA -0.4853112
## 21 1.4506234 -0.56533833 0.8437828 -0.4853112
## 22 0.7931324 -0.56533833 0.1056898 -0.4853112
## 23 0.4643869 0.63536528 -1.3704963 -0.4853112
## 24 -0.8505951 0.63536528 0.8437828 1.1036525
## 25 0.1356414 -1.16569013 0.8437828 1.1036525
## 26 -0.1931041 1.23571709 0.1056898 -1.6770340
## 27 -0.5218496 0.63536528 0.1056898 -1.6770340
## 28 0.4643869 -0.56533833 0.8437828 1.1036525
## 29 -0.5218496 0.63536528 -0.6324033 1.1036525
## 30 1.1218779 -0.56533833 0.1056898 -0.4853112
## 31 -2.8230681 -2.36639374 -1.3704963 -0.4853112
## 32 1.4506234 0.63536528 0.8437828 -0.4853112
## 33 -0.8505951 1.23571709 0.1056898 -1.6770340
## 34 -0.8505951 0.03501348 0.8437828 1.1036525
## 35 -0.5218496 1.83606889 0.8437828 1.8981344
## 36 -0.1931041 -2.96674555 -2.1085893 -0.4853112
## 37 0.4643869 0.03501348 0.8437828 1.1036525
## 38 1.1218779 0.03501348 0.1056898 1.1036525
## 39 -0.8505951 -0.56533833 -1.3704963 -1.6770340
## 40 0.7931324 0.03501348 0.8437828 -0.4853112
## 41 0.4643869 -0.56533833 0.8437828 1.8981344
## 42 -1.1793406 0.63536528 0.8437828 -0.4853112
## 43 0.4643869 0.63536528 0.8437828 -0.4853112
## 44 -0.1931041 -1.76604194 0.8437828 1.1036525
## 45 1.1218779 0.63536528 0.8437828 -0.4853112
## 46 0.4643869 -1.16569013 0.1056898 1.1036525
## 47 1.1218779 -1.16569013 -1.3704963 1.8981344
## 48 -2.1655771 -1.16569013 -2.1085893 -0.4853112
## 49 0.7931324 -1.16569013 -1.3704963 1.1036525
## 50 0.7931324 -0.56533833 0.8437828 1.1036525
## 51 -0.8505951 -0.56533833 0.8437828 -0.4853112
## 52 0.1356414 -0.56533833 0.8437828 1.8981344
## 53 0.1356414 2.43642070 0.8437828 -1.6770340
## 54 -0.8505951 0.03501348 0.1056898 -0.4853112
## 55 -0.1931041 -0.56533833 -1.3704963 -0.4853112
## 56 -0.1931041 -0.56533833 0.8437828 -0.4853112
## 57 1.1218779 0.03501348 -1.3704963 -0.4853112
## 58 -1.8368316 -1.16569013 -1.3704963 -0.4853112
## 59 0.4643869 -1.16569013 0.8437828 1.1036525
## 60 1.1218779 0.03501348 0.8437828 1.1036525
## 61 0.4643869 1.23571709 0.8437828 1.1036525
## 62 0.4643869 0.03501348 0.1056898 1.1036525
## 63 0.1356414 0.03501348 -1.3704963 -0.4853112
## 64 -0.5218496 -0.56533833 0.1056898 1.1036525
## 65 -0.8505951 0.63536528 0.1056898 -1.6770340
## 66 1.4506234 -1.16569013 0.8437828 1.1036525
## 67 0.1356414 -0.56533833 -2.1085893 -0.4853112
## 68 0.1356414 -1.76604194 -1.3704963 -0.4853112
## 69 0.4643869 0.03501348 -1.3704963 -0.4853112
## 70 0.4643869 0.03501348 0.1056898 -0.4853112
## 71 1.4506234 -0.56533833 0.1056898 1.1036525
## 72 0.1356414 -0.56533833 -2.1085893 1.1036525
## 73 -0.1931041 0.63536528 0.1056898 -0.4853112
## 74 -0.5218496 0.63536528 0.8437828 1.1036525
## 75 -0.8505951 0.63536528 0.1056898 NA
## 76 -0.8505951 0.63536528 -1.3704963 -1.6770340
## 77 -0.8505951 1.23571709 -1.3704963 1.8981344
## 78 -0.1931041 1.23571709 -1.3704963 -1.6770340
## 79 -1.1793406 1.23571709 NA -0.4853112
## 80 -0.5218496 0.63536528 0.8437828 -0.4853112
## 81 1.1218779 1.23571709 0.8437828 -0.4853112
## 82 -1.5080861 -0.56533833 0.8437828 -0.4853112
## 83 -2.1655771 0.03501348 0.8437828 -1.6770340
## 84 0.1356414 -1.16569013 0.8437828 -0.4853112
## 85 1.1218779 -0.56533833 0.8437828 1.1036525
## 86 -0.1931041 0.03501348 0.1056898 -0.4853112
## 87 0.1356414 -1.16569013 0.1056898 -0.4853112
## 88 1.1218779 0.03501348 0.1056898 1.1036525
## 89 0.7931324 0.03501348 0.1056898 -0.4853112
## 90 1.4506234 0.03501348 0.1056898 -0.4853112
## 91 0.1356414 -0.56533833 0.1056898 1.1036525
## 92 0.7931324 1.23571709 0.8437828 -0.4853112
## 93 -0.1931041 0.03501348 -1.3704963 1.1036525
## 94 0.7931324 -1.16569013 0.8437828 1.1036525
## 95 0.1356414 -1.16569013 -0.6324033 -0.4853112
## 96 -1.8368316 0.03501348 -1.3704963 -0.4853112
## 97 0.1356414 -1.16569013 0.8437828 1.1036525
## 98 0.1356414 0.63536528 0.8437828 -0.4853112
## 99 1.4506234 0.63536528 0.8437828 -0.4853112
## 100 -1.1793406 2.43642070 0.8437828 -0.4853112
flu_phon <- ind_predictors2$fluency_phon
nReps <- 100
means <- rep(0, nReps)
for(i in 1:nReps) {
means[i] <- mean(rnorm(n=length(flu_phon),
mean=1,
sd=sd(flu_phon)))
}
hist(means)

obs.mean <- mean(flu_phon)
p_value <- length(means[means <= obs.mean | means >= 1 + (1 - obs.mean)]) / nReps
print(p_value)
## [1] 0
#since the p-value is 0, we can reject the null hypothesis that the mean value
verbal_intel <- ind_predictors2$verbal_intelligence
hist(verbal_intel)

shapiro.test(verbal_intel)
##
## Shapiro-Wilk normality test
##
## data: verbal_intel
## W = 0.93073, p-value = 5.479e-05
Q2 <- 100
Q2mean <- numeric(Q2)
for(i in 1:Q2) {
bootstrap_sample <- sample(verbal_intel, length(verbal_intel), replace = TRUE)
means[i] <- mean(bootstrap_sample)
}
hist(means, main = "Bootstrap Distribution of Verbal Intelligence", xlab = "Sample Means", col = "blue")

#Both the distributions of verbal intelligence and mean verbal intelligence have relatively normal shaped curves with the bulk of the values surrounding zero. However, both histograms have a left-skewed distribution with values that come further into the negative side, with the original values of verbal intelligence having a stronger left-skewed property
Q3.n <- length(flu_phon)
Q3.sd <- sd(flu_phon)
nReps <- 100
Q3.p <- numeric(nReps)
for (i in 1:nReps) {
Q3simulated_data <- rnorm(n = Q3.n, mean = 1, sd = Q3.sd)
Q3.p[i] <- t.test(Q3simulated_data, mu = 1)$p.value
}
type1_error_rate <- mean(Q3.p < 0.05)
type1_error_rate
## [1] 0.02
#This value of 0.07 is considerably different from the 0.05 that we would expect given the null hypothesis. This suggests that we may have erroneously rejected the null hypothesis.
Q4.effect.size <- mean(flu_phon) - 1
nReps <- 100
Q4.p <- numeric(nReps)
for (i in 1:nReps) {
Q4simulated_data <- rnorm(n = Q3.n, mean = 1 + Q4.effect.size, sd = Q3.sd)
Q4.p[i] <- t.test(Q4simulated_data, mu = 1)$p.value
}
test_power <- mean(Q4.p < 0.05)
test_power
## [1] 1
for (Q3.n in seq(from = 0, to = 10000, by = 500)) {
Q5nReps <- 10000
Q5.p <- numeric(Q5nReps)
}
for (i in 1:Q5nReps) {
data <- rnorm(n = Q3.n, mean = 1 + Q4.effect.size, sd = Q3.sd)
Q5.p[i] <- t.test(data, mu = 1)$p.value
}
power <- length(which(Q5.p < 0.05)) / Q5nReps
print(power)
## [1] 1
print(Q3.n)
## [1] 10000
if (power >= 0.8) {
good.n <- Q3.n
}
if (exists("good.n")) {
cat("Minimum sample size for desired power (0.8):", good.n)
} else {
cat("Failed to achieve desired power with sample sizes up to 10,000.")
}
## Minimum sample size for desired power (0.8): 10000
#Given that there were different results obtained from different bootstrapping methods with the small sample size, and given that there was a higher degree of certainty with a larger sample size, the sample size of 100 was too small to achieve a high degree of certainty in our results. It is only when we increase the sample size to 10000 that we achieve a high degree of confidence about our result.