-
Notifications
You must be signed in to change notification settings - Fork 1
/
Manuscript_for_rendering_in_word.qmd
3385 lines (2666 loc) · 183 KB
/
Manuscript_for_rendering_in_word.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: "Comparing Apples and Oranges in Youth Depression Treatments?"
subtitle: "A Quantitative Critique of the Evidence Base and Guidelines"
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: Rudolf Uher
email: [email protected]
affiliations:
- id: dal
name: Dalhousie University
department: Department of Psychiatry
address:
city: Nova Scotia
state:
postal-code:
country: Canada
- name: Dayna Bhudia
email: [email protected]
affiliations:
- ref: ucl_1
- name: Despoina Miliou
email: [email protected]
affiliations:
- ref: ucl_1
- name: Ioannis-Marios Rokas
email: <[email protected]
affiliations:
- ref: ucl_1
- name: Marinos Kyriakopoulos
- 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: Glyn Lewis
email: [email protected]
affiliations:
- ref: ucl_1
- name: Georgina Krebs
email: [email protected]
affiliations:
- ref: ucl_1
note:
keywords:
- depression
- adolescents
- antidepressants
- psychotherapy
date: last-modified
format:
docx:
reference-doc: custom-reference-doc.docx
fig-width: 9
fig-height: 7
fig_caption: yes
tbl_caption: yes
numer-sections: true
editor: visual
bibliography: "emotion_concepts_paper.bib"
csl: "vancouver.csl"
font:
family: "Calibri"
prefer-html: true
fig-format: png
fig-cap-location: top
---
##
------------------------------------------------------------------------
------------------------------------------------------------------------
```{r, warning=FALSE, message = FALSE, echo=FALSE}
###########Libraries needed
library(tidyverse)
library(truncnorm)
library(metafor)
library(meta)
library(kableExtra)
library(flextable)
library(magrittr)
library(officer)
library(RefManageR)
library(ftExtra)
library(dplyr)
library(broom)
library(effsize)
# For referencing
bib_data <- ReadBib("emotion_concepts_paper.bib")
```
```{r global_options, include=FALSE}
knitr::opts_chunk$set(tab.cap.fp_text = officer::fp_text_lite(italic = FALSE, bold = TRUE))
```
# Abstract
**Question:** Should a young person receive psychotherapy or medication for their depression, and on what evidence do we base this decision? In this paper, we test whether the basic conditions required to draw valid inferences to answer this question are currently met.
**Study selection and analysis:** We included 88 RCTs of psychotherapy and medication for child and adolescent depression (mean age 4-18 years). Using meta-analyses, we compared a) participant characteristics and b) trial characteristics in medication and psychotherapy trials. Lastly, we examined whether psychotherapy controls are well-matched to active conditions.
**Findings:** Participants in medication RCTs had higher depression severity and were more frequently male compared to psychotherapy RCTs. There was a dramatic difference in the within-subject improvement due to placebo (SMD=-1.9 (95% CI: -2.10 to -1.70)) vs psychotherapy controls (SMD=-0.5 (95% CI: -0.75 to -0.25)). Within psychotherapy RCTs, control conditions were less intensive on average than active conditions.
**Conclusions:** Medication and psychotherapy RCTs differ on fundamental participant and methodological characteristics, thereby violating key conditions for valid comparison between them. Psychotherapy controls often involve little therapist contact and are easy-to-beat comparators. These findings cast doubt on the confidence with which psychotherapy is recommended for youth depression, and highlight the pressing need to improve the evidence base.
# Key messages
Psychotherapy is recommended before medication for most cases of depression in children and adolescents, a recommendation that is based on indirect comparisons of outcomes from randomised controlled trials (RCTs) within each treatment modality. We examine the validity of these inferences by scrutinising the comparability of psychotherapy and medication RCTs. We find significant differences in sample characteristics (namely depression severity and sex composition) and trial design features, such that the within-group effect sizes of medication controls (i.e. pill placebo) are much larger than those for psychotherapy controls, and that medication RCTs feature significantly more trial sites. We also examine the quality of controls used in psychotherapy RCTs and find that they are poorly matched to active intervention arms in ways such as human contact hours, and hence represent poor and easy to beat comparators. Our findings underscore the need for a higher quality evidence base upon which to base treatment guidelines and clinical decision making.
# Background
Should a child or an adolescent receive psychotherapy or medication for their depression, and what information should be used to guide decision-making?
For adolescent depression, there are limited head-to-head trials of medication and psychotherapy, and hence recommendations are derived from indirect comparisons of treatment efficacy. The National Institute of Health and Care Excellence (NICE) guidelines for adolescent depression recommend psychotherapy (specifically cognitive behaviour therapy (CBT) or interpersonal therapy (IPT)) over medication in most cases [@niceDepressionChildrenYoung2019]. This is in keeping with two sources of evidence relating to child and adolescent depression: meta-analyses of medication randomised controlled trials (RCTs) that cast doubt on the efficacy of antidepressants, with the exception of fluoxetine [@ciprianiComparativeEfficacyTolerability2016]; and meta-analyses of psychotherapy RCTs that conclude psychotherapy to be efficacious [@cuijpersEffectsPsychologicalTreatments2021]. However, a recent network meta-analysis (NMA) [@zhouComparativeEfficacyAcceptability2020], an established method of comparing treatments using both direct and indirect (i.e. treatment A with treatment C, via studies that directly compare A with B and B with C) evidence, concluded that only fluoxetine alone and fluoxetine administered together with CBT were significantly more effective than medication control (i.e. pill placebo) or psychotherapy controls. The only head-to-head RCT comparing modalities found that fluoxetine, alone and in combination with CBT, was superior to pill placebo, though CBT alone was not [@marchFluoxetineCognitiveBehavioralTherapy2004]. Given this confusing evidence base, how should patients, carers, clinicians and policy makers make treatment decisions?
In this paper, we examine whether the existing evidence for adolescent depression treatments can offer valid answers to this question. We provide a conceptual framework and test a series of hypotheses using data from existing trials. Two points are crucial to indirect comparisons of treatment modalities. First, whether the participants in trials are comparable across modalities. Second, whether key conditions of the trial, such as the effects of control conditions or the number of sites involved, are comparable.
Starting with the first point, comparison between different trials assumes that they sample from the same population. If not, the validity of any comparisons, including those conducted through NMA (which rests on the principal of transitivity, i.e. the requirement that the different sets of randomized trials are similar on average [@chaimaniChapter11Undertaking2023]) 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)\ -->
<!-- $$ -->
<!-- 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})$$ -->
<!-- signifying that the effect found in the population would be expected to be found in the same population for each treatment. -->
The assumption that medication and psychotherapy trials sample from the same population may not be valid as patients and parents often have treatment preferences [@jaycoxAdolescentPrimaryCare2006; @langerParentYouthPreferences2021; @mchughPatientPreferencePsychological2013], meaning that there is likely to be a self-selection bias in who participates in psychotherapy and medication trials. Moreover, treatment preferences correlate with clinically-relevant participant characteristics, including severity and sex. Some of these characteristics, such as severity, may moderate treatment response [@courtneyPredictorsModeratorsMediators2022; @lorenzo-luacesDoubleTroubleSymptom2020] and if they differ across psychotherapy and medication trials they may confound comparisons.
Regarding the second point, differences in trial design may impact outcomes in a differential way between medication and psychotherapy trials [@delgiovaneCombiningPharmacologicalNonpharmacological2019]. Most obviously, participants in psychotherapy trials are generally unblinded to treatment allocation, with the exception perhaps of trials that compare two equally plausible treatment arms [@calvoInterventionAdolescentsEarlyOnset2014]. This creates differential expectations which may favour the psychotherapy active condition, as participants are content to be receiving the “cutting edge” treatment, whilst those in the control are dissatisfied for having missed out (i.e. “disappointment bias” [@reltonEthicsTrialsCohorts2017]. By contrast, in new antidepressant trials, patients (and raters) were largely unable to judge treatment allocation [@linAssessmentBlindingRandomized2022], suggesting that expectancy effects are well-matched across conditions. Since expectancy is substantially associated with treatment outcomes [@constantinoExpectations2011], if expectancy differs between medication and psychotherapy trials, comparisons between them, including in NMA, become questionable.
Another difference in design is the number of trial sites. The number of sites in medication trials is positively related to the magnitude of placebo response [@bridgePlaceboResponseRandomized2009; @dechartresSingleCenterTrialsShow2011; @meisterPlaceboResponseRates2020]. This phenomenon may be due to lower quality of assessments in multi-site trials, with higher rates of classification errors and therefore higher apparent spontaneous remission or regression to the mean.
An inter-related issue concerns the effect of control conditions. Often psychotherapy and medication are compared on the basis of their respective effect sizes (i.e. differences between the active and control conditions for each modality). For these to be comparable, medication and psychotherapy controls ought to be equal in their effects. 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% versus 60% and another from a difference of 40% versus 0% (i.e. from different points of reference).
Additionally, control conditions in RCTs should generate counterfactual conditions to the intervention [@guoChapterCounterfactualFramework2014]: what would have been the outcome had an individual not received the intervention, with all else being equal. Pill placebo, where the appearance of the drug is faithfully emulated, is an effort for all else to be equal. In psychotherapy trials, control conditions may not be so well matched to the intervention (e.g. in number of hours of therapist contact).
# Objective
In this study we examine RCTs of psychotherapy and medication for child and adolescent depression (mean age 4-18 years). We hypothesise that there are substantial differences between psychotherapy and medication RCTs, making their comparison problematic, which we examine in the following ways. First, we conduct meta-analyses to compare sample characteristics of medication and psychotherapy trials including: a) baseline depression severity; b) percentage females; and c) mean age. Second, we examine trial characteristics including the efficacy of the control arms, using random-effects meta-regression, and the number of trial sites. Third, we examine the quality of psychotherapy control conditions by scrutinising the extent to which they are matched to the active intervention in ways such as number and frequency of sessions, and hence whether they represent fair pairings from which to draw valid efficacy inferences.
# Study selection and analysis
The study protocol was registered on the Open Science Framework (OSF) and can be found [here](https://osf.io/bfmc6).
A detailed description of our methods, including formalisms on which analyses are based, can be found in the Supplement.
## Included studies
We included RCTs identified in a recent meta-analysis of psychotherapy versus control [@cuijpersEffectsPsychologicalTreatments2021] and an NMA examining the efficacy of antidepressants [@ciprianiComparativeEfficacyTolerability2016] for depression in children and adolescents. For the psychotherapy trials, we utilised open data from the previous meta-analysis (see [here](https://docs.metapsy.org/databases/depression-childadol-psyctr/)). For medication trials, we were unable to access the full dataset used in the NMA and hence extracted data from the included studies ourselves.
For medication trials, we also conducted a systematic search for studies published after the final search date of Cipriani et al.'s [@ciprianiComparativeEfficacyTolerability2016] review up to the final search date of Cuijpers et al's [@cuijpersEffectsPsychologicalTreatments2021] review to ensure we analysed an equivalently up-to-date database of medication trials. Two authors screened 450 titles and abstracts, and 38 full text records. Seven studies met inclusion criteria and one author completed data extraction for these papers (see @fig-prisma for PRISMA diagram).
## Statistical Analysis
### Sample characteristics
We conducted random-effects meta-analyses and tested subgroup differences (psychotherapy vs medication trials) in severity of depressive symptoms, sex and age. Meta-analyses were implemented using R's meta package.
<!-- In order to compare depression severity across the variety of instruments the studies used, 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}} -->
<!-- $$ -->
<!-- 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}} -->
<!-- $$ -->
<!-- where $\text{SD}_{X}$ is the original standard deviation of the mean at baseline. -->
### Trial design
#### Measures of Effect
As the measure of effect of each individual study, we used the within-group Standardised Mean Difference (SMD) for the primary depression scale used (selected according to the hierarchy defined in the Supplement).
<!-- which we defined following [@lakensCalculatingReportingEffect2013, @cummingUnderstandingNewStatistics2013] 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 in this Cochrane Handbook [@higginsChapterChoosingEffect2023].
<!-- 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 et al.'s meta-analysis. -->
For meta-analysis it is necessary to estimate a standard error of the SMD. This requires a correlation between the pre- and post-measures, a statistic typically not reported. To ensure that our results are not biased by misestimation, we simulated n=1000 datasets for different values (0.45 to 0.9) of this correlation and used these datasets in subsequent analyses (please refer to Supplement for full details).
<!-- This is calculated according to: -->
<!-- $$ SE_{SMD} = \sqrt{\frac{2(1 -r_{t_{1}t_{2}})}{n} + \frac{SMD^2}{2n}}$$ -->
<!-- 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)$$ -->
<!-- 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 meta-analyses. -->
#### Random-effects Metaregression
We estimated the pooled SMD for each arm by using a random-effects meta-analysis implemented in R's metafor package.
<!-- The main underlying assumption of random-effects meta-analysis 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) -->
<!-- $$ -->
<!-- $$\theta_i \sim \mathcal{N}(x_i\beta, \tau_i^2) -->
<!-- $$ -->
<!-- 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$$ -->
<!-- where, -->
<!-- $$u_i \sim N(0, \tau^2) $$ -->
<!-- describes the deviation of each study from the mean of the distribution, and, -->
<!-- $$\epsilon_i \sim N(0, \sigma^2)$$ -->
<!-- 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}$$ -->
<!-- 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})} -->
<!-- $$ -->
<!-- We used maximum likelihood (ML) to estimate model and applied Hartung-Knapp adjustment to reduce the chance of false positives [@inthoutHartungKnappSidikJonkmanMethodRandom2014]. -->
We present the SMDs of each of the four treatment arms (medication control, medication active, psychotherapy control, psychotherapy active) under investigation. The SMDs are the means across the 1000 simulated datasets.
#### Number of sites
We also conducted a t-test to compare mean number of trial sites between psychotherapy and medication trials.
### Sensitivity Analyses
```{r, warning=FALSE, message = FALSE, echo = FALSE, output = 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")
x
```
We conducted a series of sensitivity analyses where we excluded studies that 1) used waitlist as their control and 2) recruited participants with subclinical levels of depression. Next, we conducted two analyses where we included only trials that used the Children's Depression Rating Scale, Revised (CDRS-R) or the Hamilton Depression Rating Scale (HAM-D) as outcome instruments.
Further, we tested whether the simulated values for the standard error had a substantial influence on the estimation of the differences between the medication and psychotherapy control conditions. 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 critical value of z = `r x` corresponding to an alpha = 0.05.
Finally, we examined whether differential regression to the mean may account for differences in effect for psychotherapy and medication trials.
### Comparing the control and active arms of psychotherapy trials
We ran t-tests to compare the active and control arms of psychotherapy trials on key variables of interest regarding the intensity of the interventions: the number, duration and intensity of sessions, and the total cumulative hours and duration of the intervention.
```{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) {
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" = "deeppink4", "Medication Active" = "deeppink")
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() +
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, family = "Calibri"),
axis.text.x = element_text(size = 12, family = "Calibri"),
axis.text.y = (element_blank()),
plot.title = element_text(size = 12, family = "Calibri", face= "italic"),
plot.subtitle = element_text(size = 12, family = "Calibri", face= "italic")) +
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}
# 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 meta-analyses
# 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, instrument_name) %>%
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, instrument_name) %>%
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 for the first set of meta-analyses 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(sex_overall = sum(percent_women * baseline_n) / sum(baseline_n)) %>%
mutate(percent_women = coalesce(percent_women_overall, sex_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, sex_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",]
# For response rate, recalculating after turning long and doing all the imputations
# df_long_for_metan <- df_long_for_metan %>%
# rowwise() %>%
# mutate(responders = sum(rnorm(baseline_n, post_mean,
# post_sd) < (baseline_mean/ 2)))
#
# df_long_for_metan <- df_long_for_metan %>%
# rowwise() %>%
# mutate(resp_rate = responders/baseline_n)
#
# summary_resp_rate <- df_long_for_metan %>%
# group_by(group) %>%
# summarise(mean_resp_rate = mean(resp_rate, na.rm = TRUE),
# sd_resp_rate = sd(resp_rate, na.rm = TRUE),
# n = n())
# 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
```
# Findings
```{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 ------------------------------------------------------
# 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 <- left_join(df_mean_coefs_from_sim, df_count_studies[df_count_studies$is_missing == FALSE, ] %>%
ungroup() %>%
select(condition, n),
by = "condition")
# 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 <- left_join(coef_and_se_means_cbt_fluox_esc_study, study_count_cbt_fluox_esc_study[study_count_cbt_fluox_esc_study$is_missing == FALSE, ] %>%
ungroup() %>%
select(condition, n),
by = "condition")
# 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 <- left_join(coef_and_se_means_no_wl, study_count_no_wl_study[study_count_no_wl_study$is_missing == FALSE, ] %>%
ungroup() %>%
select(condition, n),
by = "condition")
# D 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,])