# 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 = "Final_data_brazil_pilot1.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] 52
# 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 
## 40 12 
## 
## $Q181
## x
##  1  2  3 
##  1 36 15 
## 
## $Q182
## x
## 18 19 20 21 22 23 24 25 26 27 29 31 33 35 36 38 40 41 54 
##  3  7 10  7  2  2  2  5  1  1  2  2  1  1  1  2  1  1  1
# 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 52 5.49 1.6   2   9     7 0.22
## 
## $scenario2_Q15
##    vars  n mean   sd min max range   se
## X1    1 52  6.8 1.59   4   9     5 0.22
## 
## $scenario3_Q26
##    vars  n mean   sd min max range   se
## X1    1 52 4.51 1.49   1   9     8 0.21
## 
## $scenario4_Q239
##    vars  n mean   sd min max range  se
## X1    1 52 4.56 1.42   1   8     7 0.2
## 
## $scenario5_Q37
##    vars  n mean   sd min max range   se
## X1    1 51 5.92 1.59   3   9     6 0.22
## 
## $scenario6_Q250
##    vars  n mean   sd min max range   se
## X1    1 52  6.8 1.63   3   9     6 0.23
## 
## $scenario7_Q48
##    vars  n mean   sd min max range   se
## X1    1 51 5.89 1.33   3   9     6 0.19
## 
## $scenario8_Q59
##    vars  n mean   sd min max range   se
## X1    1 51 7.23 1.59   2   9     7 0.22
## 
## $scenario9_Q261
##    vars  n mean   sd min max range   se
## X1    1 52 6.68 1.57 2.5   9   6.5 0.22
## 
## $scenario10_Q81
##    vars  n mean   sd min max range   se
## X1    1 52 6.26 1.55   3   9     6 0.21
## 
## $scenario11_Q92
##    vars  n mean  sd min max range   se
## X1    1 52 6.42 1.6   1   9     8 0.22
## 
## $scenario12_Q103
##    vars  n mean   sd min max range   se
## X1    1 52  5.7 1.58   1 8.5   7.5 0.22
## 
## $scenario13_Q272
##    vars  n mean   sd min max range  se
## X1    1 52 5.91 1.45   1   9     8 0.2
## 
## $scenario14_Q283
##    vars  n mean   sd min max range   se
## X1    1 52 6.01 1.63 1.5   9   7.5 0.23
## 
## $scenario15_Q114
##    vars  n mean  sd min max range   se
## X1    1 52 4.62 1.3   1 8.5   7.5 0.18
## 
## $scenario16_Q228
##    vars  n mean   sd min max range   se
## X1    1 52 6.19 1.36 3.5   9   5.5 0.19
## 
## $scenario17_Q125
##    vars  n mean   sd min max range   se
## X1    1 52 6.38 1.39 4.5   9   4.5 0.19
## 
## $scenario18_Q136
##    vars  n mean   sd min max range  se
## X1    1 52    4 1.48   1 7.5   6.5 0.2
## 
## $scenario19_Q147
##    vars  n mean   sd min max range  se
## X1    1 52 3.37 1.47   1 6.5   5.5 0.2
## 
## $scenario20_Q158
##    vars  n mean   sd min max range  se
## X1    1 52 4.81 1.45   1 7.5   6.5 0.2
## 
## $scenario21_Q169
##    vars  n mean  sd min max range   se
## X1    1 52 6.21 1.5   2   9     7 0.21
# 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 = 2.2044, df = 51, p-value = 0.03204
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.043774 5.936995
## sample estimates:
## mean of x 
##  5.490385 
## 
## 
## $scenario2_Q15
## 
##  One Sample t-test
## 
## data:  x
## t = 8.1803, df = 51, p-value = 7.6e-11
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  6.356799 7.239355
## sample estimates:
## mean of x 
##  6.798077 
## 
## 
## $scenario3_Q26
## 
##  One Sample t-test
## 
## data:  x
## t = -2.3679, df = 51, p-value = 0.02172
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.093845 4.925386
## sample estimates:
## mean of x 
##  4.509615 
## 
## 
## $scenario4_Q239
## 
##  One Sample t-test
## 
## data:  x
## t = -2.2517, df = 51, p-value = 0.02868
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.163342 4.952042
## sample estimates:
## mean of x 
##  4.557692 
## 
## 
## $scenario5_Q37
## 
##  One Sample t-test
## 
## data:  x
## t = 4.1346, df = 50, p-value = 0.0001357
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.473877 6.369261
## sample estimates:
## mean of x 
##  5.921569 
## 
## 
## $scenario6_Q250
## 
##  One Sample t-test
## 
## data:  x
## t = 7.9363, df = 51, p-value = 1.827e-10
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  6.343232 7.252922
## sample estimates:
## mean of x 
##  6.798077 
## 
## 
## $scenario7_Q48
## 
##  One Sample t-test
## 
## data:  x
## t = 4.7847, df = 50, p-value = 1.556e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.517641 6.266673
## sample estimates:
## mean of x 
##  5.892157 
## 
## 
## $scenario8_Q59
## 
##  One Sample t-test
## 
## data:  x
## t = 9.9661, df = 50, p-value = 1.802e-13
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  6.776967 7.674013
## sample estimates:
## mean of x 
##   7.22549 
## 
## 
## $scenario9_Q261
## 
##  One Sample t-test
## 
## data:  x
## t = 7.7194, df = 51, p-value = 3.999e-10
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  6.245072 7.120312
## sample estimates:
## mean of x 
##  6.682692 
## 
## 
## $scenario10_Q81
## 
##  One Sample t-test
## 
## data:  x
## t = 5.8789, df = 51, p-value = 3.172e-07
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.829472 6.689758
## sample estimates:
## mean of x 
##  6.259615 
## 
## 
## $scenario11_Q92
## 
##  One Sample t-test
## 
## data:  x
## t = 6.3982, df = 51, p-value = 4.853e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.976557 6.869597
## sample estimates:
## mean of x 
##  6.423077 
## 
## 
## $scenario12_Q103
## 
##  One Sample t-test
## 
## data:  x
## t = 3.2059, df = 51, p-value = 0.002325
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.262371 6.141475
## sample estimates:
## mean of x 
##  5.701923 
## 
## 
## $scenario13_Q272
## 
##  One Sample t-test
## 
## data:  x
## t = 4.5506, df = 51, p-value = 3.338e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.510470 6.316453
## sample estimates:
## mean of x 
##  5.913462 
## 
## 
## $scenario14_Q283
## 
##  One Sample t-test
## 
## data:  x
## t = 4.4791, df = 51, p-value = 4.247e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.557089 6.462141
## sample estimates:
## mean of x 
##  6.009615 
## 
## 
## $scenario15_Q114
## 
##  One Sample t-test
## 
## data:  x
## t = -2.1259, df = 51, p-value = 0.03838
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.252168 4.978601
## sample estimates:
## mean of x 
##  4.615385 
## 
## 
## $scenario16_Q228
## 
##  One Sample t-test
## 
## data:  x
## t = 6.3304, df = 51, p-value = 6.206e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.814189 6.570427
## sample estimates:
## mean of x 
##  6.192308 
## 
## 
## $scenario17_Q125
## 
##  One Sample t-test
## 
## data:  x
## t = 7.1188, df = 51, p-value = 3.533e-09
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.987236 6.762764
## sample estimates:
## mean of x 
##     6.375 
## 
## 
## $scenario18_Q136
## 
##  One Sample t-test
## 
## data:  x
## t = -4.8879, df = 51, p-value = 1.054e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.589278 4.410722
## sample estimates:
## mean of x 
##         4 
## 
## 
## $scenario19_Q147
## 
##  One Sample t-test
## 
## data:  x
## t = -8.024, df = 51, p-value = 1.333e-10
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  2.956409 3.774360
## sample estimates:
## mean of x 
##  3.365385 
## 
## 
## $scenario20_Q158
## 
##  One Sample t-test
## 
## data:  x
## t = -0.95929, df = 51, p-value = 0.3419
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.405236 5.210148
## sample estimates:
## mean of x 
##  4.807692 
## 
## 
## $scenario21_Q169
## 
##  One Sample t-test
## 
## data:  x
## t = 5.8136, df = 51, p-value = 4.011e-07
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.793167 6.629910
## sample estimates:
## mean of x 
##  6.211538
# 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 : 0.5858171 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario2_Q15
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 9.152075e-09 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario3_Q26
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.4295271 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario4_Q239
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.536474 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario5_Q37
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.005571447 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario6_Q250
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.100519e-08 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario7_Q48
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0007997922 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario8_Q59
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.897346e-11 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario9_Q261
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 4.403458e-08 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario10_Q81
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.269293e-05 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario11_Q92
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.973776e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario12_Q103
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.06677607 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario13_Q272
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.001593845 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario14_Q283
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.001979017 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario15_Q114
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.6753954 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario16_Q228
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 4.996519e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario17_Q125
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.426463e-07 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario18_Q136
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0005627075 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario19_Q147
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.55781e-08 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario20_Q158
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.196252 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario21_Q169
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.818782e-05 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS