# install.packages("devtools")
library(devtools)
install_github("metinbulus/hcttest")Robust Inference for Standardized Mean Difference
The development version of the hcttest package is available on GitHub. Install it using devtools before running the examples below.
library(hcttest)1 Generating contaminated data
mixnormdat <- gendat.hct.test(
mu1 = c(48, 52), # means of mixture components in group 1
mu2 = c(45, 50), # means of mixture components in group 2
sd1 = c(2, 4), # SDs of mixture components in group 1
sd2 = c(10, 12), # SDs of mixture components in group 2
n1 = 107, # sample size in group 1
n2 = 67, # sample size in group 2
distribution = "mixnorm",
mixnorm.weights = c(0.50, 0.50),
group.levels = c("Group 1", "Group 2"),
format = "data"
)
head(mixnormdat) y x
1 51.85515 Group 1
2 46.18604 Group 1
3 47.04583 Group 1
4 45.37702 Group 1
5 52.53402 Group 1
6 48.59258 Group 1
2 Student’s t-test and Cohen’s d
md.const <- hct.test(
y ~ x,
data = mixnormdat,
method = "constant"
) delta se t df p lcl ucl
1 1.3304 1.3143 1.0123 172 0.3128 -1.2637 3.9246
smd.const <- robust.smd(
md.const,
ss.adjust = FALSE, # set TRUE for Hedges' g
ci = "nct"
) d se lcl ucl p
1 0.1577 0.1562 -0.1483 0.4633 NA
3 Welch’s t-test and and Cohen’s d
md.welch <- hct.test(
y ~ x,
data = mixnormdat,
method = "welch",
df = "welch"
) delta se t df p lcl ucl
1 1.3304 1.5884 0.8376 74.8161 0.4049 -1.834 4.4949
smd.welch <- robust.smd(
md.welch,
ss.adjust = FALSE, # set TRUE for Hedges' g
ci = "nct"
) d se lcl ucl p
1 0.1577 0.1887 -0.2127 0.5271 NA
4 Robust inference
md.trim.welch <- hct.test(
y ~ x,
data = mixnormdat,
method = "welch", # or its alias hc2
df = "welch",
trim = 0.20
) delta se t df p lcl ucl
1 1.3 1.9817 0.656 44.2696 0.5152 -2.6932 5.2932
smd.trim.welch <- robust.smd(
md.trim.welch,
ss.adjust = FALSE, # set TRUE for Hedges' g
ci = "nct"
) d se lcl ucl p
1 0.1319 0.2015 -0.2639 0.5262 NA
set.seed(2026)
boot.hct.test(
y ~ x,
data = mixnormdat,
method = "welch",
df = "welch",
trim = 0.20,
boot.rep = 5000
)00 hours : 00 minutes : 26 seconds
est.type est.data est.boot se.boot lcl.boot.perc ucl.boot.perc
1 Raw Scores 1.3000360 1.2612738 1.9394345 -2.5519792 5.0301264
2 Standardized 0.1319069 0.1390787 0.2169384 -0.2704076 0.5896319
lcl.boot.bca ucl.boot.bca
1 -2.5472991 5.0305499
2 -0.2729048 0.5842989
5 Robust meta-analysis weights
data("zhang2023", package = "hcttest")
head(zhang2023) study n1 m1 sd1 n2 m2 sd2
0 Farr (2010) - 1 56 42.75 9.80 50 44.03 9.39
1 Farr (2010) - 2 56 45.80 9.49 50 47.21 8.31
2 Farr (2010) - 3 56 45.10 8.31 50 45.66 8.97
3 Farr (2010) - 4 56 49.73 7.83 50 50.72 9.48
4 Goldberg (2017) - 1 107 47.65 2.04 67 49.98 10.53
5 Goldberg (2017) - 2 107 48.13 1.64 67 48.28 8.45
meta.hc2 <- meta.robust.smd(
zhang2023,
study = "study",
method = "hc2",
ss.adjust = TRUE
)
head(meta.hc2[c("study", "yi", "vi", "weight")]) study yi vi weight
1 Farr (2010) - 1 -0.13224502 0.03775702 16.76720
2 Farr (2010) - 2 -0.15634259 0.03740981 16.86539
3 Farr (2010) - 3 -0.06444115 0.03820873 16.64116
4 Farr (2010) - 4 -0.11366628 0.03874799 16.49316
5 Goldberg (2017) - 1 -0.34538911 0.03835296 16.60132
6 Goldberg (2017) - 2 -0.02770581 0.03754781 16.82623
library(metafor)
rma(yi = yi,
vi = vi,
data = meta.hc2,
method = "REML")
Random-Effects Model (k = 29; tau^2 estimator: REML)
tau^2 (estimated amount of total heterogeneity): 0.0219 (SE = 0.0117)
tau (square root of estimated tau^2 value): 0.1479
I^2 (total heterogeneity / total variability): 56.73%
H^2 (total variability / sampling variability): 2.31
Test for Heterogeneity:
Q(df = 28) = 94.2417, p-val < .0001
Model Results:
estimate se zval pval ci.lb ci.ub
-0.1236 0.0395 -3.1267 0.0018 -0.2011 -0.0461 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
6 References
- Buluş, M. (2026). Robust standard errors and confidence intervals for standardized mean difference. Research Synthesis Methods. Advance online publication. https://doi.org/10.1017/rsm.2026.10130
- Zhang, Y., Huang, H., Wang, M., Zhu, J., Tan, S., Tian, W., Mo, J., Jiang, L., Mo, J., Pan, W., & Ning, C. (2023). Family outcome disparities between sexual minority and heterosexual families: A systematic review and meta-analysis. BMJ Global Health, 8(3), Article e010556. https://doi.org/10.1136/bmjgh-2022-010556