Data

Load libraries

# Install necessary packages
if (!requireNamespace("changeofevidence")) {
  if (!requireNamespace("remotes")) install.packages("remotes")
  remotes::install_github("mrzdcmps/changeofevidence")
}
if (!requireNamespace("psych")) install.packages("psych")

# load libraries
library(psych)
library(changeofevidence)

Read Files

## read files
df <- read.csv2("psyscanner-data.csv")

## convert to correct var types
df$date <- as.POSIXct(df$date)
df$Sex <- as.factor(df$Sex)

Calculate scores and create groups

# calculate questionnaire scores
df$score.de <- rowMeans(df[,c(10,12,15,20:21,23:24,26,32,35)])
df$score.av <- rowMeans(df[,c(14,17,18,22,25,27,29:30,33,36)])
df$score.oc <- rowMeans(df[,c(8,9,11,13,16,19,28,31,34,37)])
df$score.t <- rowMeans(df[,c(42:44)])

# specify high vs low characteristic based on questionnaire score
df$de.group <- ifelse(df$score.de >= 2, "high", "low") #dependent
df$av.group <- ifelse(df$score.av >= 2, "high", "low") #avoidant
df$oc.group <- ifelse(df$score.oc >= 2, "high", "low") #obsessive-compulsive

# create groups
de.h <- subset(df, df$de.group == "high")
de.l <- subset(df, df$de.group == "low")

av.h <- subset(df, df$av.group == "high")
av.l <- subset(df, df$av.group == "low")

oc.h <- subset(df, df$oc.group == "high")
oc.l <- subset(df, df$oc.group == "low")

Load BFs from file

load("bfs.RData")

Change of evidence measures

Load sims

sims.e <- readRDS("sims-e2.rds") #exp sims
sims.c <- readRDS("sims-c2.rds") #con sims

Construct simlengths for each condition

sims.de.h <- simredo(sims.e, nrow(de.h))
sims.de.l <- simredo(sims.c, nrow(de.l))
sims.av.h <- simredo(sims.e, nrow(av.h))
sims.av.l <- simredo(sims.c, nrow(av.l))
sims.oc.h <- simredo(sims.e, nrow(oc.h))
sims.oc.l <- simredo(sims.c, nrow(oc.l))

Target groups

Dependent: DE-PT-high

r.max.de.h <- maxbf(de.h.bf, sims.de.h)
## >> MAXIMUM BF << 
## Highest BF: 12.92434 ( at N = 825 ) 
## Sims with this or a higher BFs: 6.4 %
r.nrg.de.h <- energybf(de.h.bf, sims.de.h)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  4220.349 
## Sims Energy: M = -86.49668 , SD = 3304.775 
## Sims with this or higher Energy: 3.4 %
r.fft.de.h <- ffttest(fftcreate(de.h.bf), sims.de.h)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  700 
## Sum of Amplitudes: 17.40171 
## Sims Amplitude Sums: M = 5.143038 SD = 22.20451 
## Simulations with this or higher amplitude sum: 4.6 %

Avoidant: DE-AV-high

r.max.av.h <- maxbf(av.h.bf, sims.av.h)
## >> MAXIMUM BF << 
## Highest BF: 3.204073 ( at N = 355 ) 
## Sims with this or a higher BFs: 24.6 %
r.nrg.av.h <- energybf(av.h.bf, sims.av.h)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  -100.4807 
## Sims Energy: M = -96.96872 , SD = 2781.774 
## Sims with this or higher Energy: 19.7 %
r.fft.av.h <- ffttest(fftcreate(av.h.bf), sims.av.h)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  654 
## Sum of Amplitudes: 3.625583 
## Sims Amplitude Sums: M = 5.121778 SD = 23.03417 
## Simulations with this or higher amplitude sum: 20.8 %

Obsessive-compulsive: DE-OC-high

r.max.oc.h <- maxbf(oc.h.bf, sims.oc.h)
## >> MAXIMUM BF << 
## Highest BF: 2.390554 ( at N = 187 ) 
## Sims with this or a higher BFs: 34.2 %
r.nrg.oc.h <- energybf(oc.h.bf, sims.oc.h)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  -336.5554 
## Sims Energy: M = -87.17479 , SD = 3635.507 
## Sims with this or higher Energy: 24.5 %
r.fft.oc.h <- ffttest(fftcreate(oc.h.bf), sims.oc.h)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  731 
## Sum of Amplitudes: 2.959895 
## Sims Amplitude Sums: M = 5.242747 SD = 23.59487 
## Simulations with this or higher amplitude sum: 27.1 %

Plot target groups: BF with 500 sims

plotbf(de.h.bf, sims.df = subset(sims.de.h, simid <= 500))
## 
## Attache Paket: 'ggplot2'
## Die folgenden Objekte sind maskiert von 'package:psych':
## 
##     %+%, alpha
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"
## Warning: Transformation introduced infinite values in continuous y-axis

plotbf(av.h.bf, sims.df = subset(sims.av.h, simid <= 500))
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"
## Warning: Transformation introduced infinite values in continuous y-axis

plotbf(oc.h.bf, sims.df = subset(sims.oc.h, simid <= 500))
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"
## Warning: Transformation introduced infinite values in continuous y-axis

Plot target groups: FFT with 500 sims

plotfft(fftcreate(de.h.bf), sims.df = subset(sims.de.h, simid <= 500))

plotfft(fftcreate(av.h.bf), sims.df = subset(sims.av.h, simid <= 500))

plotfft(fftcreate(oc.h.bf), sims.df = subset(sims.oc.h, simid <= 500))

Control groups

Dependent: DE-PT-low

r.max.de.l <- maxbf(de.l.bf, sims.de.l)
## >> MAXIMUM BF << 
## Highest BF: 1 ( at N = 1 ) 
## Sims with this or a higher BFs: 100 %
r.nrg.de.l <- energybf(de.l.bf, sims.de.l)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  -506.4739 
## Sims Energy: M = -262.84 , SD = 832.5058 
## Sims with this or higher Energy: 55.3 %
r.fft.de.l <- ffttest(fftcreate(de.l.bf), sims.de.l)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  502 
## Sum of Amplitudes: 1.102207 
## Sims Amplitude Sums: M = 2.794078 SD = 5.106257 
## Simulations with this or higher amplitude sum: 96.5 %

Avoidant: DE-AV-low

r.max.av.l <- maxbf(av.l.bf, sims.av.l)
## >> MAXIMUM BF << 
## Highest BF: 5.910291 ( at N = 936 ) 
## Sims with this or a higher BFs: 7.5 %
r.nrg.av.l <- energybf(av.l.bf, sims.av.l)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  1012.429 
## Sims Energy: M = -300.2585 , SD = 917.3002 
## Sims with this or higher Energy: 3.6 %
r.fft.av.l <- ffttest(fftcreate(av.l.bf), sims.av.l)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  548 
## Sum of Amplitudes: 6.740856 
## Sims Amplitude Sums: M = 2.840754 SD = 5.175428 
## Simulations with this or higher amplitude sum: 5.7 %

Obsessive-compulsive: DE-OC-low

r.max.oc.l <- maxbf(oc.l.bf, sims.oc.l)
## >> MAXIMUM BF << 
## Highest BF: 2.90654 ( at N = 17 ) 
## Sims with this or a higher BFs: 20.1 %
r.nrg.oc.l <- energybf(oc.l.bf, sims.oc.l)
## >> BF ENERGY << 
## Calculating Energy of sims... 
## 
##  Energy of BF of data:  -530.1571 
## Sims Energy: M = -239.7921 , SD = 764.4338 
## Sims with this or higher Energy: 79.5 %
r.fft.oc.l <- ffttest(fftcreate(oc.l.bf), sims.oc.l)
## >> FREQUENCY ANALYSIS << 
## 
## Number of Frequencies:  471 
## Sum of Amplitudes: 1.953752 
## Sims Amplitude Sums: M = 2.766226 SD = 5.078376 
## Simulations with this or higher amplitude sum: 34.1 %

Plot control groups: BF with 500 sims

plotbf(de.l.bf, sims.df = subset(sims.de.l, simid <= 500))
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"

plotbf(av.l.bf, sims.df = subset(sims.av.l, simid <= 500))
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"

plotbf(oc.l.bf, sims.df = subset(sims.oc.l, simid <= 500))
## [1] "Depending on the amount of simulations to be drawn, this might take a while!"

Plot target groups: FFT with 500 sims

plotfft(fftcreate(de.l.bf), sims.df = subset(sims.de.l, simid <= 500))

plotfft(fftcreate(av.l.bf), sims.df = subset(sims.av.l, simid <= 500))

plotfft(fftcreate(oc.l.bf), sims.df = subset(sims.oc.l, simid <= 500))