Skip to content

Commit 2b414c6

Browse files
committed
checked
1 parent 5aa62b1 commit 2b414c6

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

R/prepare_effect_size_QA.Rmd

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ library(readxl)
1919
```
2020

2121
```{r}
22-
data<-readRDS("processed_data/TRACErecoded.RDS") # contains only included, recoded, data
22+
data<-readRDS("processed_data/TRACErecoded.RDS") # contains only included and recoded data
2323
str(data)
2424
```
2525

@@ -31,9 +31,9 @@ data1 <- data %>% mutate(
3131
new.idPTSD = as.factor(paste(PMID,idPTSD, sep=".")),
3232
new.idHC = as.factor(paste(PMID,idHC, sep=".")),
3333
id_combination = as.factor(paste(new.idPTSD, new.idHC, sep=".")))
34-
# for checking (should be NA, if both missing excluded in dataset)
35-
data1 %>% filter(is.na(semPTSD) & is.na(sdPTSD)) #%>% View()
36-
data1 %>% filter(is.na(semHC) & is.na(sdHC)) #%>% View()
34+
# Confirm absence of missing data
35+
data1 %>% filter(is.na(semPTSD) & is.na(sdPTSD))
36+
data1 %>% filter(is.na(semHC) & is.na(sdHC))
3737
```
3838

3939
### Check which control groups are used multiple times
@@ -87,7 +87,7 @@ data3$sdPTSD <- ifelse(is.na(data3$sdPTSD), (data3$semPTSD * sqrt(data3$nPTSD)),
8787
data3$sdHC <- ifelse(is.na(data3$sdHC), (data3$semHC * sqrt(data3$nHC)), data3$sdHC)
8888
```
8989

90-
## Check Missing values (should be none)
90+
## Confirm no missing values
9191
```{r}
9292
#' Sample sizes ok
9393
which(is.na(data3$nPTSD))
@@ -102,13 +102,8 @@ which(is.na(data3$sdHC))
102102
#' dat %>% filter(!is.na(sdC)) -> dat
103103
data3 %>% select(-c(semPTSD, semHC, idPTSD, idHC, used, nHC_corrected)) -> data4 # Remove unnecessary columns
104104
105-
#' Missingvalues are checked again, should be non.. # update 8.4.21 -> there are missings.. as shock, time res.sus split are still in data
106-
# which(is.na(data1))
107-
108-
data4 %>% select(!c("shocks.num", "shocks.amp", "time","res.sus.split")) %>% filter(!(is.na(.))) %>% nrow() # is idem als total (=1643)
109-
110-
#' update 19.3.19: na toevoeging "keyfinding", sommmige na, anders niet.
111-
# head(is.na(data1))
105+
# check which column contain missing values (confirm they are not in n, sd/sem, m)
106+
colnames(data4)[ apply(data4, 2, anyNA) ]
112107
```
113108

114109
## Calculation of effect sizes and checks
@@ -118,20 +113,17 @@ data5 <- escalc(
118113
m2i = meanHC, sd2i = as.numeric(sdHC), n2i = nHC,
119114
measure = "SMD", #method = "HE", # calc hedge's G
120115
data = data4)
116+
#' INTERPRETATION: Viechtbauer, W. (2010). Conducting Meta-Analyses in R with the metafor Package. Journal of Statistical Software, 1–48. Page 7
117+
#' "SMD": The standardized mean difference is equal to (m1i m2i)/spi
118+
#' In the calulations above 1 = ptsd en 2 = control; therefore positive effect size = PTSD more, negative effectsize is HC more
121119
```
122120

123121
## Recode Effect sizes in same direction (higher score = better performance)
124-
NB variable recode contains extinction recode codes were higher scores (higher anxiety) is coded as more memory persistence (would correspond to less extinction)
122+
NB variable 'recode.for.ext' (originally specified in "Trace_methode_codes.csv") contains extinction recode codes for measures where higher scores (e.g. higher anxiety) corresponds to stronger memory persistence (e.g. less extinction)
125123

126124
```{r}
127125
#' Based on recode variable, which is specified in "Trace_methode_codes.csv"
128-
# data5$yi <- data5$yi * data5$recode
129126
data5$yi <- data5$yi * data5$recode.for.ext
130-
131-
#' INTERPRETATION: Viechtbauer, W. (2010). Conducting Meta-Analyses in R with the metafor Package. Journal of Statistical Software, 1–48. Page 7
132-
#' "SMD": The standardized mean difference is equal to (m1i m2i)/spi
133-
#' In the calulations above 1 = ptsd en 2 = control; therefore positive effect size = PTSD more, negative effectsize is HC more
134-
135127
```
136128

137129
## add unique id's
@@ -149,12 +141,12 @@ bind_rows(QA.A, QA.H) %>% mutate(PMID = as.character(PMID))->QA
149141
left_join(data5, QA, by="PMID") %>% droplevels() -> data6 #drop missing levels & Remove 'unique id combination' variable (not needed anymore)
150142
```
151143

152-
#for checking
144+
# Confirm absence of missing values (if method codes are added correctly)
153145
```{r eval=FALSE, include=FALSE}
154-
data6 %>% select(type, phase, valence, recode, cuectx) %>% is.na() %>% any() # must be false (if method codes are added correctly)
146+
data6 %>% select(type, phase, valence, recode, cuectx) %>% is.na() %>% any()
155147
```
156148

157-
# Save resulting dataset --------------------------------------------------
149+
# Save resulting dataset
158150
```{r}
159151
saveRDS(data6, file = "processed_data/TRACEprepared.RData") #save
160152
```

0 commit comments

Comments
 (0)