library(dplyr)
library(tidyr)
library(lme4)
library(emmeans)
library(car)
# Set the working directory containing the source CSV file
setwd(
"/Users/savannahwalske/Library/CloudStorage/Dropbox-PartnersHealthCare/Savannah Walske/Koa projects/Koa BDD/Publications_Presentations/SMW ADAA 2027/Stats"
)
data <- read.csv(
"Koa BDD Ph2 - insight and symptom data 10-28-2026.csv"
)
The variables of interest are the BDD-YBOCS total, insight category, patient-rated CGI-I, and clinician-rated CGI-I. To reduce mathematical overlap between symptom severity and insight, the adjusted BDD-YBOCS score excludes Item 11, which corresponds to the BABS summary score.
Participants are retained if they have nonmissing adjusted BDD-YBOCS and patient-rated CGI-I data at Week 12. Only baseline and Week 12 observations are retained for the wide-format analytic dataset.
data_complete <- data %>%
# Recode BABS summary while the data are still long.
# Dataset coding: 1-3 = Excellent/Good/Fair insight;
# 4-5 = Poor/Absent insight.
mutate(
babs_summary_recode = case_when(
babs_summary %in% c(1, 2, 3) ~ 0,
babs_summary %in% c(4, 5) ~ 1,
TRUE ~ NA_real_
),
babs_insight_group = factor(
babs_summary_recode,
levels = c(0, 1),
labels = c(
"Excellent/Good/Fair Insight",
"Poor/Absent Insight"
)
),
# Subtract Item 11/BABS summary from the BDD-YBOCS total.
bddybocs_tot_nobabs = bddybocs_tot_recalc - babs_summary
) %>%
group_by(scrnid) %>%
filter(
any(
week == 12 &
!is.na(bddybocs_tot_nobabs) &
!is.na(cgip_imp_bdd)
)
) %>%
ungroup() %>%
filter(week %in% c(0, 12)) %>%
pivot_wider(
id_cols = scrnid,
names_from = week,
values_from = -c(scrnid, week),
names_glue = "{.value}_week{week}"
) %>%
mutate(
# Positive values indicate symptom reduction.
bddybocs_pct_reduction = case_when(
is.na(bddybocs_tot_nobabs_week0) |
is.na(bddybocs_tot_nobabs_week12) ~ NA_real_,
bddybocs_tot_nobabs_week0 == 0 ~ NA_real_,
TRUE ~ (
(bddybocs_tot_nobabs_week0 - bddybocs_tot_nobabs_week12) /
bddybocs_tot_nobabs_week0
) * 100
),
# Signed discrepancy: clinician CGI-I minus patient CGI-I.
# Negative values indicate a lower clinician rating than patient rating.
cgii_discrepancy = cgic_imp_bdd_week12 - cgip_imp_bdd_week12
)
data_complete %>%
summarise(n_participants = n())
## # A tibble: 1 × 1
## n_participants
## <int>
## 1 65
age_summary <- data_complete %>%
summarise(
n_age = sum(!is.na(age_week0)),
mean_age = mean(age_week0, na.rm = TRUE),
sd_age = sd(age_week0, na.rm = TRUE)
)
age_summary
## # A tibble: 1 × 3
## n_age mean_age sd_age
## <int> <dbl> <dbl>
## 1 65 26.5 9.44
gender_summary <- data_complete %>%
filter(!is.na(genderidentity_week0)) %>%
count(genderidentity_week0, name = "n") %>%
mutate(percent = n / sum(n) * 100)
gender_summary
## # A tibble: 3 × 3
## genderidentity_week0 n percent
## <int> <int> <dbl>
## 1 1 53 81.5
## 2 2 11 16.9
## 3 4 1 1.54
race_summary <- data_complete %>%
filter(!is.na(race_white_week0)) %>%
count(race_white_week0, name = "n") %>%
mutate(percent = n / sum(n) * 100)
race_summary
## # A tibble: 2 × 3
## race_white_week0 n percent
## <int> <int> <dbl>
## 1 0 21 32.3
## 2 1 44 67.7
treatment_group_summary <- data_complete %>%
filter(!is.na(tx_group_week0)) %>%
count(tx_group_week0, name = "n") %>%
mutate(percent = n / sum(n) * 100)
treatment_group_summary
## # A tibble: 2 × 3
## tx_group_week0 n percent
## <int> <int> <dbl>
## 1 0 37 56.9
## 2 1 28 43.1
cgii_summary <- data_complete %>%
summarise(
n_discrepancy = sum(!is.na(cgii_discrepancy)),
mean_discrepancy = mean(cgii_discrepancy, na.rm = TRUE),
sd_discrepancy = sd(cgii_discrepancy, na.rm = TRUE),
mean_cgip = mean(cgip_imp_bdd_week12, na.rm = TRUE),
sd_cgip = sd(cgip_imp_bdd_week12, na.rm = TRUE),
mean_cgic = mean(cgic_imp_bdd_week12, na.rm = TRUE),
sd_cgic = sd(cgic_imp_bdd_week12, na.rm = TRUE)
)
cgii_summary
## # A tibble: 1 × 7
## n_discrepancy mean_discrepancy sd_discrepancy mean_cgip sd_cgip mean_cgic
## <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 65 -0.477 0.773 3.37 1.27 2.89
## # ℹ 1 more variable: sd_cgic <dbl>
Insight is summarized at baseline and Week 12 for the full analytic sample. Week 12 insight is also summarized separately by treatment group.
insight_summary <- data_complete %>%
summarise(
# Baseline
N_week0 = sum(!is.na(babs_summary_recode_week0)),
Excellent_Good_Fair_week0 = sum(
babs_summary_recode_week0 == 0,
na.rm = TRUE
),
Percent_Excellent_Good_Fair_week0 = mean(
babs_summary_recode_week0 == 0,
na.rm = TRUE
) * 100,
Poor_Absent_week0 = sum(
babs_summary_recode_week0 == 1,
na.rm = TRUE
),
Percent_Poor_Absent_week0 = mean(
babs_summary_recode_week0 == 1,
na.rm = TRUE
) * 100,
# Week 12
N_week12 = sum(!is.na(babs_summary_recode_week12)),
Excellent_Good_Fair_week12 = sum(
babs_summary_recode_week12 == 0,
na.rm = TRUE
),
Percent_Excellent_Good_Fair_week12 = mean(
babs_summary_recode_week12 == 0,
na.rm = TRUE
) * 100,
Poor_Absent_week12 = sum(
babs_summary_recode_week12 == 1,
na.rm = TRUE
),
Percent_Poor_Absent_week12 = mean(
babs_summary_recode_week12 == 1,
na.rm = TRUE
) * 100
)
insight_summary
## # A tibble: 1 × 10
## N_week0 Excellent_Good_Fair_week0 Percent_Excellent_Good_F…¹ Poor_Absent_week0
## <int> <int> <dbl> <int>
## 1 65 18 27.7 47
## # ℹ abbreviated name: ¹​Percent_Excellent_Good_Fair_week0
## # ℹ 6 more variables: Percent_Poor_Absent_week0 <dbl>, N_week12 <int>,
## # Excellent_Good_Fair_week12 <int>, Percent_Excellent_Good_Fair_week12 <dbl>,
## # Poor_Absent_week12 <int>, Percent_Poor_Absent_week12 <dbl>
insight_summary_group <- data_complete %>%
group_by(tx_group_week0) %>%
summarise(
N_week12 = sum(!is.na(babs_summary_recode_week12)),
Excellent_Good_Fair_week12 = sum(
babs_summary_recode_week12 == 0,
na.rm = TRUE
),
Percent_Excellent_Good_Fair_week12 = mean(
babs_summary_recode_week12 == 0,
na.rm = TRUE
) * 100,
Poor_Absent_week12 = sum(
babs_summary_recode_week12 == 1,
na.rm = TRUE
),
Percent_Poor_Absent_week12 = mean(
babs_summary_recode_week12 == 1,
na.rm = TRUE
) * 100,
.groups = "drop"
)
insight_summary_group
## # A tibble: 2 × 6
## tx_group_week0 N_week12 Excellent_Good_Fair_week12 Percent_Excellent_Good_Fa…¹
## <int> <int> <int> <dbl>
## 1 0 37 15 40.5
## 2 1 28 21 75
## # ℹ abbreviated name: ¹​Percent_Excellent_Good_Fair_week12
## # ℹ 2 more variables: Poor_Absent_week12 <int>,
## # Percent_Poor_Absent_week12 <dbl>
cor_data_cgi <- data_complete %>%
filter(
!is.na(cgic_imp_bdd_week12),
!is.na(cgip_imp_bdd_week12)
)
cgii_correlation <- cor.test(
cor_data_cgi$cgic_imp_bdd_week12,
cor_data_cgi$cgip_imp_bdd_week12,
method = "pearson"
)
cgii_correlation
##
## Pearson's product-moment correlation
##
## data: cor_data_cgi$cgic_imp_bdd_week12 and cor_data_cgi$cgip_imp_bdd_week12
## t = 10.685, df = 63, p-value = 8.851e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.6949147 0.8752820
## sample estimates:
## cor
## 0.8027556
This model examines whether Week 12 insight category and percent reduction in adjusted BDD-YBOCS scores are associated with the signed discrepancy between clinician- and patient-rated CGI-I scores.
insight_model <- lm(
cgii_discrepancy ~
babs_insight_group_week12 +
bddybocs_pct_reduction,
data = data_complete
)
summary(insight_model)
##
## Call:
## lm(formula = cgii_discrepancy ~ babs_insight_group_week12 + bddybocs_pct_reduction,
## data = data_complete)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.6715 -0.4719 0.2607 0.4961 1.6252
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) -0.201600 0.198513 -1.016
## babs_insight_group_week12Poor/Absent Insight -0.252175 0.209020 -1.206
## bddybocs_pct_reduction -0.005713 0.004024 -1.420
## Pr(>|t|)
## (Intercept) 0.314
## babs_insight_group_week12Poor/Absent Insight 0.232
## bddybocs_pct_reduction 0.161
##
## Residual standard error: 0.7697 on 62 degrees of freedom
## Multiple R-squared: 0.03891, Adjusted R-squared: 0.007903
## F-statistic: 1.255 on 2 and 62 DF, p-value: 0.2922
vif(insight_model)
## babs_insight_group_week12 bddybocs_pct_reduction
## 1.18454 1.18454
pct_reduction_by_insight <- data_complete %>%
group_by(babs_insight_group_week12) %>%
summarise(
n = sum(!is.na(bddybocs_pct_reduction)),
mean_pct_reduction = mean(bddybocs_pct_reduction, na.rm = TRUE),
sd_pct_reduction = sd(bddybocs_pct_reduction, na.rm = TRUE),
.groups = "drop"
)
pct_reduction_by_insight
## # A tibble: 2 × 4
## babs_insight_group_week12 n mean_pct_reduction sd_pct_reduction
## <fct> <int> <dbl> <dbl>
## 1 Excellent/Good/Fair Insight 36 37.6 28.5
## 2 Poor/Absent Insight 29 17.1 17.1
pct_reduction_t_test <- t.test(
bddybocs_pct_reduction ~ babs_insight_group_week12,
data = data_complete
)
pct_reduction_t_test
##
## Welch Two Sample t-test
##
## data: bddybocs_pct_reduction by babs_insight_group_week12
## t = 3.5906, df = 58.573, p-value = 0.0006757
## alternative hypothesis: true difference in means between group Excellent/Good/Fair Insight and group Poor/Absent Insight is not equal to 0
## 95 percent confidence interval:
## 9.074046 31.926850
## sample estimates:
## mean in group Excellent/Good/Fair Insight
## 37.64561
## mean in group Poor/Absent Insight
## 17.14516
par(mfrow = c(2, 2))
plot(insight_model)
par(mfrow = c(1, 1))
sessionInfo()
## R version 4.5.1 (2025-06-13)
## Platform: aarch64-apple-darwin20
## Running under: macOS 27.2.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] car_3.1-5 carData_3.0-6 emmeans_2.0.4 lme4_2.0-1 Matrix_1.7-3
## [6] tidyr_1.3.2 dplyr_1.2.1
##
## loaded via a namespace (and not attached):
## [1] utf8_1.2.6 sass_0.4.10 generics_0.1.4 lattice_0.22-7
## [5] digest_0.6.37 magrittr_2.0.3 evaluate_1.0.4 grid_4.5.1
## [9] estimability_2.0.0 mvtnorm_1.4-2 fastmap_1.2.0 jsonlite_2.0.0
## [13] Formula_1.2-5 purrr_1.2.2 jquerylib_0.1.4 abind_1.4-8
## [17] reformulas_0.4.4 Rdpack_2.6.6 cli_3.6.5 rlang_1.3.0
## [21] rbibutils_2.4.1 splines_4.5.1 withr_3.0.2 cachem_1.1.0
## [25] yaml_2.3.10 tools_4.5.1 nloptr_2.2.1 coda_0.19-4.1
## [29] minqa_1.2.8 boot_1.3-31 vctrs_0.7.3 R6_2.6.1
## [33] lifecycle_1.0.5 MASS_7.3-65 pkgconfig_2.0.3 pillar_1.11.0
## [37] bslib_0.9.0 glue_1.8.0 Rcpp_1.1.2 xfun_0.62
## [41] tibble_3.3.0 tidyselect_1.2.1 rstudioapi_0.19.0 knitr_1.50
## [45] xtable_1.8-8 htmltools_0.5.8.1 nlme_3.1-168 rmarkdown_2.32
## [49] compiler_4.5.1