1 Set up R environment.

library(tidyverse)
library(ggplot2)
library(ggpubr)
library(plyr)
library(magick)
library(png)
library(lme4)
library(lmerTest)
library(irrNA)
library(psy)
library(coefficientalpha)
library(parameters)

2 Set the R working drectory to the main experiment directory.

setwd("/Users/adambarnas/Box/MetaAwareness/data/")  

3 Read in data files.

4 Compute average likelihood rating.

tbl_all_subj_avg <- tbl_all %>%
  group_by(workerId,image) %>%
  dplyr::summarize(average = mean(likelihood_rating)) %>%
  spread(image,average) %>% 
  mutate(subj_avg = rowMeans(.[-1], na.rm = TRUE))
mean(tbl_all_subj_avg$subj_avg)
## [1] 3.122273

5 Mixed effects model and correlation.

tbl_all$log <- log10(tbl_all$detection_rt)

corr <- tbl_all %>% 
  group_by(image) %>% 
  dplyr::summarize(log = mean(log), likelihood_rating = mean(likelihood_rating), change_type = unique(change_type), eccentricity = mean(eccentricity), box_percent = mean(box_percent), change_percent = mean(change_percent))

corr %>% 
  gghistogram(x = "likelihood_rating", fill = "#f7a800", add = "mean", bins = 9, xlab = ("Likelihood Rating"), ylab = ("Frequency"))

#ggsave("rating_histogram.jpg")

corr %>% 
  gghistogram(x = "log", fill = "#f7a800", add = "mean", bins = 36, ylim = c(0,60), xlim = c(0.7,1.5), xlab = ("Log Change Detection RT (sec)"), ylab = ("Frequency"))

#ggsave("rt_histogram.jpg")

corr %>% 
  ggboxplot(x = "change_type", y = "log", label = "image", font.label = c(5, "plain", "black"), ylab = ("Log Change Detection RT (sec)"))

fit_log1 <- lmer(log ~ likelihood_rating + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all)
summary(fit_log1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log ~ likelihood_rating + (1 | workerId) + (1 | image) + (1 |  
##     stim_set)
##    Data: tbl_all
## 
## REML criterion at convergence: -5951.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8052 -0.5505 -0.1354  0.3342  5.2601 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  image    (Intercept) 0.0015972 0.03996 
##  workerId (Intercept) 0.0116759 0.10806 
##  stim_set (Intercept) 0.0002451 0.01566 
##  Residual             0.0158930 0.12607 
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)        9.707e-01  1.257e-02  2.758e+00  77.198 1.11e-05 ***
## likelihood_rating -9.362e-03  1.751e-03  2.948e+03  -5.347 9.61e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## liklhd_rtng -0.431
ci(fit_log1)
##           Parameter CI      CI_low      CI_high
## 1       (Intercept) 95  0.94606015  0.995350218
## 2 likelihood_rating 95 -0.01279402 -0.005930741
corr %>%
  ggscatter(y = "log", x = "likelihood_rating", ylab = "Log Change Detection RT (sec)", xlab = "Likelihood of Detecting Change", add = "reg.line", cor.coef = TRUE, cor.coeff.args = list(method = "pearson", label.x = 1, label.y = 1.75), conf.int = TRUE, xlim = c(1, 5), ylim = c(0.75, 1.75))
## `geom_smooth()` using formula 'y ~ x'

fit_log2 <- lmer(log ~ change_percent + eccentricity + change_type + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all)
## boundary (singular) fit: see ?isSingular
summary(fit_log2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log ~ change_percent + eccentricity + change_type + (1 | workerId) +  
##     (1 | image) + (1 | stim_set)
##    Data: tbl_all
## 
## REML criterion at convergence: -5911.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6465 -0.5502 -0.1361  0.3415  5.2666 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.001673 0.0409  
##  workerId (Intercept) 0.011758 0.1084  
##  stim_set (Intercept) 0.000000 0.0000  
##  Residual             0.015855 0.1259  
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                          Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)             9.473e-01  1.141e-02  5.715e+02  83.016  < 2e-16 ***
## change_percent         -3.609e-03  1.305e-03  4.184e+02  -2.766  0.00592 ** 
## eccentricity            1.203e-04  3.114e-05  4.050e+02   3.865  0.00013 ***
## change_typedisappear   -2.544e-02  8.032e-03  4.017e+02  -3.168  0.00165 ** 
## change_typemovement    -1.737e-02  1.256e-02  4.114e+02  -1.383  0.16744    
## change_typereplacement -1.050e-02  2.912e-02  4.006e+02  -0.360  0.71868    
## change_typesize        -3.768e-02  1.690e-02  4.264e+02  -2.230  0.02630 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) chng_p eccntr chng_typd chng_typm chng_typr
## chang_prcnt -0.153                                            
## eccentricty -0.504 -0.060                                     
## chng_typdsp -0.498  0.102 -0.038                              
## chng_typmvm -0.230 -0.312  0.080  0.300                       
## chng_typrpl -0.149 -0.025  0.087  0.138     0.174             
## chang_typsz -0.158 -0.146  0.002  0.227     0.318     0.166   
## convergence code: 0
## boundary (singular) fit: see ?isSingular
ci(fit_log2)
##                Parameter CI        CI_low       CI_high
## 1            (Intercept) 95  9.249563e-01  0.9696877981
## 2         change_percent 95 -6.166727e-03 -0.0010521207
## 3           eccentricity 95  5.930467e-05  0.0001813659
## 4   change_typedisappear 95 -4.118383e-02 -0.0097005606
## 5    change_typemovement 95 -4.199855e-02  0.0072499415
## 6 change_typereplacement 95 -6.758098e-02  0.0465839332
## 7        change_typesize 95 -7.080946e-02 -0.0045559205
corr %>%
  ggscatter(y = "log", x = "eccentricity", ylab = "Log Change Detection RT (sec)", xlab = "Eccentricity (distance in pixels)", add = "reg.line", cor.coef = TRUE, cor.coeff.args = list(method = "pearson", label.x = 1, label.y = 1.5), conf.int = TRUE, ylim = c(0.75, 1.50), xlim = c(0,500))
## `geom_smooth()` using formula 'y ~ x'

corr %>%
  ggscatter(y = "log", x = "change_percent", ylab = "Log Change Detection RT (sec)", xlab = "Size of change (% of total image)", add = "reg.line", cor.coef = TRUE, cor.coeff.args = list(method = "pearson", label.x = 1, label.y = 1.5), conf.int = TRUE, ylim = c(0.75, 1.50), xlim = c(0,25))
## `geom_smooth()` using formula 'y ~ x'

fit_log3 <- lmer(likelihood_rating ~ box_percent + change_percent + eccentricity + change_type + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all)
summary(fit_log3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: likelihood_rating ~ box_percent + change_percent + eccentricity +  
##     change_type + (1 | workerId) + (1 | image) + (1 | stim_set)
##    Data: tbl_all
## 
## REML criterion at convergence: 15086.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9103 -0.6084  0.0059  0.6369  3.8821 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.5950   0.7714  
##  workerId (Intercept) 0.4581   0.6768  
##  stim_set (Intercept) 0.0460   0.2145  
##  Residual             0.7166   0.8465  
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                          Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)             3.282e+00  1.775e-01  7.973e+00  18.492 7.84e-08 ***
## box_percent             1.285e-02  2.855e-02  4.361e+02   0.450 0.652868    
## change_percent          3.935e-02  4.295e-02  4.361e+02   0.916 0.360099    
## eccentricity           -2.361e-04  4.495e-04  4.535e+02  -0.525 0.599565    
## change_typedisappear   -8.464e-02  1.214e-01  2.974e+02  -0.697 0.486300    
## change_typemovement    -1.329e+00  1.883e-01  3.633e+02  -7.060 8.53e-12 ***
## change_typereplacement -4.724e-01  4.300e-01  4.322e+02  -1.099 0.272453    
## change_typesize        -9.706e-01  2.533e-01  3.132e+02  -3.831 0.000154 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) bx_prc chng_p eccntr chng_typd chng_typm chng_typr
## box_percent -0.103                                                   
## chang_prcnt  0.007 -0.896                                            
## eccentricty -0.475  0.068 -0.087                                     
## chng_typdsp -0.447  0.088 -0.036 -0.025                              
## chng_typmvm -0.256  0.063 -0.191  0.082  0.315                       
## chng_typrpl -0.164  0.034 -0.039  0.086  0.147     0.186             
## chang_typsz -0.189  0.075 -0.125  0.003  0.245     0.337     0.178
ci(fit_log3)
##                Parameter CI       CI_low       CI_high
## 1            (Intercept) 95  2.933896270  3.6295695125
## 2            box_percent 95 -0.043104501  0.0688033189
## 3         change_percent 95 -0.044832883  0.1235307755
## 4           eccentricity 95 -0.001117091  0.0006447938
## 5   change_typedisappear 95 -0.322624332  0.1533428967
## 6    change_typemovement 95 -1.698579141 -0.9603772192
## 7 change_typereplacement 95 -1.315136158  0.3702449588
## 8        change_typesize 95 -1.467093496 -0.4740823562
corr %>%
  ggscatter(y = "likelihood_rating", x = "eccentricity", ylab = "Log Change Detection RT (sec)", xlab = "Eccentricity (distance in pixels)", add = "reg.line", conf.int = TRUE, ylim = c(1, 5), xlim = c(0,500))
## `geom_smooth()` using formula 'y ~ x'

corr %>%
  ggscatter(y = "likelihood_rating", x = "change_percent", ylab = "Log Change Detection RT (sec)", xlab = "Size of change (% of total image)", add = "reg.line", conf.int = TRUE, ylim = c(1, 5), xlim = c(0,25))
## `geom_smooth()` using formula 'y ~ x'

corr %>%
  ggscatter(y = "log", x = "likelihood_rating", color = "change_type", palette = c("#0d2240", "#00a8e1", "#f7a800", "#E31818", "#dfdddc"), ylab = "Log Change Detection RT (sec)", xlab = "Likelihood of Detecting Change", add = "reg.line", conf.int = TRUE, xlim = c(1, 5), ylim = c(0.75, 1.75)) + stat_cor(aes(color = change_type), label.x = c(1, 1, 2.5, 2.5, 4), label.y = c(1.7, 1.6, 1.7, 1.6, 1.7), method = "pearson")
## `geom_smooth()` using formula 'y ~ x'

model1a <- lmer(log ~  change_percent + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model1a)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ change_percent + (1 | workerId) + (1 | image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5937.9  -5898.4   2975.0  -5949.9     5333 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7248 -0.5494 -0.1384  0.3436  5.2565 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.001811 0.04256 
##  workerId (Intercept) 0.011737 0.10834 
##  stim_set (Intercept) 0.000000 0.00000 
##  Residual             0.015856 0.12592 
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                  Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)      0.951010   0.007883 289.841518 120.635  < 2e-16 ***
## change_percent  -0.003479   0.001231 433.809767  -2.827  0.00492 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## chang_prcnt -0.234
## convergence code: 0
## boundary (singular) fit: see ?isSingular
model1b <- lmer(log ~  change_percent + likelihood_rating + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model1b)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ change_percent + likelihood_rating + (1 | workerId) + (1 |  
##     image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5963.8  -5917.7   2988.9  -5977.8     5332 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8103 -0.5514 -0.1382  0.3327  5.2628 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.001565 0.03956 
##  workerId (Intercept) 0.011623 0.10781 
##  stim_set (Intercept) 0.000000 0.00000 
##  Residual             0.015888 0.12605 
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)        9.798e-01  9.484e-03  5.700e+02 103.315  < 2e-16 ***
## change_percent    -3.443e-03  1.185e-03  4.168e+02  -2.906  0.00386 ** 
## likelihood_rating -9.430e-03  1.747e-03  2.925e+03  -5.399 7.25e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) chng_p
## chang_prcnt -0.190       
## liklhd_rtng -0.569  0.003
## convergence code: 0
## boundary (singular) fit: see ?isSingular
anova(model1a,model1b)
## Data: tbl_all
## Models:
## model1a: log ~ change_percent + (1 | workerId) + (1 | image) + (1 | stim_set)
## model1b: log ~ change_percent + likelihood_rating + (1 | workerId) + (1 | 
## model1b:     image) + (1 | stim_set)
##         npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)    
## model1a    6 -5937.9 -5898.4 2975.0  -5949.9                         
## model1b    7 -5963.8 -5917.7 2988.9  -5977.8 27.855  1  1.307e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model2a <- lmer(log ~  eccentricity + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model2a)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ eccentricity + (1 | workerId) + (1 | image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5943.2  -5903.7   2977.6  -5955.2     5333 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6749 -0.5465 -0.1388  0.3428  5.3126 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  image    (Intercept) 1.748e-03 0.041807
##  workerId (Intercept) 1.191e-02 0.109133
##  stim_set (Intercept) 9.509e-06 0.003084
##  Residual             1.586e-02 0.125924
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  9.236e-01  9.915e-03 3.436e+00  93.157 5.72e-07 ***
## eccentricity 1.140e-04  3.122e-05 4.093e+02   3.651 0.000295 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## eccentricty -0.604
model2b <- lmer(log ~  eccentricity + likelihood_rating + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model2b)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ eccentricity + likelihood_rating + (1 | workerId) + (1 |  
##     image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5969.7  -5923.6   2991.8  -5983.7     5332 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7561 -0.5453 -0.1412  0.3411  5.3242 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  image    (Intercept) 1.502e-03 0.038753
##  workerId (Intercept) 1.175e-02 0.108413
##  stim_set (Intercept) 2.887e-05 0.005373
##  Residual             1.589e-02 0.126056
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)        9.523e-01  1.136e-02  7.895e+00  83.831 6.24e-13 ***
## eccentricity       1.140e-04  3.001e-05  3.974e+02   3.797 0.000169 ***
## likelihood_rating -9.515e-03  1.741e-03  2.871e+03  -5.464 5.05e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) eccntr
## eccentricty -0.504       
## liklhd_rtng -0.471 -0.003
anova(model2a,model2b)
## Data: tbl_all
## Models:
## model2a: log ~ eccentricity + (1 | workerId) + (1 | image) + (1 | stim_set)
## model2b: log ~ eccentricity + likelihood_rating + (1 | workerId) + (1 | 
## model2b:     image) + (1 | stim_set)
##         npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)    
## model2a    6 -5943.2 -5903.7 2977.6  -5955.2                         
## model2b    7 -5969.7 -5923.6 2991.8  -5983.7 28.522  1  9.266e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model3a <- lmer(log ~  change_type + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model3a)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ change_type + (1 | workerId) + (1 | image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5937.1  -5877.8   2977.5  -5955.1     5330 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6955 -0.5562 -0.1337  0.3397  5.2119 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.001753 0.04187 
##  workerId (Intercept) 0.011870 0.10895 
##  stim_set (Intercept) 0.000000 0.00000 
##  Residual             0.015858 0.12593 
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                         Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)              0.96430    0.00971 480.42543  99.314  < 2e-16 ***
## change_typedisappear    -0.02225    0.00809 411.19923  -2.750  0.00623 ** 
## change_typemovement     -0.03115    0.01206 418.90935  -2.582  0.01015 *  
## change_typereplacement  -0.02184    0.02938 406.38538  -0.744  0.45761    
## change_typesize         -0.04411    0.01693 427.30215  -2.605  0.00951 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) chng_typd chng_typm chng_typr
## chng_typdsp -0.598                              
## chng_typmvm -0.309  0.355                       
## chng_typrpl -0.130  0.145     0.170             
## chang_typsz -0.221  0.246     0.290     0.164   
## convergence code: 0
## boundary (singular) fit: see ?isSingular
model3b <- lmer(log ~  change_type + likelihood_rating + (1 | workerId) + (1 | image) + (1 | stim_set), data=tbl_all, REML=FALSE)
summary(model3b)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: log ~ change_type + likelihood_rating + (1 | workerId) + (1 |  
##     image) + (1 | stim_set)
##    Data: tbl_all
## 
##      AIC      BIC   logLik deviance df.resid 
##  -5970.0  -5904.1   2995.0  -5990.0     5329 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7883 -0.5477 -0.1322  0.3356  5.2113 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  image    (Intercept) 0.001443 0.03799 
##  workerId (Intercept) 0.011673 0.10804 
##  stim_set (Intercept) 0.000000 0.00000 
##  Residual             0.015906 0.12612 
## Number of obs: 5339, groups:  image, 480; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                          Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)             9.991e-01  1.107e-02  7.542e+02  90.221  < 2e-16 ***
## change_typedisappear   -2.320e-02  7.690e-03  3.878e+02  -3.017  0.00272 ** 
## change_typemovement    -4.331e-02  1.166e-02  4.223e+02  -3.716  0.00023 ***
## change_typereplacement -2.591e-02  2.794e-02  3.927e+02  -0.927  0.35438    
## change_typesize        -5.305e-02  1.618e-02  4.155e+02  -3.278  0.00113 ** 
## likelihood_rating      -1.076e-02  1.767e-03  3.151e+03  -6.090 1.26e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) chng_typd chng_typm chng_typr chng_typs
## chng_typdsp -0.509                                        
## chng_typmvm -0.345  0.351                                 
## chng_typrpl -0.122  0.144     0.175                       
## chang_typsz -0.232  0.245     0.305     0.169             
## liklhd_rtng -0.521  0.022     0.176     0.026     0.094   
## convergence code: 0
## boundary (singular) fit: see ?isSingular
anova(model3a,model3b)
## Data: tbl_all
## Models:
## model3a: log ~ change_type + (1 | workerId) + (1 | image) + (1 | stim_set)
## model3b: log ~ change_type + likelihood_rating + (1 | workerId) + (1 | 
## model3b:     image) + (1 | stim_set)
##         npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)    
## model3a    9 -5937.1 -5877.8 2977.5  -5955.1                         
## model3b   10 -5970.0 -5904.1 2995.0  -5990.0 34.903  1  3.465e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

6 Predicting self vs. other.

6.1 Correlation between subject’s change detection RT and meta-awareness likelihood rating.

func1 <- function(tbl_all)
{
return(data.frame(corr_indiv = cor(tbl_all$log, tbl_all$likelihood_rating)))
}

tbl_corr_indiv <- ddply(tbl_all, .(workerId), func1)
tbl_corr_indiv$fisherZ_indiv <- .5*((log(1+tbl_corr_indiv$corr_indiv)) - (log(1-tbl_corr_indiv$corr_indiv)))

tbl_corr_indiv_no_NAs <- na.omit(tbl_corr_indiv)

6.2 Correlation between subject’s meta-awareness likelihood rating and group average change detection RT (without subject).

6.3 Compare means.

tbl_predict <- left_join(tbl_corr_indiv_no_NAs, tbl_corr_group_no_NAs, by = "workerId")

6.4 Correlations.

6.4.1 Non-transformed Correlations.

tbl_predict_corrs <- tbl_predict[, -c(3,5)]

tbl_predict_corrs  <- tbl_predict_corrs  %>%
  gather(key = "predicting", value = "corr", corr_indiv, corr_group)

tbl_predict_corrs %>%
  group_by(predicting) %>%
  get_summary_stats(corr, type = "mean_se")
## # A tibble: 2 x 5
##   predicting variable     n   mean    se
##   <chr>      <chr>    <dbl>  <dbl> <dbl>
## 1 corr_group corr       225 -0.231 0.015
## 2 corr_indiv corr       225 -0.12  0.017
tbl_predict_corrs %>%
  filter(workerId != "A372725XPFZ48Q") %>%
  with(t.test(corr~predicting,paired=TRUE))
## 
##  Paired t-test
## 
## data:  corr by predicting
## t = -5.8972, df = 223, p-value = 1.358e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.14961455 -0.07466636
## sample estimates:
## mean of the differences 
##              -0.1121405

6.4.2 FisherZ-transformed correlations.

tbl_predict_fisherZ <- tbl_predict[, -c(2,4)]

tbl_predict_fisherZ <- tbl_predict_fisherZ %>% 
    filter(workerId != "A372725XPFZ48Q")
  
indiv_ttest <-t.test(tbl_predict_fisherZ$fisherZ_indiv, mu = 0)
indiv_ttest
## 
##  One Sample t-test
## 
## data:  tbl_predict_fisherZ$fisherZ_indiv
## t = -7.0652, df = 223, p-value = 2.025e-11
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -0.15858091 -0.08941029
## sample estimates:
##  mean of x 
## -0.1239956
group_ttest <-t.test(tbl_predict_fisherZ$fisherZ_group, mu = 0)
group_ttest
## 
##  One Sample t-test
## 
## data:  tbl_predict_fisherZ$fisherZ_group
## t = -14.855, df = 223, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -0.2785286 -0.2132847
## sample estimates:
##  mean of x 
## -0.2459066
tbl_predict_fisherZ <- tbl_predict_fisherZ %>%
  gather(key = "predicting", value = "fisherZ", fisherZ_indiv, fisherZ_group)

tbl_predict_fisherZ %>%
  group_by(predicting) %>%
  get_summary_stats(fisherZ, type = "mean_sd")
## # A tibble: 2 x 5
##   predicting    variable     n   mean    sd
##   <chr>         <chr>    <dbl>  <dbl> <dbl>
## 1 fisherZ_group fisherZ    224 -0.246 0.248
## 2 fisherZ_indiv fisherZ    224 -0.124 0.263
tbl_predict_fisherZ %>%
  with(t.test(fisherZ~predicting,paired=TRUE))
## 
##  Paired t-test
## 
## data:  fisherZ by predicting
## t = -5.8602, df = 223, p-value = 1.648e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.16290737 -0.08091472
## sample estimates:
## mean of the differences 
##               -0.121911
tbl_predict_fisherZ %>%
  ggbarplot("predicting", "fisherZ", add = "mean_se",fill = "predicting", color = "predicting", palette = c("#0d2240", "#00a8e1"), ylab = "Average correlation", ylim = c(-0.3,0)) + theme(legend.position = "none") + scale_x_discrete(position = "top", labels=c("Individual", "Group")) + rremove("xlab")

#ggsave("bar1.jpg")

7 Deviation analysis.

df2$deviation <- df2$mean_detection_rt - df2$log

fit_log4 <- lmer(deviation ~ likelihood_rating + (1 | workerId) + (1 | image) + (1 | stim_set), data=df2)
## boundary (singular) fit: see ?isSingular
summary(fit_log4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: deviation ~ likelihood_rating + (1 | workerId) + (1 | image) +  
##     (1 | stim_set)
##    Data: df2
## 
## REML criterion at convergence: -5507
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.5246 -0.4335  0.1076  0.5783  4.1691 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  image    (Intercept) 0.0000000 0.00000 
##  workerId (Intercept) 0.0121009 0.11000 
##  stim_set (Intercept) 0.0001943 0.01394 
##  Residual             0.0184794 0.13594 
## Number of obs: 5336, groups:  image, 477; workerId, 231; stim_set, 4
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)       -8.970e-05  1.179e-02  6.251e+00  -0.008    0.994
## likelihood_rating  1.917e-04  1.613e-03  5.284e+03   0.119    0.905
## 
## Correlation of Fixed Effects:
##             (Intr)
## liklhd_rtng -0.427
## convergence code: 0
## boundary (singular) fit: see ?isSingular
ci(fit_log4)
##           Parameter CI       CI_low     CI_high
## 1       (Intercept) 95 -0.023190061 0.023010652
## 2 likelihood_rating 95 -0.002970335 0.003353695