2
$\begingroup$

I am interested in calculating the standardised difference for a multinomial variable. In R there is a package called tableone that produces such calculations (https://cran.r-project.org/web/packages/tableone/vignettes/smd.html). In this vignette there is a calculation for race, with a smd of 0.036.

race (%)                                                0.036
     black                  585 (16.5)      335 (15.3)         
     other                  213 ( 6.0)      142 ( 6.5)         
     white                 2753 (77.5)     1707 (78.2)         

to work through this calculation I used the "building block" code here https://rpubs.com/kaz_yos/smd1

> T <- c(213.0/3551.0, 2753.0/3551.0)
> C <- c(142.0/2184.0, 1707.0/2184.0)
> T
[1] 0.0599831 0.7752746
> C
[1] 0.06501832 0.78159341
> meanDiffVector<-(T-C)
> vcovT <- -1 * outer(T, T)
> diag(vcovT) <- T * (1-T)
> vcovT
            [,1]        [,2]
[1,]  0.05638513 -0.04650337
[2,] -0.04650337  0.17422391
> vcovC <- -1 * outer(C, C)
> diag(vcovC) <- C * (1-C)
> vcovC
            [,1]        [,2]
[1,]  0.06079093 -0.05081789
[2,] -0.05081789  0.17070515
> S<-(vcovC+vcovT)/2
> S
            [,1]        [,2]
[1,]  0.05858803 -0.04866063
[2,] -0.04866063  0.17246453
> Sinv <- solve(S)
> Sinv
          [,1]     [,2]
[1,] 22.292318 6.289747
[2,]  6.289747 7.572937
> smdCat <- drop(t(meanDiffVector) %*% Sinv %*% t(t(meanDiffVector)))
> smdCat
[1] 0.001267793

with a value of 0.00127 not the 0.036.

Both methods claim to follow the method in Yang and Dalton (2012) "... extension to multinomival variables is suggested in Yang et al 2012. This multinomial extension treats a single multinomial variable as multiple non-redundant dichotomous variables and use the Mahalanobis distance. The off diagonal elements of the covariance matrix on page 3 have an error, and need negation." https://www.rdocumentation.org/packages/tableone/versions/0.12.0/topics/CreateTableOne

Yang, D. and Dalton, JE. (2012). A unified approach to measuring the effect size between two groups using SAS. SAS Global Forum 2012, Paper 335-2012. http://support.sas.com/resources/papers/proceedings12/335-2012.pdf

$\endgroup$

1 Answer 1

1
$\begingroup$

Doh! sqrt(0.001267793) = 0.036.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.