Title: | Compute Standardized Mean Differences |
---|---|
Description: | Computes standardized mean differences and confidence intervals for multiple data types based on Yang, D., & Dalton, J. E. (2012) <https://support.sas.com/resources/papers/proceedings12/335-2012.pdf>. |
Authors: | Bradley Saul [aut, cre], Alex Breskin [ctb], Catie Wiener [ctb], Matt Phelan [ctb], Daniel Sjoberg [ctb], Nuvan Rathnayaka [ctb] |
Maintainer: | Bradley Saul <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7.0 |
Built: | 2024-11-02 04:12:37 UTC |
Source: | https://github.com/bsaul/smd |
Computes the standardized mean differnce (SMD) between two groups.
where is a vector of differences between group 1 and 2 and
is
the covariance matrix of these differences. If
is length 1, the result
is multplied by
.
In the case of a numeric
or integer
variable, this is equivalent
to:
where is the sample mean for group
and
is
the sample variance.
For a logical
or factor
with only two levels, the equation above is
, i.e. the sample proportion and
.
When using the SMD to evaluate the effectiveness of weighting in achieving
covariate balance, it is important to isolate the change in SMD before and
after weighting to the change in mean difference, so the denominator (covariance matrix)
must be held constant (Stuart 2008, doi:10.1002/sim.3207).
By default, the unweighted covariance matrix is used to compute SMD in both
the unweighted and weighted case. If the weights are not being used to adjust
for covariate imbalance (e.g. case weights), the unwgt.var
argument
can be set to FALSE
to use the weighted covariance matrix as the denominator.
smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'character,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'character,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'logical,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'logical,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'matrix,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'matrix,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'list,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'list,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'data.frame,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'data.frame,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE)
smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'character,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'character,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'logical,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'logical,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'matrix,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'matrix,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'list,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'list,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'data.frame,ANY,missing' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE) ## S4 method for signature 'data.frame,ANY,numeric' smd(x, g, w, std.error = FALSE, na.rm = FALSE, gref = 1L, unwgt.var = TRUE)
x |
a |
g |
a vector of at least 2 groups to compare. This should coercable to a
|
w |
a vector of |
std.error |
Logical indicator for computing standard errors using
|
na.rm |
Remove |
gref |
an integer indicating which level of |
unwgt.var |
Use unweighted or weighted covariance matrix. Defaults to |
a data.frame
containing standardized mean differences between
levels of g
for values of x
. The data.frame
contains
the columns:
term
: the level being comparing to the reference level
estimate
: SMD estimates
std.error
: (if std.error = TRUE
) SMD standard error estimates
x <- rnorm(100) g <- rep(1:2, each = 50) smd(x, g)
x <- rnorm(100) g <- rep(1:2, each = 50) smd(x, g)