Hi I would like to ask how CreateTableOne
in R calculates standardised mean differences for variables with multiple categories.
I used matchit
to conduct propensity score matching, and then used CreateTableOne
to create a summary table to check the balances between the treatment and control groups. This is the code that I wrote:
matched_outcome <- matchit(treatment ~ age_group + gender, data = mydata, method = "nearest")
matched_data <- match.data(matched_outcome)
xvars <- c("age_group", "gender")
matched_table1 <- CreateTableOne(vars = xvars, strata = "treatment", data = matched_data, test = F)
print(matched_table1, smd = T)
Stratified by treatment Stratified by treatment SMD
0 1
n 656 656
age_group (%) 0.048
19-49 28 (4.3) 25 (3.8)
50-64 63 (9.6) 69 (10.5)
65-74 110 (16.8) 110 (16.8)
75-84 195 (29.7) 202 (30.8)
85+ 259 (39.5) 249 (38.0)
Under 19 1 (0.2) 1 (0.2)
gender = Male (%) 324 (49.4) 322 (49.1) 0.006
I understand how the SMD (standardised mean difference) for gender was calculated since it's binary. However, I don't know how the SMD was calculated for age_group. I checked the documentation for CreateTableOne
. The documentation only says that "......standardized mean differences for all pairwise comparisons are calculated".
I would be really grateful if someone can help me to understand how the this is calculated. Thanks in advance.