ngreifer / cobalt

Covariate Balance Tables and Plots - An R package for assessing covariate balance
https://ngreifer.github.io/cobalt/
73 stars 11 forks source link

bal.tab.default() does not show the results of adjusted correlation in continuous exposure. #55

Closed yohei-h closed 3 years ago

yohei-h commented 3 years ago

Hello, Noah Greifer

I would like to estimate the effect of continuous exposure on binary outcomes. For my dataset, exposure is 'ADLScaled'; covariates are 'Age', 'sex', 'HT', 'DM', 'Stroke', and 'MI'; outcomes is 'sequela'; and weights are 'swtTrimmed'. I have run the following R code, but I cannot get adjusted correlation.

library(cobalt)
library(data.table)

dt <- fread('dt_sample.csv')
dt_covs <- dt[, .(Age, sex, HT, DM, Stroke, MI)] 
baltab <- bal.tab(x = dt_covs, 
                  data = dt,               
                  treat = 'ADLScaled',     
                  method = 'weighting',
                  weigths =  'swtTrimmed', 
                  un = T,
                  thresholds = 0.1
        )

The output is as follows, and only 'Corr.Un' is shown (Corr.Adj is not):


Balance Measures Type Corr.Un R.Threshold.Un Age Contin. -0.8869 Not Balanced, >0.1 sex_男 Binary 0.0013 Balanced, <0.1 HT Binary -0.5920 Not Balanced, >0.1 DM Binary -0.5876 Not Balanced, >0.1 Stroke Binary -0.5057 Not Balanced, >0.1 MI Binary -0.5535 Not Balanced, >0.1

Balance tally for treatment correlations count Balanced, <0.1 1 Not Balanced, >0.1 5

Variable with the greatest treatment correlation Variable Corr.Un R.Threshold.Un Age -0.8869 Not Balanced, >0.1

Sample sizes Total All 15000


I would appreciate it if you could tell me how to calculate adjusted (weighted) correlation values for continuous exposure. The dataset is as follows: dt_sample.csv

Sincerely yours, yohei-h

ngreifer commented 3 years ago

It's because you spelled weights wrong.

yohei-h commented 3 years ago

That was a very simple mistake... Sorry. Thank you so much!

ngreifer commented 3 years ago

It happens :)