# Loading required package, setting working directory, and reading the data file.
require(psych)
## Loading required package: psych
require(BayesFactor)
## Loading required package: BayesFactor
## Loading required package: coda
## Loading required package: Matrix
## ************
## Welcome to BayesFactor 0.9.12-2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
## 
## Type BFManual() to open the manual.
## ************
setwd("/Users/ivanropovik/OneDrive/MANUSCRIPTS/2016 Many Labs 5/Pilot 1/Analyses/")
pilot1 <- read.csv(file = "Pilot_1_Fort_Lewis.csv", header = TRUE, sep = ";")

# Computing means of the two scale items for each scenario
# If one of the two target items is missing,
# the score of the other item is used as the estimate for the given scenario
pilot1$scenario1_Q3 <- rowMeans(pilot1[,c("Q9", "Q12")], na.rm = TRUE)
pilot1$scenario2_Q15 <- rowMeans(pilot1[,c("Q20", "Q23")], na.rm = TRUE)
pilot1$scenario3_Q26 <- rowMeans(pilot1[,c("Q31", "Q34")], na.rm = TRUE)
pilot1$scenario4_Q239 <- rowMeans(pilot1[,c("Q244", "Q247")], na.rm = TRUE)
pilot1$scenario5_Q37 <- rowMeans(pilot1[,c("Q42", "Q45")], na.rm = TRUE)
pilot1$scenario6_Q250 <- rowMeans(pilot1[,c("Q255", "Q258")], na.rm = TRUE)
pilot1$scenario7_Q48 <- rowMeans(pilot1[,c("Q53", "Q56")], na.rm = TRUE)
pilot1$scenario8_Q59 <- rowMeans(pilot1[,c("Q64", "Q67")], na.rm = TRUE)
pilot1$scenario9_Q261 <- rowMeans(pilot1[,c("Q266", "Q269")], na.rm = TRUE)
pilot1$scenario10_Q81 <- rowMeans(pilot1[,c("Q86", "Q89")], na.rm = TRUE)
pilot1$scenario11_Q92 <- rowMeans(pilot1[,c("Q97", "Q100")], na.rm = TRUE)
pilot1$scenario12_Q103 <- rowMeans(pilot1[,c("Q108", "Q111")], na.rm = TRUE)
pilot1$scenario13_Q272 <- rowMeans(pilot1[,c("Q277", "Q280")], na.rm = TRUE)
pilot1$scenario14_Q283 <- rowMeans(pilot1[,c("Q288", "Q291")], na.rm = TRUE)
pilot1$scenario15_Q114 <- rowMeans(pilot1[,c("Q119", "Q122")], na.rm = TRUE)
pilot1$scenario16_Q228 <- rowMeans(pilot1[,c("Q233", "Q236")], na.rm = TRUE)
pilot1$scenario17_Q125 <- rowMeans(pilot1[,c("Q130", "Q133")], na.rm = TRUE)
pilot1$scenario18_Q136 <- rowMeans(pilot1[,c("Q141", "Q144")], na.rm = TRUE)
pilot1$scenario19_Q147 <- rowMeans(pilot1[,c("Q152", "Q155")], na.rm = TRUE)
pilot1$scenario20_Q158 <- rowMeans(pilot1[,c("Q163", "Q166")], na.rm = TRUE)
pilot1$scenario21_Q169 <- rowMeans(pilot1[,c("Q174", "Q177")], na.rm = TRUE)

# Sample size
nrow(pilot1)
## [1] 83
# Frequencies for demographic variables
# Q180 = Gender
# Q181 = Year of study
# Q182 = Age
lapply(pilot1[,c("Q180", "Q181", "Q182")],
       function(x){table(x, useNA = "ifany")})
## $Q180
## x
##    1    2 <NA> 
##   48    9   26 
## 
## $Q181
## x
##    1    2    3    4    5 <NA> 
##   19   14   10   11    3   26 
## 
## $Q182
## x
## <NA> 
##   83
# Descriptive statistics for each scenario
lapply(pilot1[,c("scenario1_Q3", "scenario2_Q15", "scenario3_Q26", "scenario4_Q239", "scenario5_Q37", "scenario6_Q250",
                 "scenario7_Q48", "scenario8_Q59", "scenario9_Q261", "scenario10_Q81", "scenario11_Q92",
                 "scenario12_Q103", "scenario13_Q272", "scenario14_Q283", "scenario15_Q114", "scenario16_Q228",
                 "scenario17_Q125", "scenario18_Q136", "scenario19_Q147", "scenario20_Q158", "scenario21_Q169")],
       function(x){describe(x, na.rm = TRUE, fast = TRUE)})
## $scenario1_Q3
##    vars  n mean  sd min max range  se
## X1    1 66 5.18 1.6   1   9     8 0.2
## 
## $scenario2_Q15
##    vars  n mean  sd min max range   se
## X1    1 65 5.76 1.7   1   9     8 0.21
## 
## $scenario3_Q26
##    vars  n mean   sd min max range   se
## X1    1 68  4.1 1.91   1 8.5   7.5 0.23
## 
## $scenario4_Q239
##    vars  n mean sd min max range   se
## X1    1 69 4.64  2   1   9     8 0.24
## 
## $scenario5_Q37
##    vars  n mean   sd min max range   se
## X1    1 66 5.64 1.87   1   9     8 0.23
## 
## $scenario6_Q250
##    vars  n mean   sd min max range   se
## X1    1 66 6.47 1.93   1   9     8 0.24
## 
## $scenario7_Q48
##    vars  n mean   sd min max range   se
## X1    1 65 5.94 1.34 2.5   9   6.5 0.17
## 
## $scenario8_Q59
##    vars  n mean   sd min max range   se
## X1    1 64 7.47 1.65 2.5   9   6.5 0.21
## 
## $scenario9_Q261
##    vars  n mean   sd min max range   se
## X1    1 63 6.12 1.94   1   9     8 0.24
## 
## $scenario10_Q81
##    vars  n mean   sd min max range   se
## X1    1 66 5.79 1.99   1   9     8 0.24
## 
## $scenario11_Q92
##    vars  n mean   sd min max range   se
## X1    1 68 5.37 1.85   1   9     8 0.22
## 
## $scenario12_Q103
##    vars  n mean   sd min max range   se
## X1    1 66 5.99 2.18   1   9     8 0.27
## 
## $scenario13_Q272
##    vars  n mean   sd min max range   se
## X1    1 75 5.59 1.92   1   9     8 0.22
## 
## $scenario14_Q283
##    vars  n mean   sd min max range   se
## X1    1 75 6.11 2.04   1   9     8 0.24
## 
## $scenario15_Q114
##    vars  n mean   sd min max range   se
## X1    1 73 4.21 1.84   1   9     8 0.22
## 
## $scenario16_Q228
##    vars  n mean   sd min max range   se
## X1    1 71 6.28 1.81   1   9     8 0.22
## 
## $scenario17_Q125
##    vars  n mean   sd min max range   se
## X1    1 70 6.26 2.07   1   9     8 0.25
## 
## $scenario18_Q136
##    vars  n mean   sd min max range   se
## X1    1 71 3.65 2.15   1   9     8 0.25
## 
## $scenario19_Q147
##    vars  n mean   sd min max range   se
## X1    1 70 4.08 1.99   1   9     8 0.24
## 
## $scenario20_Q158
##    vars  n mean   sd min max range   se
## X1    1 69 4.75 1.94   1   8     7 0.23
## 
## $scenario21_Q169
##    vars  n mean   sd min max range   se
## X1    1 65 6.18 1.78   1   9     8 0.22
# One-sample t-test for each scenario with population parameter mu set at 5.
lapply(pilot1[,c("scenario1_Q3", "scenario2_Q15", "scenario3_Q26", "scenario4_Q239", "scenario5_Q37", "scenario6_Q250",
                 "scenario7_Q48", "scenario8_Q59", "scenario9_Q261", "scenario10_Q81", "scenario11_Q92",
                 "scenario12_Q103", "scenario13_Q272", "scenario14_Q283", "scenario15_Q114", "scenario16_Q228",
                 "scenario17_Q125", "scenario18_Q136", "scenario19_Q147", "scenario20_Q158", "scenario21_Q169")],
       function(x){t.test(x, data = pilot1, mu = 5, na.rm = TRUE)})
## $scenario1_Q3
## 
##  One Sample t-test
## 
## data:  x
## t = 0.92203, df = 65, p-value = 0.3599
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.787995 5.575641
## sample estimates:
## mean of x 
##  5.181818 
## 
## 
## $scenario2_Q15
## 
##  One Sample t-test
## 
## data:  x
## t = 3.6205, df = 64, p-value = 0.0005818
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.341332 6.181745
## sample estimates:
## mean of x 
##  5.761538 
## 
## 
## $scenario3_Q26
## 
##  One Sample t-test
## 
## data:  x
## t = -3.907, df = 67, p-value = 0.0002201
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.633548 4.557629
## sample estimates:
## mean of x 
##  4.095588 
## 
## 
## $scenario4_Q239
## 
##  One Sample t-test
## 
## data:  x
## t = -1.4719, df = 68, p-value = 0.1457
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.163548 5.126307
## sample estimates:
## mean of x 
##  4.644928 
## 
## 
## $scenario5_Q37
## 
##  One Sample t-test
## 
## data:  x
## t = 2.7678, df = 65, p-value = 0.007343
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.177192 6.095535
## sample estimates:
## mean of x 
##  5.636364 
## 
## 
## $scenario6_Q250
## 
##  One Sample t-test
## 
## data:  x
## t = 6.2016, df = 65, p-value = 4.345e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.996400 6.942993
## sample estimates:
## mean of x 
##  6.469697 
## 
## 
## $scenario7_Q48
## 
##  One Sample t-test
## 
## data:  x
## t = 5.6381, df = 64, p-value = 4.169e-07
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.605942 6.270982
## sample estimates:
## mean of x 
##  5.938462 
## 
## 
## $scenario8_Q59
## 
##  One Sample t-test
## 
## data:  x
## t = 11.99, df = 63, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  7.05729 7.88021
## sample estimates:
## mean of x 
##   7.46875 
## 
## 
## $scenario9_Q261
## 
##  One Sample t-test
## 
## data:  x
## t = 4.5783, df = 62, p-value = 2.31e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.630450 6.607645
## sample estimates:
## mean of x 
##  6.119048 
## 
## 
## $scenario10_Q81
## 
##  One Sample t-test
## 
## data:  x
## t = 3.2219, df = 65, p-value = 0.001991
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.299509 6.276249
## sample estimates:
## mean of x 
##  5.787879 
## 
## 
## $scenario11_Q92
## 
##  One Sample t-test
## 
## data:  x
## t = 1.637, df = 67, p-value = 0.1063
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.919362 5.815932
## sample estimates:
## mean of x 
##  5.367647 
## 
## 
## $scenario12_Q103
## 
##  One Sample t-test
## 
## data:  x
## t = 3.6904, df = 65, p-value = 0.0004599
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.455352 6.529496
## sample estimates:
## mean of x 
##  5.992424 
## 
## 
## $scenario13_Q272
## 
##  One Sample t-test
## 
## data:  x
## t = 2.6785, df = 74, p-value = 0.009108
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.151943 6.034723
## sample estimates:
## mean of x 
##  5.593333 
## 
## 
## $scenario14_Q283
## 
##  One Sample t-test
## 
## data:  x
## t = 4.7277, df = 74, p-value = 1.059e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.644103 6.582564
## sample estimates:
## mean of x 
##  6.113333 
## 
## 
## $scenario15_Q114
## 
##  One Sample t-test
## 
## data:  x
## t = -3.6806, df = 72, p-value = 0.0004462
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.775160 4.635799
## sample estimates:
## mean of x 
##  4.205479 
## 
## 
## $scenario16_Q228
## 
##  One Sample t-test
## 
## data:  x
## t = 5.9597, df = 70, p-value = 9.228e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.852767 6.710614
## sample estimates:
## mean of x 
##   6.28169 
## 
## 
## $scenario17_Q125
## 
##  One Sample t-test
## 
## data:  x
## t = 5.0923, df = 69, p-value = 2.934e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.764644 6.749642
## sample estimates:
## mean of x 
##  6.257143 
## 
## 
## $scenario18_Q136
## 
##  One Sample t-test
## 
## data:  x
## t = -5.3063, df = 70, p-value = 1.248e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.139681 4.156093
## sample estimates:
## mean of x 
##  3.647887 
## 
## 
## $scenario19_Q147
## 
##  One Sample t-test
## 
## data:  x
## t = -3.8618, df = 69, p-value = 0.0002508
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.607997 4.556288
## sample estimates:
## mean of x 
##  4.082143 
## 
## 
## $scenario20_Q158
## 
##  One Sample t-test
## 
## data:  x
## t = -1.0552, df = 68, p-value = 0.2951
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.287687 5.219559
## sample estimates:
## mean of x 
##  4.753623 
## 
## 
## $scenario21_Q169
## 
##  One Sample t-test
## 
## data:  x
## t = 5.3184, df = 64, p-value = 1.424e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.734842 6.619004
## sample estimates:
## mean of x 
##  6.176923
# Bayes factor in favour of the null (BF01) for each scenario
# with population parameter mu set at 5 and prior width of 0.5.
lapply(pilot1[,c("scenario1_Q3", "scenario2_Q15", "scenario3_Q26", "scenario4_Q239", "scenario5_Q37", "scenario6_Q250",
                 "scenario7_Q48", "scenario8_Q59", "scenario9_Q261", "scenario10_Q81", "scenario11_Q92",
                 "scenario12_Q103", "scenario13_Q272", "scenario14_Q283", "scenario15_Q114", "scenario16_Q228",
                 "scenario17_Q125", "scenario18_Q136", "scenario19_Q147", "scenario20_Q158", "scenario21_Q169")],
       function(x){1/ttestBF(x[!is.na(x)], mu = 5, rscale = 0.5,  na.rm = TRUE)})
## $scenario1_Q3
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.641862 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario2_Q15
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.02096281 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario3_Q26
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.008929963 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario4_Q239
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.046543 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario5_Q37
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.187974 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario6_Q250
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.566535e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario7_Q48
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.928113e-05 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario8_Q59
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.482989e-15 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario9_Q261
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.001163285 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario10_Q81
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.06158926 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario11_Q92
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.618561 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario12_Q103
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0170872 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario13_Q272
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.2339356 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario14_Q283
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0005827229 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario15_Q114
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.01696729 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario16_Q228
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 7.215624e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario17_Q125
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0001782674 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario18_Q136
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 8.114708e-05 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario19_Q147
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.01008463 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario20_Q158
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.292246 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario21_Q169
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 9.118161e-05 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS