-
Notifications
You must be signed in to change notification settings - Fork 1
/
apples_and_oranges.qmd
2134 lines (1611 loc) · 110 KB
/
apples_and_oranges.qmd
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
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: Fundamental Problems with the Evidence Base of Adolescent Depression Treatments.
author:
- name: Argyris Stringaris
email: [email protected]
affiliations:
- id: ucl_1
name: University College London
department: Divisions of Psychiatry and Psychology and Language Science
address: 1-19 Torrington Place
city: London, UK
state:
postal-code: WC1E 7HB
country: United Kingdom
attributes:
corresponding: true
note:
- name: Charlotte Burman
email: [email protected]
affiliations:
- ref: ucl_1
note:
- name: Dayna Bhudia
email: [email protected]
affiliations:
- ref: ucl_1
- name: Despina Miliou
email: [email protected]
affiliations:
- ref: ucl_1
- name: Giannis Rokas
email: <[email protected]
affiliations:
- ref: ucl_1
- name: Lucy Foulkes
email: [email protected]
affiliations:
- id: OU
name: University of Oxford
department: Experimental Psychology
address: Anna Watts Building, Radcliffe Observatory Quarter, Woodstock Road
city: Oxford
postal-code: OX2 6GG
country: United Kingdom
note:
- name: Carmen Moreno
email: [email protected]
affiliations:
- id: HGM
name: Hospital Gregorio Marañón
department: Department of Psychiatry
address: 46 C. del Dr. Esquerdo
city: Madrid
state:
postal-code: 28007
country: Spain
- name: Samuele Cortese
email: [email protected]
affiliations:
- id: soton
name: University of Southampton
department: Centre for Innovation in Mental Health (CIMH), School of Psychology
address: Highfield Campus, Building 44
city: Southampton
state:
postal-code: SO17 1BJ
country: United Kingdom
- name: Georgina Krebs
email: [email protected]
affiliations:
- ref: ucl_1
note:
abstract: |
To follow
keywords:
- depression
- adolescents
- antidepressants
- psychotherapy
date: last-modified
bibliography: emotion_concepts_paper.bib
format:
elsevier-pdf:
keep-tex: true
journal:
name: Journal Name
formatting: preprint
model: 3p
cite-style: super
---
# Introduction
There are two principal treatment modalities for adolescent depression: psychotherapy, medication, or both. Where does one turn to find the evidence that will inform their treatment options? This question is relevant for patients and their carers, for clinicians and for policy makers when they plan services. However, the question is particularly difficult to answer for adolescent depression, where there are limited data from head-to-head trials of medication and psychotherapy, and where recommendations must therefore be derived from indirect comparisons of treatment efficacy.
Guidelines, such as the ones that the internationally influential UK National Institute of Clinical Excellence (NICE) have produced for adolescent depression, are a principal source of such information. NICE recommend that youth be first offered psychological therapy (specifically cognitive behaviour therapy and interpersonal therapy) over medication for most presentations of depression. This conclusion is in keeping with two sources of evidence. On the one hand, medication meta-analyses that cast doubt on the efficacy of most antidepressants, with the exception of fluoxetine (ref); and on the other hand, psychotherapy meta-analyses that conclude psychotherapy to be effective for adolescent depression (ref). However, such conclusions seem at odds with those of a recent network meta-analysis (ref), an established method of comparing treatments with each other using both direct (head-to-head) and indirect (indirectly treatment A with treatment C, via studies that directly compare treatments A with B and B with C) evidence. Indeed, the network meta-analysis concluded that only fluoxetine alone and fluoxetine administered together with CBT were significantly more effective than pill placebo or psychological controls. Given this confusing evidence base, how should patients, carers, clinicians and policy makers make decisions on treatment options for adolescent depression?
In this paper, we examine whether the existing evidence base for adolescent depression treatment can offer valid answers to such questions. Below, we provide a conceptual framework for answering such questions and state our hypotheses that we will test using data from existing trials. Two points are relevant to indirect comparisons of treatment modalities with each other.
First, whether the participants of trials in one modality are comparable to those in another modality. Second, whether key conditions of the trial, such as the effects of control conditions or the number of sites involved in a trial, are comparable.
Starting with the first point, to be able to compare between different trials one must assume that these trials sample from the same population. If they do not, then the validity of any comparisons, including those conducted through network metanalysis (which rests on the principal of transitivity) are questionable.
Indeed, comparing outcomes (Y) between psychotherapy and medication trials requires us to contrast what is called the sample average treatment effect $\tau$ of each, defined in the following way:
$$
\tau_{psy} = E(Y_{1} - Y_{0} \,|\, S, psy)
$$ $$
\tau_{med} = E(Y_{1} - Y_{0} \,|\, S, med)\
$$ {#eq-1}
where the operator E denotes the expectation over the differences in outcomes between those who received the intervention (T = 1) and those who received the control condition (T = 0), for each sample, $S$, where psy and med stand for psychotherapy and medication respectively.
Obviously, this comparison rests on the assumption that trials in both modalities sample from the same population, $P$, of patients. Formally, this can be expressed as follows:
$$E(Y_{1} \,|\, \text{S, psy}) = E(Y_{1} \,|\, P, \text{psy})$$
$$E(Y_{1} \,|\, \text{S, med}) = E(Y_{1} \,|\, P, \text{med})$$ {#eq-2}
signifying that the effect found in the population would be expected to be found in the same population for each treatment.
This assumption may be hard to meet. Clinical experience and empirical evidence (ref: (<https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4156137/>, <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7669695/#:~:text=Adolescents%20also%20may%20be%20more,medications%2C%20and%20fewer%20anxiety%20symptoms.> , <https://pubmed.ncbi.nlm.nih.gov/16502131/>) indicate that patients and parents often have preferences between psychotherapy and medication, meaning that there is likely to be a self- %\>% ion bias with respect to who participates in psychotherapy versus medication trials. Moreover, these treatment preferences correlate with clinically-relevant characteristics of the participants, including severity, gender and comorbidity. Some of these characteristics, particularly baseline severity, may moderate treatment response (ref) and therefore, if they differ across psychotherapy and medication trials, they may confound comparisons.
Here we will compare between four key sample characteristics, namely baseline severity in the outcome, number of sites, gender and age in each sample.
In terms of the second point, differences in trial design may impact outcomes in a differential way between antidepressant and psychotherapy trials. Perhaps the most obvious way in which this happens is the fact that participants in psychotherapy trials are unblinded in terms of treatment allocation; by contrast, in new antidepressant trials, patients (and raters) were found to be unlikely to be able to judge treatment allocation (cite: Assessment of blinding in randomized controlled trials of antidepressants for depressive disorders 2000−2020: A systematic review and meta-analysis, Lancet). This creates differential expectations between medication and psychotherapy trials. Importantly, the placebo control has been developed in order to match as closely as possible the intervention condition, so as to minimise differences in expectancy between conditions. By contrast, psychotherapy control arms vary across waitlist controls, treatment as usual and active controls. These differences in expectation essentially favour the psychotherapy active condition and disadvantage the psychotherapy control (thus potentially the difference between them), because participants in the active condition could be content for receiving the "cutting edge treatment" whilst those in the control will be dissatisfied for having missed out on "proper treatment". And this is important because expectancy is associated with treatment outcomes. This also poses problems when trying to infer indirect comparisons in network metanalyses where, for example, CBT is compared to placebo control and medication --- given the likely differential expectation effects, comparisons to the unblinded psychotherapy controls may be biased.
Another difference in design that has potential implications for which patients are selected into the trial is the number of sites in a trial. Previous research has shown that in medication trials the number of sites is positively related to the magnitude of the placebo response. This phenomenon is hard to explain fully with the data available, but may be due to lower quality of phenotyping in such studies, with higher measurement (and therefore diagnostic classification) errors, leading to issues such as spontaneous remission or regression to the mean. In contrast to medication trials, psychotherapy trials typically involve one or fewer sites.
An inter-related issue concerns the nature of control interventions being used. Control conditions in trials are meant to generate counterfactual conditions (CITE RUBIN et al) to the intervention: what would have been the outcome in an individual had they not received the intervention. This implies that there is a latent distribution of values that represent that counterfactual condition which control arms in trials are meant to approximate. Those latent values of the counterfactual condition should, on average, not be different between psychotherapy and medication trials, provided that the samples are representative of the same underlying population (see Eqs 1& 2). If the average response to placebo and psychotherapy controls differs systematically from each other, then this is either due to the fact that the trials sample from different populations or because the control conditions differ in their effects (e.g. because of how much they do or do not protect against expectancy effects).
Understanding the nature of controls for each treatment modality is important for a similar reason. Often, in the public domain, psychotherapy and medication are compared to each other on the basis of their respective effect sizes. However, as evident from Eqs 1 and 2, these effect sizes represent differences between the active intervention and the control condition (placebo or psychotherapy control). For these effect sizes to be comparable, placebo and psychotherapy controls ought to be the equal. Otherwise, misleading conclusions could be drawn, e.g. two effect sizes of 40% would be considered equal, even if one arose from a difference of 100% - 60% and another arose from a difference of 40% - 0%.
In this paper, we examine psychotherapy and medication trials in the following ways. First, we compare key baseline characteristics of medication vs psychotherapy trials, specifically the extent to which they are comparable in a) baseline severity; b) number of sites involved; c) gender composition and d) age. Second, we assess the mean efficacy of psychotherapy controls vs placebo. We recognise that both these sets of analyses pull data out of the randomised comparisons between treatment arms. However, we believe that this is justified for two reasons: a) because it is important to make transparent to all, particularly decision makers in healthcare, the raw data before these are entered into more complex modelling such as network metanalysis, as this allows them to form opinions about the quality and limitations of the input data; b) our aim here is not to make claims about the relative efficacy of each treatment arm, but rather establish whether the conditions for the possibility of comparisons are fulfilled. Thus, the comparisons between control conditions are not meant to lead to inferences about placebo being "more efficacious" than psychotherapy controls, but rather to make transparent the problem that they seem to derive from different distributions. Third, we examine the quality of psychotherapy controls as such, by scrutinising the extent to which they are matched to the active intervention in ways such as number or frequency of sessions, and therefore, whether they represent fair pairings from which to draw valid efficacy inferences.
@stringarisDevelopmentalPathwaysChildhood2014
# Method
## Studies included
For this review, we primarily drew upon studies included in two recent meta-analyses. Please refer to these original meta-analyses for a detailed description of study selection criteria. Psychotherapy studies were drawn from Cuijpers' (2023) systematic review and meta-analysis of randomised trials comparing psychotherapy for youth depression against control conditions. Cuijpers made available a full dataset of psychotherapy trials (via https://www.metapsy.org/), which we used for the current study. Whilst Cuijpers (2023) excluded those studies for which the primary outcome variable could not be calculated due to missing data, we included these studies and performed the imputations outlined below; hence we have more psychotherapy studies included in this review compared to Cuijpers' (2023) meta-analysis. Whilst the online database is regularly updated, we chose to exclude studies published after the final date of Cuipers' (2023) literature search.
Medication studies were drawn from Cipriani's (2016) network meta-analysis examining the efficacy and tolerability of a range of antidepressants and placebo for major depressive disorder in young people. The study dataset was made available online though did not include means or standard deviations at baseline or post-test. We emailed the study authors requesting a full dataset with this data, though did not receive a reply, and hence conducted data extraction for medication studies. We excluded three studies because they did not include a control arm. We were unable to locate and therefore complete extraction for two papers. Many studies did not report complete data, and so we emailed all corresponding authors to request missing data, though did not receive any responses. We conducted a systematic search for medication studies published after the final search date of Cipriani's (2016) review up to the final search date of Cuijpers' (2023) review to ensure we analysed an equivalently up-to-date database of medication trials. We used the same search terms outlined in Cipriani (2016).
## Statistical Analysis
### Trial and sample characteristics
We conducted a series of random effects meta-analyses and tested for subgroup differences between psychotherapy versus medication trials in sample characteristics including gender, age, and severity of depressive symptoms at baseline. Meta-analyses were implemented using R's meta package.
In order to compare depression severity across different instruments, we performed a min-max normalisation to turn each study arm mean score at baseline into a percentage using the following formalism:
$$
\text{outcome}_{percent} = \frac{\bar{X} - \text{scale}_{min}}{\text{scale}_{max} - \text{scale}_{min}}
$$ {#eq-3}
where, $$\bar{X}$$ is the mean score for each study arm on the primary outcome questionnaire, and ${scale}_{min}$ and ${scale}_{max}$ are the minimum and maximum possible values of the scale in question, respectively. The standard deviation is calculated thus:
$$
\text{SD}_{Xpercent} = \frac{\text{SD}_{X}}{\text{scale}_{max} - \text{scale}_{min}}
$$ {#eq-4}
where $\text{SD}_{X}$ is the original standard deviation of the mean at baseline.
We also conducted a t-test to compare mean number of trial sites between psychotherapy and medication trials.
### Measures of Effect
As the measure of effect of each individual study, we used the within-group Standardised Mean Difference (SMD), which we defined following NOTE: Charlotte cite Lakens 2013 and in there Cummings 2012, as:
$$SMD_{change} = \frac{Mean_{t_{2}} - Mean_{t_{1}}}{\frac{SD_{t{2}} + SD_{t{1}}}2}\ $$
where, $Mean_{t_{2}}$ and $Mean_{t_{1}}$ refer to the means of the main outcome score at the end and beginning of the intervention respectively and $SD_{t_{2}}$ and $SD_{t_{1}}$ to the respective standard deviations. Where individual studies did not report all data required to calculate the SMD, we imputed missing data according to the methods summarised by X (citation), in the following order. If a study reported the standard error of the mean, the SD was obtained simply by multiplying the SE by the square root of the sample size. For conditions where the SD was missing at one time point, the baseline SD was substituted by the post-test SD, and vice versa. If the SD was not available at either time point, missing values were replaced by the mean of the SDs available for comparable cases (defined as same trial type (psy or med), same instrument, same timepoint (pre or post), and same arm (control or active)). Where there were missing means at either baseline or post-test, missing values were calculated using mean change scores, preferring the change scores reported in the paper itself, though where this was unavailable, using the change scores reported in the dataset from Cipriani's meta-analysis (citation).
For the purposes of metanalysis, it is necessary to estimate a standard error of the SMD. This is calculated according to:
$$ SE_{SMD} = \sqrt{\frac{2(1 -r_{t_{1}t_{2}})}{n} + \frac{SMD^2}{2n}}$$ {#eq-5}
where $n$ refers to the study sample size and $r_{t_{1}t_{2}}$ refers to the correlation between the outcome score obtained at baseline and at the end point. This correlation is typically not reported in studies and is often imputed using previously reported correlations for the instruments used. However, this practice has given rise to concerns about misestimation. Whilst such misestimation is possible, there is no reason to expect that it would be systematic, i.e. bias estimation of the effects for the control group of medication compared to those of psychotherapy. Still, to alleviate such concerns we have used a simulations.
In particular, we simulated one thousand truncated distribution of standard errors with the following general characteristics:
$$r_{t_{1}t_{2}} \sim \mathcal{TN}(\mu, \sigma, a, b)$$ {#eq-6}
for which we chose the mean to be $\mu = 0.65$, the standard deviation to be $\ sigma = 0.2$, and the upper and lower bounds to be $a = 0.45$ and $b = 0.9$, respectively. We then used these simulated datasets in the subsequent metanalyses.
### Random Effects Metaregression
We estimated the pooled standardised mean difference for each arm by using a random effects metanalysis implemented in R's metafor package. The main underlying assumption of random effects metanalysis is that each study's true effect size $\theta_{k}$ is affected not only by sampling error $\epsilon_{k}$, but also by $\zeta$ which represents heterogeneity between studies, allowing each study's estimate to vary along a distribution of effects, and the distribution of true effect sizes termed $\tau^2$. Therefore, we can estimate a two stage model with:
$$Y_i \sim \mathcal{N}(\theta_i, \sigma_i^2)
$$ {#eq-7}
$$\theta_i \sim \mathcal{N}(x_i\beta, \tau_i^2)
$$ {#eq-8}
where $Y_i$ is the estimated effect size for study i, has a normal distribution with $\theta_i$ as its true mean effect and sampling error $\sigma^2$. Whereas $\theta_i$ is a study-specific instantiation of the distribution of effect sizes, with $\tau^2$ representing heterogeneity.
This then gives rise to:
$$Y_i = x_i\beta_i + u_i + \epsilon_i$$ {#eq-9}
where,
$$u_i \sim N(0, \tau^2) $$ {#eq-10}
describes the deviation of each study from the mean of the distribution, and,
$$\epsilon_i \sim N(0, \sigma^2)$$ {#eq-11}
describes the sampling error.
We can then specify the following model to obtain the means of each arm of the trials as follows:
$$ \begin{aligned}
Υ_i &=
\begin{cases}
0 & MedControl: b_0 + u_i + \epsilon_i\\
1 & MedActive: b_0 + b_{1_{i}} + u_i + \epsilon_i \\
2 & PsyActive: b_0 + b_{2_{i}} + u_i + \epsilon_i \\
3 & PsyControl: b_0 + b_{3_{i}} + u_i + \epsilon_i \\
\end{cases}
\end{aligned}$$ {#eq-12}
where to obtain the mean of each level is the sum of $b_0$, the intercept for the reference category of medication control, with the coefficient of each level, e.g. for level 3, $b_{3_{i}}$ the psychotherapy controls. The confidence intervals of the means are constructed in the standard way using the standard errors of the mean. Similarly, each coefficient represents the contrast between the reference category and each level, for an example and of main interest to us $b_{3_{i}}$ represents the contrast between psychotherapy and medication control arms. Inference on the contrasts is done as follows:
$$
z = \frac{\hat{\beta}}{\text{SE}(\hat{\beta})}
$$ {#eq-13}
We used maximum likelihood (ML) to estimate model and applied Hartung-Knapp adjustment to reduce the chance of false positives (NOTE: **Charlotte**cite Ioannides on this).
We present our main results as means of the estimates across simulated datasets, for example, the SMDs of each level of the dummy variable above are means across the simulations.
### Sensitivity Analyses
We conducted a number of additional analyses to test for the robustness of our results.
First, for each of the the analyses comparing trial and sample characteristics at baseline, and control efficacy between study arms, we performed sensitivity analyses where we restricted the included studies in the following ways. First, we excluded studies which recruited participants with subclinical levels of depression. Second, we restricted the analyses to studies using CBT and the FDA-approved antidepressants fluoxetine and escitalopram. Third, we excluded studies that used waitlist as their control condition.
Further, we tested whether the simulated values for the standard error had a substantial influence on the estimation of the differences between the medication vs psychotherapy control condition. To inspect whether this is the case, we plotted the z-value of the difference between the two coefficients against the number of simulations. We make inference on the stability of the difference, by counting the proportion of times that the z-value is above the
```{r, warning=FALSE, message = FALSE, echo = FALSE}
# my alpha for the z
target_probability <- 1 - 0.05
#start here
x <- 1
# two decimals should be fine
tolerance <- 1e-3
#find the z value using the pnorm function
while (abs(pnorm(x)) < target_probability ) {
x <- x + tolerance
}
# Adjust the step size based on your problem
cat("critical value of z =", x, "corresponding to an alpha = 0.05." , "\n")
```
### Comparing the control versus active arms of psychotherapy trials
We ran t-tests to compare the active versus control arms of psychotherapy trials on key variables of interest regarding the nature and intensity of the interventions. We extracted data pertaining to the number, duration and intensity of sessions, and the total cumulative hours and period of the intervention. Where a range was provided, the maximum was encoded (e.g. if a paper reported that an intervention involved 8-10 sessions lasting 50-60 minutes, we encoded the number and duration of sessions as 10 and 60, respectively). If sessions varied in frequency across an intervention, we calculated an average by dividing total number of sessions by length of intervention period. Similarly, if the length of sessions varied across the course of the intervention, we calculated a weighted average. Phone call, web-chat and online sessions were encoded as sessions, however guided self-help components were not.
```{r, warning=FALSE, message = FALSE, echo=FALSE}
###########Libraries needed
library(tidyverse)
library(truncnorm)
library(metafor)
library(meta)
library(kableExtra)
```
```{r, warning=FALSE, message = FALSE, echo=FALSE}
#############Some custom made functions#############
###### 1. Simulation Function for SEs
simulate_dataframes_for_st_errors <- function(df, num_repetitions, seed, n, a, b, mean, sd) { # n refers to the number
# of unique ids to which a correlation coef
# is allocated.
set.seed(seed)
# Empty list to store simulated dfs
list_df_simulated <- list()
for (i in 1:num_repetitions) {
# Simulate the vector
simulated_correlations_vector <- truncnorm::rtruncnorm(n, a, b, mean, sd) #using the truncnorm to create correlations
# Create a copy of the original dataframe
df_simulated_copy <- df
# Add/update the sims column
df_simulated_copy$correlation_sim_values <- simulated_correlations_vector[match(df_simulated_copy$new_study_id, unique(df_simulated_copy$new_study_id))]
# Remove duplicated columns
df_simulated_copy <- df_simulated_copy[, !duplicated(colnames(df_simulated_copy))]
# Calculate the ses
df_simulated_copy <- df_simulated_copy %>%
group_by(new_study_id, baseline_n) %>%
mutate(simulated_se = sqrt(((2*(1-correlation_sim_values))/baseline_n) +
(cohens_d^2/(2*baseline_n))))
# Add the simulated dataframe to the list
list_df_simulated[[i]] <- df_simulated_copy
}
return(list_df_simulated)
}
###############2. Simulation function for metaregression
run_metaregression <- function(list_of_datasets, model_formula) {
list_model_meta_reg <- list()
for (i in seq_along(list_of_datasets)) {
list_model_meta_reg[[i]] <- metafor::rma(yi = cohens_d,
sei = simulated_se,
data = list_of_datasets[[i]],
method = "ML",
mods = model_formula,
test = "knha")
}
return(list_model_meta_reg)
}
#########2. Function to count studies with missingness etc.
count_studies <- function(df) {
df_count_studies <- df %>%
group_by(psy_or_med, arm_effect_size) %>%
count(is.na(cohens_d)) %>%
rename(is_missing = `is.na(cohens_d)`) %>%
mutate(
condition = case_when(
psy_or_med == 0 & arm_effect_size == "cohens_d_active" ~ "medication_active",
psy_or_med == 0 & arm_effect_size == "cohens_d_control" ~ "medication_control",
psy_or_med == 1 & arm_effect_size == "cohens_d_active" ~ "psychotherapy_active",
psy_or_med == 1 & arm_effect_size == "cohens_d_control" ~ "psychotherapy_control"
)
)
df_count_studies$condition <- factor(df_count_studies$condition) # turn to factor
# relevel so that medication control becomes the reference category for the regression
df_count_studies$condition <- relevel(df_count_studies$condition, ref = "medication_control")
return(df_count_studies)
}
##########3. Function to extract mean coefficients and to extract model characteristics
aggregate_model_results <- function(list_model_1_meta_reg, condition) {
df_coefs <- matrix(NA, nrow = length(list_model_1_meta_reg), ncol = length(condition))
df_se <- matrix(NA, nrow = length(list_model_1_meta_reg), ncol = length(condition))
df_z_value <- matrix(NA, nrow = length(list_model_1_meta_reg), ncol = length(condition))
df_lower_ci <- matrix(NA, nrow = length(list_model_1_meta_reg), ncol = length(condition))
df_upper_ci <- matrix(NA, nrow = length(list_model_1_meta_reg), ncol = length(condition))
tau_sq <- rep(0, length(list_model_1_meta_reg))
i_sq <- rep(0, length(list_model_1_meta_reg))
k <- rep(0, length(list_model_1_meta_reg))
r_sq <- rep(0, length(list_model_1_meta_reg))
for (i in 1:length(list_model_1_meta_reg)) {
for (j in 1:length(condition)) {
df_coefs[i, j] <- list_model_1_meta_reg[[i]]$beta[[j]]
df_se[i, j] <- list_model_1_meta_reg[[i]]$se[[j]]
df_z_value[i, j] <- list_model_1_meta_reg[[i]]$zval[[j]]
df_lower_ci[i, j] <- list_model_1_meta_reg[[i]]$ci.lb[[j]]
df_upper_ci[i, j] <- list_model_1_meta_reg[[i]]$ci.ub[[j]]
tau_sq[i] <- list_model_1_meta_reg[[i]]$tau2
i_sq[i] <- list_model_1_meta_reg[[i]]$I2
k[i] <- list_model_1_meta_reg[[i]]$k
r_sq[i] <- list_model_1_meta_reg[[i]]$R2
}
}
df_coefficients_model <- data.frame(
coefficients = colMeans(df_coefs),
se = colMeans(df_se),
z_value = colMeans(df_z_value),
lower_ci = colMeans(df_lower_ci),
upper_ci = colMeans(df_upper_ci),
tau_sq = mean(tau_sq),
i_sq = mean(i_sq),
k = mean(k),
r_sq = mean(r_sq)
)
return(df_coefficients_model)
}
###########4. Function to extract the SMDs (SMD, ses, CI) for each level of the dummy variable. The output is used below in 5.
# it is a slightly awkward one, because I couldn't' come up with a better way to add the intercept to each coefficient
# given the named output of the built in coef function. here I extract the coefficients
extract_coefficients_func <- function(df_with_coefs){
list_coefs <- list()
coefs <- 0
coefficient_output <- 0
for(i in 1: length(coefficients(df_with_coefs))){
temp_vec <- c(0, rep(coefficients(df_with_coefs)[[1]],
length(coefficients(df_with_coefs)) - 1 ))
coefs[i] <- coef(df_with_coefs)[[i]]
coefficient_output <- temp_vec + coefs
st_error_output <- df_with_coefs$se
df_coefficients <- data.frame(cbind(coefficients = coefficient_output, se = st_error_output ))
df_coefficients$lower_bound <- df_coefficients$coefficients - 1.96*df_coefficients$se
df_coefficients$upper_bound <- df_coefficients$coefficients + 1.96*df_coefficients$se
}
return (df_coefficients )
}
############5. Function to get the means out of the SMDs (this is similar to Func 3 and I should at some point create one more general one)
# here the argument list_of_dfs is the list of extracted coefficients that you get out of the extract_coefficients_func
# which itself you get from the run_metaregression function. The argument conditions refers to the levels of the variable that describes each study arm
calculate_mean_coefs_ses <- function(list_of_dfs, conditions) {
df_coefs <- matrix(NA, nrow = length(list_of_dfs), ncol = length(conditions))
df_se <- matrix(NA, nrow = length(list_of_dfs), ncol = length(conditions))
for (i in 1:length(list_of_dfs)) {
for (j in 1:length(conditions)) {
df_coefs[i, j] <- list_of_dfs[[i]]$coefficients[j]
df_se[i, j] <- list_of_dfs[[i]]$se[j]
}
}
df_mean_coefs_ses <- data.frame(
coef_means = colMeans(df_coefs),
se_means = colMeans(df_se)
)
df_mean_coefs_ses$lower_ci <- df_mean_coefs_ses$coef_means - 1.96 * df_mean_coefs_ses$se_means
df_mean_coefs_ses$upper_ci <- df_mean_coefs_ses$coef_means + 1.96 * df_mean_coefs_ses$se_means
return(df_mean_coefs_ses)
}
###############6. Function for plotting the SMDs
plot_means_function <- function(dataframe, subtitle) {
dataframe$text_label <- 0
for (i in 1:nrow(dataframe)) {
dataframe$text_label[i] <- paste(
dataframe$condition[i], "\n",
round(dataframe$coef_means[i], 2),
"[" ,
round(dataframe$lower_ci[i], 2),
round(dataframe$upper_ci[i], 2),
"]"
)
}
# Recode condition for ease of plotting
dataframe$condition <- str_replace_all(dataframe$condition, "_", " ")
# Encode colours
redish_palette <- c("medication control" = "deeppink", "medication active" = "deeppink3")
blueish_palette <- c("psychotherapy active" = "steelblue1", "psychotherapy control" = "steelblue3")
# Plotting
plot_means <- ggplot(dataframe, aes(x = coef_means, y = 1:nrow(dataframe),
colour = condition, label = text_label)) +
geom_point(label=dataframe$k) +
geom_errorbar(aes(xmin = lower_ci, xmax = upper_ci), width = 0.2, position = position_dodge(0.5)) +
geom_text(vjust = +1.5, size = 4) +
scale_size_continuous(guide = "none") +
guides(colour = FALSE) +
scale_color_manual(values = c(redish_palette, blueish_palette)) +
theme_minimal() +
labs(x = "TE-random", y = NULL, title = "Adolescent Depression Trial Efficacy by Treatment Arm",
subtitle = subtitle) +
xlab("Standardized Mean Difference (SMD) with 95% CIs") +
ylab("") +
ylim(0, nrow(dataframe) + 1) +
xlim(-3.0, 0.5) +
geom_vline(xintercept = 0, linetype = "dashed", size = 1.5, colour = "grey") +
geom_segment(x = -1.25, xend = -1.75, y = 4.7, yend = 4.7, arrow = arrow(length = unit(0.25, "cm"), type = "closed"), color = "grey") +
geom_text(x = -1.55, y = 4.9, label = "More Effective", color = "grey", vjust = 0.5, hjust = 1) +
geom_segment(x = -1.35, xend = -0.85, y = 4.9, yend = 4.9, arrow = arrow(length = unit(0.25, "cm"), type = "closed"), color = "grey") +
geom_text(x = -1.05, y = 5.05, label = "Less Effective", color = "grey", vjust = 0.5, hjust = 0)+
theme(axis.title.x = element_text(size = 12),
axis.text.x = element_text(size = 12),
axis.text.y = (element_blank()),
plot.title = element_text(size = 12),
plot.subtitle = element_text(size = 12)) +
geom_curve(aes(x = 0.18, y = 4.73, xend = 0.02, yend = 4.5), color = "grey", curvature = -0.2, arrow = arrow(length = unit(0.25, "cm"), type = "closed")) +
geom_text(x = 0.2, y = 4.75, label = "No Effect", color = "grey", vjust = 0.5, hjust = 0)
return(plot_means)
}
###########7. Function for baseline SMD results
library(broom)
run_metareg_and_extract <- function(dataframe, model_1, condition) {
# Run metareg
inst_baseline_metareg <- rma(yi = baseline_mean,
sei = baseline_stand_error,
data = dataframe,
method = "ML",
mods = model_1,
test = "knha")
# Extract coefficients from the list
baseline_metareg_results <- tidy(inst_baseline_metareg)
baseline_metareg_results$condition <- condition
coefs_for_inst_baseline <- tidy(inst_baseline_metareg)$estimate
# Calculate SMDs
smds_for_inst_baseline <- c(coefs_for_inst_baseline[1], coefs_for_inst_baseline[-1] + coefs_for_inst_baseline[1])
# Calculate upper and lower CIs
upper_cis_for_inst_baseline <- smds_for_inst_baseline + 1.96 * tidy(inst_baseline_metareg)$std.error
lower_cis_for_inst_baseline <- smds_for_inst_baseline - 1.96 * tidy(inst_baseline_metareg)$std.error
# Create dataframe with results
df_baseline_means_with_cis <- data.frame(
baseline_smds = smds_for_inst_baseline,
upper_cis_smds = upper_cis_for_inst_baseline,
lower_cis_smds = lower_cis_for_inst_baseline,
condition = condition
)
# Return the two dataframes
return(list(baseline_metareg_results = baseline_metareg_results, df_baseline_means_with_cis = df_baseline_means_with_cis))
}
```
```{r, warning=FALSE, message = FALSE, echo=FALSE}
library(tidyverse)
# Transforming data ------------------------------------------------------
# import master dataset
df_appl_v_orange <-readxl:: read_excel("df_appl_v_orange.xlsx")
# Here we add in instrument end point values (mins / maxs).
# We will use these to transform the scale into % as follows: (observed score - min of the scale)/(max-min)
# We have done this for both means and standard deviations.
df_scale_ranges <- read.csv("scale_ranges.csv")
df_appl_v_orange <- full_join(df_appl_v_orange, df_scale_ranges, by = "instrument_name")
df_appl_v_orange <- df_appl_v_orange %>%
mutate(perc_baseline_mean_active = (baseline_mean_active - scale_min) / (scale_max - scale_min)) %>%
mutate(perc_baseline_sd_active = baseline_sd_active / (scale_max - scale_min)) %>% # this is the best way to estimate the SD of the linear transformation of the score
mutate(perc_baseline_mean_control = (baseline_mean_control - scale_min) / (scale_max - scale_min)) %>%
mutate(perc_baseline_sd_control = baseline_sd_control / (scale_max - scale_min)) %>%
mutate(perc_post_mean_active = (post_mean_active - scale_min) / (scale_max - scale_min)) %>%
mutate(perc_post_sd_active = post_sd_active / (scale_max - scale_min)) %>%
mutate(perc_post_mean_control = (post_mean_control - scale_min) / (scale_max - scale_min)) %>%
mutate(perc_post_sd_control = post_sd_control / (scale_max - scale_min))
# Need to use SMDs (ie our Cohen's d) and then use standard error of SMD, to achieve this I need test-retest reliabilities of instruments.
# CDRS reliability taken from here https://www.liebertpub.com/doi/epdf/10.1089/104454601317261546
# Using a 2-week interval, and different psychiatrists from the first to the second assessment,
# Poz-nanski et al. (1984) demonstrated high reliability (r= 0.86)
# for the CDRS-R total score in 53 clinic-referred 6- to 12-year-olds.
### A few more tidying things from Argyris before doing metanalyses
# Discovered some errors in the percentage women variable. Have gone back and checked.
df_appl_v_orange[df_appl_v_orange$study_ID=="Fristad, 2019_cbt + placebo_placebo",]$percent_women <-43.1
df_appl_v_orange[df_appl_v_orange$study=="Clarke, 1995",]$percent_women <-47.3
df_appl_v_orange[df_appl_v_orange$study=="Moeini, 2019",]$percent_women <-100
df_appl_v_orange[df_appl_v_orange$study=="Santomauro, 2016",]$percent_women <-40
# Calculate SE for baseline severity --------------------------------------
df_appl_v_orange$baseline_st_error_active <-
df_appl_v_orange$baseline_sd_active/sqrt(df_appl_v_orange$baseline_n_active)
df_appl_v_orange$baseline_st_error_control <-
df_appl_v_orange$baseline_sd_control/sqrt(df_appl_v_orange$baseline_n_control)
# Turn into a long database with unique rows ------------------------------
### Important: create a dataset that will have unique control studies (see problem that we identified, namely common control conditions)
# create new id to help with better identification and work with duplicates (see below)
df_appl_v_orange <- df_appl_v_orange %>%
mutate(new_study_id = case_when(psy_or_med == 0 ~ paste(study,year, sep = ", "),
.default = study ))
# We are going to use the descr_active and descr_control columns rather than active_type and control_type columns, as these have unique values for each study. However the descr columns are empty for med studies, so I'm going to paste values across to fix this error.
df_appl_v_orange <- df_appl_v_orange %>%
mutate(descr_active = if_else(is.na(descr_active ), active_type , descr_active ))
df_appl_v_orange <- df_appl_v_orange %>%
mutate(descr_control = if_else(is.na(descr_control), control_type, descr_control ))
# Step 1: keep only the rows with the top instrument in our hierarchy
df_with_distinct_instruments <- df_appl_v_orange %>%
group_by(new_study_id) %>%
filter(instrument_value == min(instrument_value)) # coded for the smallest number to be best.
write.csv(df_with_distinct_instruments, "df_with_distinct_instruments.csv")
# Step 2: turn dataframes to long
# A small bit of cleaning so the code below will work
df_with_distinct_instruments <- df_with_distinct_instruments %>%
rename (percent_women_active = active_percent_women,
percent_women_control = control_percent_women,
percent_women_overall = percent_women)
# A: turn long the rows with active
active_df <- df_with_distinct_instruments %>%
dplyr:: select(new_study_id, active_type, descr_active, psy_or_med, baseline_n_active, cohens_d_active,
baseline_mean_active, baseline_sd_active, post_mean_active, post_sd_active,
perc_baseline_mean_active, perc_baseline_sd_active, perc_post_mean_active, perc_post_sd_active, percent_women_overall, percent_women_active, age_m_active, age_sd_active, age_m_overall, age_sd_overall, no_sites) %>%
rename(treatment = descr_active) %>%
rename(type = active_type) %>%
rename_with(~ str_remove(., "_active")) %>%
mutate(arm_effect_size = "cohens_d_active") %>% # chose this clunky name because I had used this variable name in previous code and don't want to bread the rest
group_by(new_study_id) %>% #go through each study id and remove duplicates
distinct(treatment, .keep_all = TRUE)
control_df <- df_with_distinct_instruments %>%
dplyr:: select(new_study_id, control_type, descr_control, psy_or_med, baseline_n_control, cohens_d_control,
baseline_mean_control, baseline_sd_control,post_mean_control, post_sd_control,
perc_baseline_mean_control, perc_baseline_sd_control, perc_post_mean_control, perc_post_sd_control, percent_women_overall, percent_women_control, age_m_control, age_sd_control, age_m_overall, age_sd_overall, no_sites) %>%
rename(treatment = descr_control) %>%
rename(type = control_type) %>%
rename_with(~ str_remove(., "_control")) %>%
mutate(arm_effect_size = "cohens_d_control") %>% #chose this clunky name because I had used this variable name in previous code and don't want to bread the rest
group_by(new_study_id) %>% #go through each study id and remove duplicates
distinct(treatment, .keep_all = TRUE)
df_long_for_metan <- rbind(active_df, control_df)
# I'm going to remove the March / TADS psy control row. It is currently filled with NAs which implies missing data, however it is actually the case that this condition doesn't exist as such (the control is placebo, which is not a psy control).
df_long_for_metan <- df_long_for_metan %>%
filter(!(new_study_id == "March, 2004" & is.na(treatment)))
# I'm going to perform the operations to calculate overall age and percent women here now. We just want this per study rather than per arm
# as we are going to compare psy vs med (2 subgroups) rather than the 4 arms
df_long_for_metan <- df_long_for_metan %>%
group_by(new_study_id) %>%
mutate(n_overall = sum(baseline_n)) %>%
mutate(age_overall = sum(age_m * baseline_n) / sum(baseline_n)) %>%
mutate(mean_age = coalesce(age_overall, age_m_overall)) %>%
mutate(pooled_sd_age = sqrt(sum((age_sd^2) * (baseline_n - 1)) / sum(baseline_n - 1))) %>%
mutate(se_age = pooled_sd_age / sqrt(n_overall)) %>%
mutate(gender_overall = sum(percent_women * baseline_n) / sum(baseline_n)) %>%
mutate(percent_women = coalesce(percent_women_overall, gender_overall))
# Now just get rid of the unnecessary columns as these are causing clutter
df_long_for_metan <- df_long_for_metan %>%
select(-c(percent_women_overall, age_m, age_sd, age_m_overall, age_sd_overall, age_overall, gender_overall))
# Remember that these are now per study, not per arm.
# Create SEs proportions for percentage women --------------------------------------------
# We also need to calculate SE for proportion women for the baseline calculations
# for proportions, this is calculated as sqrt(p(1-p)/n), which I implement stepwise below
df_long_for_metan <- df_long_for_metan %>%
mutate(product_perc_women = (percent_women/100)* (1-(percent_women/100)) )
df_long_for_metan <- df_long_for_metan %>%
mutate(percent_women_std_error = sqrt(product_perc_women/ n_overall ))
#dim(df_long_for_metan ) #check dimension
#make sure no study lost
#length(unique(df_long_for_metan$new_study_id ) ) == # #length(unique(df_appl_v_orange$new_study_id ) )
# Now check again the studies with muliple arms
# Now checking if this worked with the studies that I used to illustrate the problem above.
# df_long_for_metan[df_long_for_metan$new_study_id == "Stallard, 2012",]
# df_long_for_metan[df_long_for_metan$new_study_id == "Atkinson, 2014",]
# # also check one which is single to make sure it is kept
# df_long_for_metan[df_long_for_metan$new_study_id == "Ackerson, 1998",]
# save this as the master dataframe --------------------------------------
# use this dataframe to perform all operations below
write.csv(df_long_for_metan, "df_long_for_metan.csv", row.names = F)
########### simulate so that each study has a value from a distribution of
######## of correlations.
# I will generate random numbers per study id from a distribution with these parameters.
# it is reasonable to generate one random correlation value per study as there is no reason why the correlation should
# systematically vary within studies
# Use the function I have created for this
df_long_for_metan <- read.csv("df_long_for_metan.csv")
list_df_simulated <- simulate_dataframes_for_st_errors (df = df_long_for_metan,
num_repetitions = 1000,
seed = 1974,
n = length(unique(df_long_for_metan$new_study_id)),
a = 0.45,
b = .9,
mean = 0.65,
sd = 0.2)
#check this worked
#list_df_simulated[[10]][,c("new_study_id", "correlation_sim_values", "simulated_se")] # looks right
#summary(list_df_simulated[[1000]]$correlation_sim_values, na.rm = T) # as expected # the mean is around the parameter I gave
```
# Results
```{r, warning=FALSE, message = FALSE, echo=FALSE}
# This chunk of code needs to be here because some of the data needed for the included studies summary lives here
# Get Ns, run metareg, prepare graphing ------------------------------------------------------
library(tidyverse)
library(metafor)
# add a new multilevel variable to the simulated data for the regression
for(i in 1: length(list_df_simulated)){
list_df_simulated[[i]]$arm_effect_size <- factor(list_df_simulated[[i]]$arm_effect_size)
list_df_simulated[[i]] <- list_df_simulated[[i]] %>%
mutate(four_level_var = case_when(psy_or_med == 0 & arm_effect_size == "cohens_d_active" ~ "medication_active",
psy_or_med == 0 & arm_effect_size == "cohens_d_control" ~ "medication_control",
psy_or_med == 1 & arm_effect_size == "cohens_d_active" ~ "psychotherapy_active",
psy_or_med == 1 & arm_effect_size == "cohens_d_control" ~ "psychotherapy_control")
)
list_df_simulated[[i]]$four_level_var <- factor(list_df_simulated[[i]]$four_level_var) # turn to factor
# relevel so that medication control becomes the reference category for the regression
# list_df_simulated[[i]]$four_level_var <- relevel(list_df_simulated[[1]]$four_level_var, ref = "medication_control")
list_df_simulated[[i]]$four_level_var <- fct_relevel(list_df_simulated[[i]]$four_level_var,
"medication_control",
"medication_active",
"psychotherapy_control",
"psychotherapy_active")
}
# check it worked
# list_df_simulated[[2]] %>%
# dplyr:: select(psy_or_med, arm_effect_size, four_level_var)
######## NOW RUN METAREGRESSIONS AND GET Coefficients for
# A) the overall sample
# B) the CBT vs Fluox and Escitalopram sample
# C) the no WL sample
# E) the CDRS only sample (**Argyris** do we still want this?)
# F) Clinical Levels Depression
# A. Estimate Means and CIs for the overall ----------------------------------
# count studies
# count the number of studies
n_unique_studies <- length(unique(df_long_for_metan$new_study_id)) # CHARLOTTE please check
df_count_studies <- count_studies(df_long_for_metan ) # CHARLOTTE please check
# CB checked both, both correct.
# specify model
model_1 <- as.formula(~ four_level_var)
# run metareg function
# here you can use the simulated results directly
list_model_1_meta_reg <- run_metaregression(list_df_simulated, model_1)
# extract coefficients and model characteristics.
condition <- levels(list_df_simulated[[1]]$four_level_var)
aggregate_results_overall <- aggregate_model_results(list_model_1_meta_reg, condition)
aggregate_results_overall <- cbind(aggregate_results_overall, condition)
# extract SMDs from the list
list_dummy_var_means <- lapply(list_model_1_meta_reg, extract_coefficients_func)
# calculate mean SMDs and ses
df_mean_coefs_from_sim <- calculate_mean_coefs_ses(list_dummy_var_means, condition)
df_mean_coefs_from_sim <- data.frame(cbind(condition,df_mean_coefs_from_sim))
# add the ns
df_mean_coefs_from_sim <- data.frame(cbind(df_mean_coefs_from_sim, n = df_count_studies[df_count_studies$is_missing == FALSE, ]$n))
# B. Estimate Means and CIs for CBT Fluox Esc --------------------------------
# grab ids for those studies
cbt_fluox_esc_study_ids <-
df_appl_v_orange[df_appl_v_orange$active_type == "cbt" | df_appl_v_orange$active_type == "Fluoxetine" | df_appl_v_orange$active_type == "Escitalopram",]$new_study_id
# Use those ids to subset all dataframes in the list
# By searching for IDs we have mistakenly included multiple active arms. E.g. for Atkinson which has dulox and fluox.
# So we need to further subset the simulated dfs. For the active arms, I am filtering out conditions that do not meet our criteria.
# This leaves all the control conditions from trials where the active is cbt, fluox or esc.
# We may have multiple controls per study id for this reason, though this isn't a problem
# conceptually.
list_cbt_fluox_esc_study <- lapply(list_df_simulated, function(df) {
df %>%
filter(new_study_id %in% cbt_fluox_esc_study_ids) %>%
filter(!(arm_effect_size == "cohens_d_active" & !(type %in% c("Fluoxetine", "Escitalopram", "cbt"))))
})
# count the number of studies
cbt_fluox_esc_study <- df_long_for_metan %>%
filter(new_study_id %in% cbt_fluox_esc_study_ids,
!(arm_effect_size == "cohens_d_active" & !(type %in% c("Fluoxetine", "Escitalopram", "cbt"))))
study_count_cbt_fluox_esc_study <- count_studies(cbt_fluox_esc_study)
# CB checked, looks good now.
# apply the metareg function to the list of cbt, fluox, esc
model_1 <- as.formula(~ four_level_var)
list_model_1_cbt_fluox_esc_study <- run_metaregression(list_cbt_fluox_esc_study , model_1)
# extract coefficients and model characteristics.
condition <- levels(list_df_simulated[[1]]$four_level_var)
aggregate_results_cbt_fluox_esc_study <- aggregate_model_results(list_model_1_cbt_fluox_esc_study, condition)
aggregate_results_cbt_fluox_esc_study <- cbind(aggregate_results_cbt_fluox_esc_study, condition)
# extract SMDs from the list for cbt fluox escit
means_cbt_fluox_esc_study <- lapply(list_model_1_cbt_fluox_esc_study, extract_coefficients_func)
# calculate mean SMDs and ses
condition <- levels(list_df_simulated[[1]]$four_level_var) # for the conditino argument
coef_and_se_means_cbt_fluox_esc_study <- calculate_mean_coefs_ses(means_cbt_fluox_esc_study, condition)
coef_and_se_means_cbt_fluox_esc_study <- data.frame(cbind(condition, coef_and_se_means_cbt_fluox_esc_study))
# add the ns to the dataframe
coef_and_se_means_cbt_fluox_esc_study$n <- study_count_cbt_fluox_esc_study[study_count_cbt_fluox_esc_study$is_missing ==F,]$n
# C. Estimate Means and CIs without WL ---------------------------------------
# grab the ids for no waitlist
no_wl_ids <-df_appl_v_orange[df_appl_v_orange$control_type != "wl",]$new_study_id
# use them to loop over the simulated list to subset all the dataframes.
list_no_wl <- lapply(list_df_simulated, function(df) {
df %>%
filter(new_study_id %in% no_wl_ids) %>%
filter(!(arm_effect_size == "cohens_d_control" & type == "wl"))
})
# count studies
no_wl_studies <- df_long_for_metan %>%
filter(new_study_id %in% no_wl_ids) %>%
filter(!(arm_effect_size == "cohens_d_control" & type == "wl"))
study_count_no_wl_study <- count_studies(no_wl_studies)
# CB checked, looks good!
# use this model as above
model_1 <- as.formula(~ four_level_var)
# apply the metareg function to the list of no wl
list_model_1_no_wl <- run_metaregression(list_no_wl , model_1)
# extract coefficients and model characteristics.
condition <- levels(list_df_simulated[[1]]$four_level_var)
aggregate_results_no_wl <- aggregate_model_results(list_model_1_no_wl, condition)
aggregate_results_no_wl <- cbind(aggregate_results_no_wl, condition)
# now use the function to extract the coefficients
means_no_wl <- lapply(list_model_1_no_wl, extract_coefficients_func)
# run the mean function for no wl
condition <- levels(list_df_simulated[[1]]$four_level_var) # for the conditino argument
coef_and_se_means_no_wl <- calculate_mean_coefs_ses(means_no_wl, condition)
coef_and_se_means_no_wl <- data.frame(cbind(condition,coef_and_se_means_no_wl))
coef_and_se_means_no_wl$n <- study_count_no_wl_study[study_count_no_wl_study$is_missing
==FALSE,]$n
# E. CDRS Sensitivity Analysis ---------------------------------------
cdrs_study_ids <-
df_appl_v_orange[df_appl_v_orange$instrument_name == "cdrs",]$new_study_id
# use those ids to subset all dataframes in the list
list_cdrs_study <- list()
for(i in 1: length(list_df_simulated)){
list_cdrs_study[[i]] <- list_df_simulated[[i]][list_df_simulated[[i]]$new_study_id
%in% cdrs_study_ids,]
}
# count the number of studies
study_count_cdrs_study <- count_studies(df_long_for_metan[df_long_for_metan$new_study_id %in% cdrs_study_ids,])
# CB checked, correct.
# apply the metareg function to the list of cdrs studies
model_1 <- as.formula(~ four_level_var)
list_model_1_cdrs_study <- run_metaregression(list_cdrs_study , model_1)
# extract coefficients and model characteristics.
condition <- levels(list_df_simulated[[1]]$four_level_var)
aggregate_results_cdrs_study <- aggregate_model_results(list_model_1_cdrs_study, condition)
# extract SMDs from the list for cdrs
means_cdrs_study <- lapply(list_model_1_cdrs_study, extract_coefficients_func)
# calculate mean SMDs and ses
condition <- levels(list_df_simulated[[1]]$four_level_var) # for the conditino argument
coef_and_se_means_cdrs_study <- calculate_mean_coefs_ses(means_cdrs_study, condition)
coef_and_se_means_cdrs_study <- data.frame(cbind(condition, coef_and_se_means_cdrs_study))
# add the ns to the dataframe
coef_and_se_means_cdrs_study$n <- study_count_cdrs_study[study_count_cdrs_study$is_missing ==F,]$n
# F Clinical Levels Depression Sensitivity Analysis ---------------------------------------
# We need to decide how we want to do this. We have mdd, mood, sub, and cut categories. For now I'll just exclude sub.
#take study ids where sample has clinical levels of depression
clin_study_ids <-
df_appl_v_orange[df_appl_v_orange$diagnosis != "sub",]$new_study_id
# use those ids to subset all dataframes in the list
list_clin_study <- list()
for(i in 1: length(list_df_simulated)){
list_clin_study[[i]] <- list_df_simulated[[i]][list_df_simulated[[i]]$new_study_id
%in% clin_study_ids,]
}
# count the number of studies
study_count_clin_study <- count_studies(df_long_for_metan[df_long_for_metan$new_study_id %in% clin_study_ids,])
# CB checked, correct.
# apply the metareg function to the list of clinical studies
model_1 <- as.formula(~ four_level_var)
list_model_1_clin_study <- run_metaregression(list_clin_study , model_1)
# extract coefficients and model characteristics.
condition <- levels(list_df_simulated[[1]]$four_level_var)
aggregate_results_clin_study <- aggregate_model_results(list_model_1_clin_study, condition)
# extract SMDs from the list for clinical studies
means_clin_study <- lapply(list_model_1_clin_study, extract_coefficients_func)
# calculate mean SMDs and ses
condition <- levels(list_df_simulated[[1]]$four_level_var) # for the conditino argument
coef_and_se_means_clin_study <- calculate_mean_coefs_ses(means_clin_study, condition)
coef_and_se_means_clin_study <- data.frame(cbind(condition, coef_and_se_means_clin_study))
# add the ns to the dataframe
coef_and_se_means_clin_study$n <- study_count_clin_study[study_count_clin_study$is_missing ==F,]$n
```
## Included studies
The data for the studies included in this metanalysis are summarised in Supplementary Table 1 and are also available as a csv dataframe on \[<https://github.com/transatlantic-comppsych/apples_oranges>\].
In total, there were `r length(unique(df_long_for_metan$new_study_id))` studies which included `r df_count_studies[df_count_studies$condition == "medication_active"& df_count_studies$is_missing == FALSE,]$n` active arms and `r df_count_studies[df_count_studies$condition == "medication_control"& df_count_studies$is_missing == FALSE,]$n` control arms of antidepressant trials; and `r df_count_studies[df_count_studies$condition == "psychotherapy_active"& df_count_studies$is_missing == FALSE,]$n` active arms and `r df_count_studies[df_count_studies$condition == "psychotherapy_control"& df_count_studies$is_missing == FALSE,]$n` control arms from psychotherapy trials. Note that the number of active and control arms does not exactly match because some studies feature more than one control or active arm. There were also missing data for `r df_count_studies[df_count_studies$condition == "medication_active"& df_count_studies$is_missing == TRUE,]$n`, `r df_count_studies[df_count_studies$condition == "medication_control"& df_count_studies$is_missing == TRUE,]$n`, `r df_count_studies[df_count_studies$condition == "psychotherapy_active"& df_count_studies$is_missing == TRUE,]$n`, and `r df_count_studies[df_count_studies$condition == "psychotherapy_control"& df_count_studies$is_missing == TRUE,]$n` trial arms for medication active, medication control, psychotherapy active, and psychotherapy control conditions respectively, as the data needed to calculate the SMD was missing and could not be imputed by any of the methods outlined above.
Placebo was the control condition for all medication trials; the active arm ranged from serotonin reuptake inhibitors, such as 6 fluoxetine and 2 escitalopram, to tricylics, such as 2 nortriptyline. In psychological trials, the control arm included 14 WL controls, 25 care as usual and several other conditions such as 4 attention control conditions; the active arm included 43 CBT and 8 IPT amongst others. All included trials and the types of treatment controls can be found in Supplementary Table 1.
## Sample characteristics at baseline in medication versus psychotherapy trials
Table 1 summarises the results from each of the meta-analyses examining sample characteristics at baseline. The summary statistics are provided for each subgroup (i.e. for medication and psychotherapy trials) and the p-value derives from the test for subgroup differences. Full results for each of the sensitivity analyses are included in the Supplementary Materials (Table X - Y).
```{r, warning=FALSE, message = FALSE, echo=FALSE}
# Start by looking at demographics at baseline
# Currently we have both control and active conditions, we just need each study once
df_baseline_demographics <- df_long_for_metan %>%
distinct(new_study_id, .keep_all = TRUE)
# This is the function to extract statistics
extract_stats <- function(df) {
# get the summary table with results
statistics <- summary(df, byvar = "psy_or_med")
df_stats <- tibble(
subgroup = statistics$subgroup.levels,
k_study = statistics$k.study.w,
TE_random = statistics$TE.random.w,
seTE_random = statistics$seTE.random.w,