# 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+ManyLabs5+Hofstra.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] 71
# 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    3 <NA> 
##   36   23    2   10 
## 
## $Q181
## x
##    1    2    3    4    5 <NA> 
##   31   18    9    2    1   10 
## 
## $Q182
## x
##   18   19   20   22   23   99 <NA> 
##   31   18    9    1    1    1   10
# 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 61 5.16 1.41 2.5 8.5     6 0.18
## 
## $scenario2_Q15
##    vars  n mean   sd min max range   se
## X1    1 61  5.4 1.67   1   9     8 0.21
## 
## $scenario3_Q26
##    vars  n mean   sd min max range  se
## X1    1 59 3.98 1.56   1   8     7 0.2
## 
## $scenario4_Q239
##    vars  n mean   sd min max range   se
## X1    1 61 4.74 1.76   1   9     8 0.23
## 
## $scenario5_Q37
##    vars  n mean   sd min max range   se
## X1    1 60 4.73 1.63   1 7.5   6.5 0.21
## 
## $scenario6_Q250
##    vars  n mean   sd min max range   se
## X1    1 62 5.59 1.81   1   9     8 0.23
## 
## $scenario7_Q48
##    vars  n mean   sd min max range   se
## X1    1 61 5.61 1.47 1.5   9   7.5 0.19
## 
## $scenario8_Q59
##    vars  n mean   sd min max range   se
## X1    1 61 6.22 1.82   1   9     8 0.23
## 
## $scenario9_Q261
##    vars  n mean   sd min max range  se
## X1    1 62 5.73 1.57   1   9     8 0.2
## 
## $scenario10_Q81
##    vars  n mean   sd min max range   se
## X1    1 61 5.27 1.72   1   9     8 0.22
## 
## $scenario11_Q92
##    vars  n mean   sd min max range   se
## X1    1 61 5.21 2.01   1   9     8 0.26
## 
## $scenario12_Q103
##    vars  n mean   sd min max range   se
## X1    1 61 5.46 1.61   1   9     8 0.21
## 
## $scenario13_Q272
##    vars  n mean   sd min max range   se
## X1    1 62 4.82 1.52   1   8     7 0.19
## 
## $scenario14_Q283
##    vars  n mean   sd min max range   se
## X1    1 62  5.8 1.63 1.5   9   7.5 0.21
## 
## $scenario15_Q114
##    vars  n mean   sd min max range  se
## X1    1 60 4.25 1.55   1   9     8 0.2
## 
## $scenario16_Q228
##    vars  n mean   sd min max range   se
## X1    1 61 5.41 1.78   1   9     8 0.23
## 
## $scenario17_Q125
##    vars  n mean  sd min max range   se
## X1    1 61 6.01 1.8 1.5   9   7.5 0.23
## 
## $scenario18_Q136
##    vars  n mean   sd min max range   se
## X1    1 61 3.75 1.77   1 8.5   7.5 0.23
## 
## $scenario19_Q147
##    vars  n mean  sd min max range   se
## X1    1 61 4.16 1.7   1   9     8 0.22
## 
## $scenario20_Q158
##    vars  n mean   sd min max range   se
## X1    1 61 4.94 1.65   2   9     7 0.21
## 
## $scenario21_Q169
##    vars  n mean   sd min max range   se
## X1    1 61 5.75 1.73 1.5   9   7.5 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.90778, df = 60, p-value = 0.3676
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.802704 5.525165
## sample estimates:
## mean of x 
##  5.163934 
## 
## 
## $scenario2_Q15
## 
##  One Sample t-test
## 
## data:  x
## t = 1.8836, df = 60, p-value = 0.06447
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.975115 5.828163
## sample estimates:
## mean of x 
##  5.401639 
## 
## 
## $scenario3_Q26
## 
##  One Sample t-test
## 
## data:  x
## t = -5.0102, df = 58, p-value = 5.414e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.576751 4.389350
## sample estimates:
## mean of x 
##  3.983051 
## 
## 
## $scenario4_Q239
## 
##  One Sample t-test
## 
## data:  x
## t = -1.1626, df = 60, p-value = 0.2496
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.286406 5.189004
## sample estimates:
## mean of x 
##  4.737705 
## 
## 
## $scenario5_Q37
## 
##  One Sample t-test
## 
## data:  x
## t = -1.2653, df = 59, p-value = 0.2107
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.311621 5.155046
## sample estimates:
## mean of x 
##  4.733333 
## 
## 
## $scenario6_Q250
## 
##  One Sample t-test
## 
## data:  x
## t = 2.5584, df = 61, p-value = 0.01302
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.128573 6.048846
## sample estimates:
## mean of x 
##   5.58871 
## 
## 
## $scenario7_Q48
## 
##  One Sample t-test
## 
## data:  x
## t = 3.2301, df = 60, p-value = 0.002009
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.230940 5.982175
## sample estimates:
## mean of x 
##  5.606557 
## 
## 
## $scenario8_Q59
## 
##  One Sample t-test
## 
## data:  x
## t = 5.2408, df = 60, p-value = 2.176e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.755166 6.687457
## sample estimates:
## mean of x 
##  6.221311 
## 
## 
## $scenario9_Q261
## 
##  One Sample t-test
## 
## data:  x
## t = 3.6745, df = 61, p-value = 0.0005045
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.334503 6.133239
## sample estimates:
## mean of x 
##  5.733871 
## 
## 
## $scenario10_Q81
## 
##  One Sample t-test
## 
## data:  x
## t = 1.2273, df = 60, p-value = 0.2245
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.829628 5.711355
## sample estimates:
## mean of x 
##  5.270492 
## 
## 
## $scenario11_Q92
## 
##  One Sample t-test
## 
## data:  x
## t = 0.8284, df = 60, p-value = 0.4107
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.698517 5.727712
## sample estimates:
## mean of x 
##  5.213115 
## 
## 
## $scenario12_Q103
## 
##  One Sample t-test
## 
## data:  x
## t = 2.2223, df = 60, p-value = 0.03004
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.045853 5.872180
## sample estimates:
## mean of x 
##  5.459016 
## 
## 
## $scenario13_Q272
## 
##  One Sample t-test
## 
## data:  x
## t = -0.91708, df = 61, p-value = 0.3627
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.435733 5.209428
## sample estimates:
## mean of x 
##  4.822581 
## 
## 
## $scenario14_Q283
## 
##  One Sample t-test
## 
## data:  x
## t = 3.8489, df = 61, p-value = 0.0002866
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.383604 6.213170
## sample estimates:
## mean of x 
##  5.798387 
## 
## 
## $scenario15_Q114
## 
##  One Sample t-test
## 
## data:  x
## t = -3.7546, df = 59, p-value = 0.0003991
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.850296 4.649704
## sample estimates:
## mean of x 
##      4.25 
## 
## 
## $scenario16_Q228
## 
##  One Sample t-test
## 
## data:  x
## t = 1.7999, df = 60, p-value = 0.0769
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.954377 5.865295
## sample estimates:
## mean of x 
##  5.409836 
## 
## 
## $scenario17_Q125
## 
##  One Sample t-test
## 
## data:  x
## t = 4.3651, df = 60, p-value = 5.093e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.546193 6.470200
## sample estimates:
## mean of x 
##  6.008197 
## 
## 
## $scenario18_Q136
## 
##  One Sample t-test
## 
## data:  x
## t = -5.5, df = 60, p-value = 8.252e-07
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.300976 4.207220
## sample estimates:
## mean of x 
##  3.754098 
## 
## 
## $scenario19_Q147
## 
##  One Sample t-test
## 
## data:  x
## t = -3.8415, df = 60, p-value = 0.0002974
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.728594 4.599275
## sample estimates:
## mean of x 
##  4.163934 
## 
## 
## $scenario20_Q158
## 
##  One Sample t-test
## 
## data:  x
## t = -0.27226, df = 60, p-value = 0.7864
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.521075 5.364170
## sample estimates:
## mean of x 
##  4.942623 
## 
## 
## $scenario21_Q169
## 
##  One Sample t-test
## 
## data:  x
## t = 3.3975, df = 60, p-value = 0.001213
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.310116 6.198081
## sample estimates:
## mean of x 
##  5.754098
# 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.564679 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario2_Q15
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.066159 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario3_Q26
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0003089479 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario4_Q239
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.811595 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario5_Q37
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.498568 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario6_Q250
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.2977764 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario7_Q48
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.06097187 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario8_Q59
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0001342706 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario9_Q261
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.01832494 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario10_Q81
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.623497 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario11_Q92
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.793784 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario12_Q103
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.585643 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario13_Q272
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.561689 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario14_Q283
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.01111857 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario15_Q114
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.01481977 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario16_Q228
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.219412 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario17_Q125
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.002368134 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario18_Q136
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 5.49648e-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.01145727 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario20_Q158
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 5.010288 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario21_Q169
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.03936757 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS