# Loading required package, setting working directory, and reading the data file.
library(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")
pilot1 <- read.csv(file = "Pilot 1 raw data.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 <- rowMeans(pilot1[,c("Sce1_scale_5", "Sce1_scale_8")], na.rm = TRUE)
pilot1$scenario2 <- rowMeans(pilot1[,c("Sce2_scale_5", "Sce2_scale_8")], na.rm = TRUE)
pilot1$scenario3 <- rowMeans(pilot1[,c("Sce3_scale_5", "Sce3_scale_8")], na.rm = TRUE)
pilot1$scenario4 <- rowMeans(pilot1[,c("Sce4_scale_5", "Sce4_scale_8")], na.rm = TRUE)
pilot1$scenario5 <- rowMeans(pilot1[,c("Sce5_scale_5", "Sce5_scale_8")], na.rm = TRUE)
pilot1$scenario6 <- rowMeans(pilot1[,c("Sce6_scale_5", "Sce6_scale_8")], na.rm = TRUE)
pilot1$scenario7 <- rowMeans(pilot1[,c("Sce7_scale_5", "Sce7_scale_8")], na.rm = TRUE)
pilot1$scenario8 <- rowMeans(pilot1[,c("Sce8_scale_5", "Sce8_scale_8")], na.rm = TRUE)
pilot1$scenario9 <- rowMeans(pilot1[,c("Sce9_scale_5", "Sce9_scale_8")], na.rm = TRUE)
pilot1$scenario10 <- rowMeans(pilot1[,c("Sce10_scale_5", "Sce10_scale_8")], na.rm = TRUE)
pilot1$scenario11 <- rowMeans(pilot1[,c("Sce11_scale_5", "Sce11_scale_8")], na.rm = TRUE)
pilot1$scenario12 <- rowMeans(pilot1[,c("Sce12_scale_5", "Sce12_scale_8")], na.rm = TRUE)
pilot1$scenario13 <- rowMeans(pilot1[,c("Sce13_scale_5", "Sce13_scale_8")], na.rm = TRUE)
pilot1$scenario14 <- rowMeans(pilot1[,c("Sce14_scale_5", "Sce14_scale_8")], na.rm = TRUE)
pilot1$scenario15 <- rowMeans(pilot1[,c("Sce15_scale_5", "Sce15_scale_8")], na.rm = TRUE)
pilot1$scenario16 <- rowMeans(pilot1[,c("Sce16_scale_5", "Sce16_scale_8")], na.rm = TRUE)
pilot1$scenario17 <- rowMeans(pilot1[,c("Sce17_scale_5", "Sce17_scale_8")], na.rm = TRUE)
pilot1$scenario18 <- rowMeans(pilot1[,c("Sce18_scale_5", "Sce18_scale_8")], na.rm = TRUE)
pilot1$scenario19 <- rowMeans(pilot1[,c("Sce19_scale_5", "Sce19_scale_8")], na.rm = TRUE)
pilot1$scenario20 <- rowMeans(pilot1[,c("Sce20_scale_5", "Sce20_scale_8")], na.rm = TRUE)
pilot1$scenario21 <- rowMeans(pilot1[,c("Sce21_scale_5", "Sce21_scale_8")], na.rm = TRUE)

# Sample size
nrow(pilot1)
## [1] 54
# Frequencies for demographic variables
lapply(pilot1[,c("Female", "Year_of_study", "Age")],
       function(x){table(x, useNA = "ifany")})
## $Female
## x
##    0    1 <NA> 
##   24   29    1 
## 
## $Year_of_study
## x
##    1    2    3 <NA> 
##   48    2    3    1 
## 
## $Age
## x
##   18   19   20   21   22 <NA> 
##    5   28   13    5    2    1
# Descriptive statistics for each scenario
lapply(pilot1[,c("scenario1","scenario2","scenario3","scenario4","scenario5","scenario6","scenario7",
                 "scenario8","scenario9","scenario10","scenario11","scenario12","scenario13","scenario14",
                 "scenario15","scenario16","scenario17","scenario18","scenario19","scenario20","scenario21")],
       function(x){describe(x, na.rm = TRUE, fast = TRUE)})
## $scenario1
##    vars  n mean   sd min max range   se
## X1    1 54 4.49 1.29   2 7.5   5.5 0.18
## 
## $scenario2
##    vars  n mean   sd min max range  se
## X1    1 54 6.53 1.49   3   9     6 0.2
## 
## $scenario3
##    vars  n mean   sd min max range   se
## X1    1 54  3.9 1.58 1.5 7.5     6 0.22
## 
## $scenario4
##    vars  n mean   sd min max range   se
## X1    1 54 5.05 1.73   1   9     8 0.24
## 
## $scenario5
##    vars  n mean   sd min max range   se
## X1    1 54 5.45 1.42 2.5 8.5     6 0.19
## 
## $scenario6
##    vars  n mean   sd min max range  se
## X1    1 54 6.31 1.51 1.5   9   7.5 0.2
## 
## $scenario7
##    vars  n mean   sd min max range   se
## X1    1 54 5.02 1.35 1.5   8   6.5 0.18
## 
## $scenario8
##    vars  n mean  sd min max range  se
## X1    1 54 7.48 1.5 2.5   9   6.5 0.2
## 
## $scenario9
##    vars  n mean   sd min max range  se
## X1    1 54    6 1.48 2.5   9   6.5 0.2
## 
## $scenario10
##    vars  n mean   sd min max range   se
## X1    1 54 5.34 1.58   2   9     7 0.22
## 
## $scenario11
##    vars  n mean   sd min max range  se
## X1    1 54 5.94 1.46 2.5   9   6.5 0.2
## 
## $scenario12
##    vars  n mean  sd min max range  se
## X1    1 54 5.21 1.5 1.5   9   7.5 0.2
## 
## $scenario13
##    vars  n mean   sd min max range   se
## X1    1 54 4.85 1.25   2   8     6 0.17
## 
## $scenario14
##    vars  n mean  sd min max range   se
## X1    1 54 6.19 1.3 2.5   9   6.5 0.18
## 
## $scenario15
##    vars  n mean   sd min max range   se
## X1    1 54 4.52 1.41 1.5 7.5     6 0.19
## 
## $scenario16
##    vars  n mean   sd min max range  se
## X1    1 54 6.02 1.49   2   9     7 0.2
## 
## $scenario17
##    vars  n mean   sd min max range   se
## X1    1 54 5.95 1.32 3.5   8   4.5 0.18
## 
## $scenario18
##    vars  n mean   sd min max range   se
## X1    1 54    4 2.07   1   9     8 0.28
## 
## $scenario19
##    vars  n mean   sd min max range   se
## X1    1 54 3.81 1.74   1   8     7 0.24
## 
## $scenario20
##    vars  n mean   sd min max range   se
## X1    1 54  3.8 1.13   1   7     6 0.15
## 
## $scenario21
##    vars  n mean   sd min max range   se
## X1    1 54 5.88 1.54 2.5   9   6.5 0.21
# One-sample t-test for each scenario with population parameter mu set at 5.
lapply(pilot1[,c("scenario1","scenario2","scenario3","scenario4","scenario5","scenario6","scenario7",
               "scenario8","scenario9","scenario10","scenario11","scenario12","scenario13","scenario14",
               "scenario15","scenario16","scenario17","scenario18","scenario19","scenario20","scenario21")],
       function(x){t.test(x, data = pilot1, mu = 5, na.rm = TRUE)})
## $scenario1
## 
##  One Sample t-test
## 
## data:  x
## t = -2.9085, df = 53, p-value = 0.005296
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.139542 4.841940
## sample estimates:
## mean of x 
##  4.490741 
## 
## 
## $scenario2
## 
##  One Sample t-test
## 
## data:  x
## t = 7.5175, df = 53, p-value = 6.635e-10
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  6.120149 6.935407
## sample estimates:
## mean of x 
##  6.527778 
## 
## 
## $scenario3
## 
##  One Sample t-test
## 
## data:  x
## t = -5.1173, df = 53, p-value = 4.389e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.466271 4.330025
## sample estimates:
## mean of x 
##  3.898148 
## 
## 
## $scenario4
## 
##  One Sample t-test
## 
## data:  x
## t = 0.19664, df = 53, p-value = 0.8449
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.574081 5.518511
## sample estimates:
## mean of x 
##  5.046296 
## 
## 
## $scenario5
## 
##  One Sample t-test
## 
## data:  x
## t = 2.3505, df = 53, p-value = 0.0225
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.066545 5.840863
## sample estimates:
## mean of x 
##  5.453704 
## 
## 
## $scenario6
## 
##  One Sample t-test
## 
## data:  x
## t = 6.4171, df = 53, p-value = 3.901e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.903855 6.725775
## sample estimates:
## mean of x 
##  6.314815 
## 
## 
## $scenario7
## 
##  One Sample t-test
## 
## data:  x
## t = 0.1006, df = 53, p-value = 0.9202
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.649298 5.387739
## sample estimates:
## mean of x 
##  5.018519 
## 
## 
## $scenario8
## 
##  One Sample t-test
## 
## data:  x
## t = 12.12, df = 53, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  7.070807 7.892156
## sample estimates:
## mean of x 
##  7.481481 
## 
## 
## $scenario9
## 
##  One Sample t-test
## 
## data:  x
## t = 4.9671, df = 53, p-value = 7.454e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.596196 6.403804
## sample estimates:
## mean of x 
##         6 
## 
## 
## $scenario10
## 
##  One Sample t-test
## 
## data:  x
## t = 1.5928, df = 53, p-value = 0.1172
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.911168 5.774017
## sample estimates:
## mean of x 
##  5.342593 
## 
## 
## $scenario11
## 
##  One Sample t-test
## 
## data:  x
## t = 4.7566, df = 53, p-value = 1.555e-05
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.546191 6.342698
## sample estimates:
## mean of x 
##  5.944444 
## 
## 
## $scenario12
## 
##  One Sample t-test
## 
## data:  x
## t = 1.0453, df = 53, p-value = 0.3006
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.804313 5.621613
## sample estimates:
## mean of x 
##  5.212963 
## 
## 
## $scenario13
## 
##  One Sample t-test
## 
## data:  x
## t = -0.87356, df = 53, p-value = 0.3863
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.511694 5.192009
## sample estimates:
## mean of x 
##  4.851852 
## 
## 
## $scenario14
## 
##  One Sample t-test
## 
## data:  x
## t = 6.7279, df = 53, p-value = 1.236e-08
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.838351 6.550538
## sample estimates:
## mean of x 
##  6.194444 
## 
## 
## $scenario15
## 
##  One Sample t-test
## 
## data:  x
## t = -2.514, df = 53, p-value = 0.01501
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.134371 4.902666
## sample estimates:
## mean of x 
##  4.518519 
## 
## 
## $scenario16
## 
##  One Sample t-test
## 
## data:  x
## t = 5.0271, df = 53, p-value = 6.036e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.612145 6.424892
## sample estimates:
## mean of x 
##  6.018519 
## 
## 
## $scenario17
## 
##  One Sample t-test
## 
## data:  x
## t = 5.3011, df = 53, p-value = 2.281e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.592854 6.314554
## sample estimates:
## mean of x 
##  5.953704 
## 
## 
## $scenario18
## 
##  One Sample t-test
## 
## data:  x
## t = -3.5547, df = 53, p-value = 0.0008055
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.435745 4.564255
## sample estimates:
## mean of x 
##         4 
## 
## 
## $scenario19
## 
##  One Sample t-test
## 
## data:  x
## t = -5.0563, df = 53, p-value = 5.444e-06
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.331745 4.279366
## sample estimates:
## mean of x 
##  3.805556 
## 
## 
## $scenario20
## 
##  One Sample t-test
## 
## data:  x
## t = -7.8229, df = 53, p-value = 2.148e-10
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  3.487675 4.104917
## sample estimates:
## mean of x 
##  3.796296 
## 
## 
## $scenario21
## 
##  One Sample t-test
## 
## data:  x
## t = 4.2012, df = 53, p-value = 0.0001022
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  5.459671 6.299589
## sample estimates:
## mean of x 
##   5.87963
# 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","scenario2","scenario3","scenario4","scenario5","scenario6","scenario7",
                 "scenario8","scenario9","scenario10","scenario11","scenario12","scenario13","scenario14",
                 "scenario15","scenario16","scenario17","scenario18","scenario19","scenario20","scenario21")],
       function(x){1/ttestBF(x[!is.na(x)], mu = 5, rscale = 0.5,  na.rm = TRUE)})
## $scenario1
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.1354379 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario2
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 7.076854e-08 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario3
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0002538595 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario4
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 4.822912 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario5
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.4469339 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario6
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.237599e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario7
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 4.885614 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario8
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.440826e-14 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario9
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0004114527 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario10
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.592397 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario11
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.000801814 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario12
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.005938 ±0.04%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario13
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 3.481813 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario14
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 1.106291e-06 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario15
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.3217495 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario16
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0003394928 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario17
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.0001395387 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario18
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.02693429 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario19
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.00030903 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario20
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 2.437586e-08 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS
## 
## 
## $scenario21
## Bayes factor analysis
## --------------
## [1] Null, mu=5 : 0.004360321 ±0%
## 
## Against denominator:
##   Alternative, r = 0.5, mu =/= 5 
## ---
## Bayes factor type: BFoneSample, JZS