-
Notifications
You must be signed in to change notification settings - Fork 6
/
hypotheses.Rmd
815 lines (618 loc) · 27.8 KB
/
hypotheses.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
---
title: 'Regulation of pupil size in natural vision - hypotheses'
date: "`r format(Sys.Date(), format = '%d %b %Y')`"
output:
html_document:
df_print: paged
code_folding: show
keep_md: no
number_sections: yes
toc: yes
toc_depth: 5
toc_float: yes
pdf_document:
number_sections: yes
editor_options:
chunk_output_type: console
---
```{r, echo = FALSE, include = FALSE}
knitr::opts_chunk$set(fig.width = 5, fig.height = 5, echo = TRUE, eval = TRUE, message = TRUE, warning = FALSE, error = TRUE, cache = FALSE, cache.path = "cache/", cache.extra = 1, fig.path = paste0("figures/", knitr::opts_chunk$get("fig.path")), dev = c("png"))
```
```{r load, warning = FALSE, message = FALSE, include = FALSE}
#Libraries
library(BayesFactor)
library(tidyverse)
set.seed(20230703)
```
In the first section <span style="color: blue;">*[1] Loading subdatasets*</span> we load the `conf_subdata.rda` file, which includes an image of the environment with all subdatasets generated from the `50_subdatasets.R` code.
```{r [1]-Loading-subdatasets}
###[0] Loading subdatasets------------------------------------------------------
load(file="./05_analysis/subdata/conf_subdata.rda")
```
In section <span style="color: blue;">*[2] Testing log-transformation*</span> we run additional analyses regarding the log-10 transformation of the light data. After realizing that the linear light data violate the assumptions of linear regression models, we generated log10-transformed light variables with which the requirements were approximately met. Here, we additionally tested whether the transformation improved the fit in the LMM, comparing the model with log10 transformation against a null model with linear light data in the same procedure as our hypothesis tests specified in the pre-registered analysis. The BF10 clearly shows evidence in favour of log10-transformation.
```{r [2]-Testing-log10-transformation}
###[2] Testing-log10-transformation---------------------------------------------------
# comparing model fit log10 vs. linear mEDI
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#full model (numerator) log10-transformed
set.seed(20230703)
CH1blog_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator) linear (no transformation)
set.seed(20230703)
CH1blog_denominator <- lmBF(diameter_3d ~ Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH1blog <-compare(CH1blog_numerator, CH1blog_denominator)
summary(BF_CH1blog)
#extract ln of the BF
extractBF(BF_CH1blog, logbf = T, onlybf = T)
#convert to log10
extractBF(BF_CH1blog, logbf = T, onlybf = T) / log(10)
```
In code section <span style="color: blue;">*[3] Positive control tests*</span> we test our confirmatory hypotheses in the controlled laboratory conditions as positive control tests.
First, we tested hypothesis CH1 with the linear models specified in stage 1 of our report with data from our laboratory conditions (subdataset "Labdata"). The models are tested with log10-transformed and linear (non-transformed) mEDI as a predictor.
```{r [3]-Positive-control-tests CH1}
###[3] Positive control tests---------------------------------------------------
# Positive control: CH1 in Lab data
#computing BF10: likelihood ratio of full model vs. null model
# including Laboratory data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
CH1a_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH1a_denominator <- lmBF(diameter_3d ~ age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH1a <- compare(CH1a_numerator, CH1a_denominator)
summary(BF_CH1a)
#extract ln of the BF
extractBF(BF_CH1a, logbf = T, onlybf = T)
#convert to log10
extractBF(BF_CH1a, logbf = T, onlybf = T) / log(10)
# Positive control: CH1 in Lab data
#computing BF10: likelihood ratio of full model vs. null model
# including Laboratory data only
#linear (non-transformed) light data
#full model (numerator)
set.seed(20230703)
CH1ax_numerator<- lmBF(diameter_3d ~ Mel_EDI + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH1ax_denominator <- lmBF(diameter_3d ~ age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH1ax <- compare(CH1ax_numerator, CH1ax_denominator)
summary(BF_CH1ax)
#extract ln of the BF
extractBF(BF_CH1ax, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH1ax, logbf = T, onlybf = T)/ log(10)
```
Secondly, we tested hypothesis CH2 with the linear models specified in stage 1 of our report with data from our laboratory conditions (subdataset "Labdata"). Note that under these conditions, the light units mEDI and photopic lux are somewhat dissociated. Again, the test is once run for a model including the log10-transformed light data (mEDI and photopic illuminance) and once with non-transformed light data.
```{r [3]-Positive-control-tests CH2}
# Positive control: CH2 in Lab data
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
CH2a_numerator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH2a_denominator <- lmBF(diameter_3d ~ log_phot_lux + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH2_lab <- compare(CH2a_numerator, CH2a_denominator)
summary(BF_CH2_lab)
#extract ln of the BF
extractBF(BF_CH2_lab, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH2_lab, logbf = T, onlybf = T)/ log(10)
# Positive control: CH2 in Lab data
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#linear (non-transformed) light data
#full model (numerator)
set.seed(20230703)
CH2ax_numerator <- lmBF(diameter_3d ~ Mel_EDI + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH2ax_denominator <- lmBF(diameter_3d ~ phot_lux + age + id + sex,
data = Labdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH2x_lab <- compare(CH2ax_numerator, CH2ax_denominator)
summary(BF_CH2x_lab)
#extract ln of the BF
extractBF(BF_CH2x_lab, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH2x_lab, logbf = T, onlybf = T)/ log(10)
```
Lastly, we test our age hypothesis CH3 in the data from the 10-minute dark adaptation (subdataset "Darkdata") as a positive control, where we expected the age effect to be most pronounced. In the tested models, no light variables are used as a predictor because these samples were taken in darkness, where the light measurements are not valid.
```{r [3]-Positive-control-tests CH3}
# Positive control: CH3 in Dark data
#computing BF10: likelihood ratio of full model vs. null model
# including Dark adapation data only
#linear (non-transformed) light data
#full model (numerator)
set.seed(20230703)
CH3c_numerator<- lmBF(diameter_3d ~ age + id + sex, data = Darkdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH3c_denominator <- lmBF(diameter_3d ~ id + sex, data = Darkdata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH3c <- compare(CH3c_numerator, CH3c_denominator)
summary(BF_CH3c)
#extract ln of the BF
extractBF(BF_CH3c, logbf = T, onlybf = T)
extractBF(BF_CH3c, logbf = T, onlybf = T)/ log(10)
```
In the code given in <span style="color: blue;">*[4] Hypothesis testing - CH1*</span> , we test our confirmatory hypothesis CH1 in the data from the field condition (subdataset "Fielddata"). First, we conduct the test with models including the log10-transformed mEDI predictor and then secondly with the linear mEDI predictor.
<span style="color: green;">*CH1: In real-world conditions, light-adapted pupil size changes as a function of melanopsin sensitivity-weighted retinal illumination with higher illumination associated with a smaller pupil size.*</span>
```{r [4]-Hypothesis-testing:-CH1-log10-transformed}
### [4] Hypothesis testing - CH1---------------------------------------------------
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
CH1b_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH1b_denominator <- lmBF(diameter_3d ~ age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH1b <- compare(CH1b_numerator, CH1b_denominator)
summary(BF_CH1b)
#extract ln of the BF
extractBF(BF_CH1b, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH1b, logbf = T, onlybf = T)/ log(10)
```
CH1 test with the linear (non-transformed) melanopic Equivalent Daylight Illuminance (mEDI) predictor:
```{r [4]-Hypothesis-testing:-CH1-linear-data}
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#linear light data (no log10 transformation)
#full model (numerator)
set.seed(20230703)
CH1bx_numerator<- lmBF(diameter_3d ~ Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH1bx_denominator <- lmBF(diameter_3d ~ age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH1bx <-compare(CH1bx_numerator, CH1bx_denominator)
summary(BF_CH1bx)
#extract ln of the BF
extractBF(BF_CH1bx, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH1bx, logbf = T, onlybf = T)/ log(10)
```
In the code given in <span style="color: blue;">*[5] Hypothesis testing - CH2*</span> , we test our confirmatory hypothesis CH2 in the data from the field condition (subdataset "Fielddata"). First, we conduct the test with models including the log10-transformed mEDI and photopic illuminance predictors and then secondly with the linear mEDI and photopic illuminance predictors.
<span style="color: green;">*CH2: In real-world conditions, melanopsin sensitivity-weighted retinal illumination better predicts pupil size than the weighted sum of L- and M-cone weighted retinal illumination (CIE 1931 Y, photopic illuminance).*</span>
```{r [5]-Hypothesis-testing:-CH2-log10-transformed}
### [5] Hypothesis testing - CH2----------------------------------------------------
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
CH2b_numerator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH2b_denominator <- lmBF(diameter_3d ~ log_phot_lux + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH2b <- compare(CH2b_numerator, CH2b_denominator)
summary(BF_CH2b)
#extract ln of the BF
extractBF(BF_CH2b, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH2b, logbf = T, onlybf = T)/ log(10)
```
CH2 test with the linear (non-transformed) melanopic Equivalent Daylight Illuminance (mEDI) and photopic illuminance predictors:
```{r [5]-Hypothesis-testing:-CH2-linear-data}
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#linear light data (no log10 transformation)
#full model (numerator)
set.seed(20230703)
CH2bx_numerator <- lmBF(diameter_3d ~ Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH2bx_denominator <- lmBF(diameter_3d ~ phot_lux + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH2bx <- compare(CH2bx_numerator, CH2bx_denominator)
summary(BF_CH2bx)
#extract ln of the BF
extractBF(BF_CH2bx, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH2bx, logbf = T, onlybf = T)/ log(10)
```
To double check that our tests conducted with the "BayesFactors" package were valid, we additionally ran a test comparing the two models defined with a function from the *lme4* & *lmerTest* packages ("lmer") and compared the two models from CH2 regarding their Bayesian Information Criterion (BIC). The resulting BIC value for the full model is lower for the full model than with the null model, confirming the results from the BayesFactor analysis.
We then approximated the the Bayes factors from BICs computed in the *lme4* package using the equation by [Wagenmakers (2007)](https://doi.org/10.3758/BF03194105), retrieved from [Stevens (2019)](https://osf.io/eszbd), resulting in very similar Bayes Factor magnitudes.
```{r [5]-Hypothesis-testing:-CH2-BIC-validation, warning=FALSE}
#loading required packages
library(lme4)
library(lmerTest)
#Testing the models against each other with BICs from the lm4e package
#these tests are only used as a double check to
#"validate" our procedure with the BayesFactor package
#formulate models with lmerTest package
set.seed(20230703)
(CH2_NHST_H1<-lmer(diameter_3d ~ log_Mel_EDI + age + (1|id) + (1|sex), Fielddata))
set.seed(20230703)
(CH2_NHST_H0<-lmer(diameter_3d ~ log_phot_lux + age + (1|id) + (1|sex), Fielddata))
#compute a model comparison with Bayesian information criterion
# the lower the BIC, the better the model fit
set.seed(20230703)
BIC_CH2<- BIC(CH2_NHST_H0,CH2_NHST_H1)
BIC_CH2
#BIC is lower with log10(mEDI) than with log10(photopic lux)
#Approximating Bayes factors from BICs using the equation by Wagenmakers (2007),
#retrieved from Stevens (2019) https://osf.io/eszbd
#function for converting BICs into BFs (retrieved from Stevens (2019) https://osf.io/eszbd )
bic_bf10 <- function(null, alternative) {
new_bf <- exp((null - alternative) / 2) # convert BICs to Bayes factor
names(new_bf) <- NULL # remove BIC label
return(new_bf) # return Bayes factor of alternative over null hypothesis
}
#compute BIC for each model of CH2 defined earlier
set.seed(20230703)
CH2_H1_bic<- BIC(CH2_NHST_H1)
set.seed(20230703)
CH2_H0_bic<- BIC(CH2_NHST_H0)
set.seed(20230703)
#convert the BICs into an approximated BF10 factor
bic_bf10(CH2_H0_bic,CH2_H1_bic)
#ln(approx. BF10)
log(bic_bf10(CH2_H0_bic,CH2_H1_bic))
#log10(approx. BF10)
log10(bic_bf10(CH2_H0_bic,CH2_H1_bic))
#result very similar to the BF10 computed with BayesFactor package.
# Repeating the BIC test using the non-log10 transformed light intensity vars
set.seed(20230703)
(CH2_NHST_nolog_H1<-lmer(diameter_3d ~ Mel_EDI + age + (1|id) + (1|sex), Fielddata))
set.seed(20230703)
(CH2_NHST_nolog_H0<-lmer(diameter_3d ~ phot_lux + age + (1|id) + (1|sex), Fielddata))
set.seed(20230703)
BIC(CH2_NHST_nolog_H0, CH2_NHST_nolog_H1)
#the model with log10(mEDI) (H1) has a lower BIC and is preferred.
#compute BIC for each model of CH2 without log10 transformation
set.seed(20230703)
CH2_H1_nolog_bic<- BIC(CH2_NHST_nolog_H1)
set.seed(20230703)
CH2_H0_nolog_bic<- BIC(CH2_NHST_nolog_H0)
set.seed(20230703)
#convert the BICs into an approximated BF10 factor
bic_bf10(CH2_H0_nolog_bic,CH2_H1_nolog_bic)
#results very similar to the BF10 computed with BayesFactor package.
#ln of approx. BF10 factor
log(bic_bf10(CH2_H0_nolog_bic,CH2_H1_nolog_bic))
#log10 of approx. BF10 factor
log10(bic_bf10(CH2_H0_nolog_bic,CH2_H1_nolog_bic))
```
In the code given in <span style="color: blue;">*[6] Hypothesis testing - CH3*</span> , we test our confirmatory hypothesis CH3 in the data from the field condition (subdataset "Fielddata"). First, we conduct the test with models including the log10-transformed mEDI predictor and then secondly with the linear mEDI predictor.
<span style="color: green;">*CH3: In real-world conditions, light-adapted pupil size changes as a function of age, with higher age associated with a smaller pupil size.*</span>
```{r [6] Hypothesis-testing:-CH3-log10-transformed}
### [6] Hypothesis testing - CH3-------------------------------------------------------------------------
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
CH3b_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex, data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH3b_denominator <- lmBF(diameter_3d ~ log_Mel_EDI + id + sex, data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH3b <- compare(CH3b_numerator, CH3b_denominator)
summary(BF_CH3b)
#extract ln of the BF
extractBF(BF_CH3b, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH3b, logbf = T, onlybf = T)/ log(10)
```
CH3 test with the linear (non-transformed) melanopic Equivalent Daylight Illuminance (mEDI) predictor:
```{r [6] Hypothesis-testing:-CH3-linear-data}
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#linear light data (no log10 transformation)
#full model (numerator)
set.seed(20230703)
CH3bx_numerator<- lmBF(diameter_3d ~ Mel_EDI + age + id + sex, data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
CH3bx_denominator <- lmBF(diameter_3d ~ Mel_EDI + id + sex, data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
BF_CH3b_nolog <- compare(CH3bx_numerator, CH3bx_denominator)
summary(BF_CH3b_nolog)
#extract ln of the BF
extractBF(BF_CH3b_nolog, logbf = T, onlybf = T)
#convert into log10
extractBF(BF_CH3b_nolog, logbf = T, onlybf = T)/ log(10)
```
In the code section <span style="color: blue;">*[7] Exploratory analyses - EH*</span> we analyse our exploratory analyses specified in the Stage 2 RR manuscript. The analysis procedure corresponds to the confirmatory hypotheses. However, we only include log10-transformed mEDI as a predictor in these cases.
- *EH1: Sex differences in light-adapted pupil size are present under real-world conditions.*
- *EH2: Light-adapted pupil size varies as a function of iris colour under real-world conditions.*
- *EH3: Light-adapted pupil size varies as a function of habitual caffeine consumption (relative to body weight) under real-world conditions.*
- *EH4: Light-adapted pupil size varies as a function of the acute caffeine consumption (relative to body weight) under real-world conditions.*
Sex differences:
```{r [7]-Exploratory-analyses: sex differences}
### [7] Exploratory analyses - EH-----------------------------------------------
# Sex differences
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
sexdif_field_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
sexdif_field_denominator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
sexdif_field <- compare(sexdif_field_numerator, sexdif_field_denominator)
summary(sexdif_field)
#extract ln of the BF
extractBF(sexdif_field, logbf = T, onlybf = T)
#convert into log10
extractBF(sexdif_field, logbf = T, onlybf = T)/ log(10)
# strong evidence for the null model
```
Caffeine consumption:
```{r [7]-Exploratory-analyses: caffeine consumption}
#Caffeine consumption-
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
caf_field_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex + acute_sum_rel,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
caf_field_denominator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
caf_field <- compare(caf_field_numerator, caf_field_denominator)
summary(caf_field)
#extract ln of the BF
extractBF(caf_field, logbf = T, onlybf = T)
#convert into log10
extractBF(caf_field, logbf = T, onlybf = T)/ log(10)
# --> moderate evidence for null model
#habitual caffeine in the field data
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
hcaf_field_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex + habitual_sum_rel,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
hcaf_field_denominator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
hcaf_field<- compare(hcaf_field_numerator, hcaf_field_denominator)
summary(hcaf_field)
#extract ln of the BF
extractBF(hcaf_field, logbf = T, onlybf = T)
#convert into log10
extractBF(hcaf_field, logbf = T, onlybf = T)/ log(10)
# moderate evidence for null model
```
Iris colour:
```{r [7]-Exploratory-analyses: iris colour}
# iris colour
#computing BF10: likelihood ratio of full model vs. null model
# including Field data only
#log10-transformed light data
#full model (numerator)
set.seed(20230703)
iris_field_numerator<- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex + iris_colour,
data = Fielddata,
whichRandom = c("id","sex", "iris_colour"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#null model (denominator)
set.seed(20230703)
iris_field_denominator <- lmBF(diameter_3d ~ log_Mel_EDI + age + id + sex,
data = Fielddata,
whichRandom = c("id","sex", "iris_colour"),
progress = FALSE,
posterior = TRUE,
iterations = 10000
)
#comparison of full div. by null model
set.seed(20230703)
iris_field <- compare(iris_field_numerator, iris_field_denominator)
summary(iris_field)
#extract ln of the BF
extractBF(iris_field, logbf = T, onlybf = T)
#convert into log10
extractBF(iris_field, logbf = T, onlybf = T)/ log(10)
# strong evidence for null model
```