source("../Utilities/Utilities-Main.R")
source("../Utilities/Utilities-Extra.R")

### Correlation for EFF calculated in other files already

### Correlation for IS and CON
data_IS <- data_FFM %>% filter(DV == 2 & INCLUDE_IN_ANALYSIS == 2 & DV_TYPE == 1)
format_file(BF_analysis(data_IS, IV_name = "IV")$overall)[c("E","A","C","N","O"),]

data_CON <- data_FFM %>% filter(DV == 2 & INCLUDE_IN_ANALYSIS == 2 & DV_TYPE == 5)
format_file(BF_analysis(data_CON, IV_name = "IV")$overall)[c("E","A","C","N","O"),]


### FFM Intercorrelations
intercorrelation_data <- as.data.frame(readxl::read_excel("../../DataSet/FFM_INTERCORRELATIONS.xlsx", sheet = "FFM_Corr"))
intercorrelation_data <- intercorrelation_data %>% filter(is.na(`Exclude Reason`)) %>% filter(N < 10000)

## 114 Primary studies
length(table(intercorrelation_data$Article_ID)) - 8

EA_data <- intercorrelation_data %>% filter(x %in% c("E", "A") & y %in% c("E", "A"))
EC_data <- intercorrelation_data %>% filter(x %in% c("E", "C") & y %in% c("E", "C"))
EN_data <- intercorrelation_data %>% filter(x %in% c("E", "ES") & y %in% c("E", "ES"))
EO_data <- intercorrelation_data %>% filter(x %in% c("E", "O") & y %in% c("E", "O"))

AC_data <- intercorrelation_data %>% filter(x %in% c("A", "C") & y %in% c("A", "C"))
AN_data <- intercorrelation_data %>% filter(x %in% c("A", "ES") & y %in% c("A", "ES"))
AO_data <- intercorrelation_data %>% filter(x %in% c("A", "O") & y %in% c("A", "O"))

CN_data <- intercorrelation_data %>% filter(x %in% c("C", "ES") & y %in% c("C", "ES"))
CO_data <- intercorrelation_data %>% filter(x %in% c("C", "O") & y %in% c("C", "O"))

NO_data <- intercorrelation_data %>% filter(x %in% c("ES", "O") & y %in% c("ES", "O"))

## Here we get the intercorrelations and the corresponding SD_rho
calculation(EA_data)$details
calculation(EC_data)$details
calculation(EN_data)$details
calculation(EO_data)$details
calculation(AC_data)$details
calculation(AN_data)$details
calculation(AO_data)$details
calculation(CN_data)$details
calculation(CO_data)$details
calculation(NO_data)$details

