sd_pooled function

Pooled Indices of (Co)Deviation

Pooled Indices of (Co)Deviation

The Pooled Standard Deviation is a weighted average of standard deviations for two or more groups, assumed to have equal variance. It represents the common deviation among the groups, around each of their respective means.

sd_pooled(x, y = NULL, data = NULL, verbose = TRUE, ...) mad_pooled(x, y = NULL, data = NULL, constant = 1.4826, verbose = TRUE, ...) cov_pooled(x, y = NULL, data = NULL, verbose = TRUE, ...)

Arguments

  • x, y: A numeric vector, or a character name of one in data. Any missing values (NAs) are dropped from the resulting vector. x can also be a formula (see stats::t.test()), in which case y is ignored.
  • data: An optional data frame containing the variables.
  • verbose: Toggle warnings and messages on or off.
  • ...: Arguments passed to or from other methods. When x is a formula, these can be subset and na.action.
  • constant: scale factor.

Returns

Numeric, the pooled standard deviation. For cov_pooled() a matrix.

Details

The standard version is calculated as:

(xixˉ)2n1+n22sqrt(sum(c(xmean(x),ymean(y))2)/(n1+n22)) \sqrt{\frac{\sum (x_i - \bar{x})^2}{n_1 + n_2 - 2}}sqrt(sum(c(x - mean(x), y - mean(y))^2) / (n1 + n2 - 2))

The robust version is calculated as:

1.4826×Median({xMedianx,yMediany})mad(c(xmedian(x),ymedian(y)),constant=1.4826) 1.4826 \times Median(|\left\{x - Median_x,\,y - Median_y\right\}|)mad(c(x - median(x), y - median(y)), constant = 1.4826)

Examples

sd_pooled(mpg ~ am, data = mtcars) mad_pooled(mtcars$mpg, factor(mtcars$am)) cov_pooled(mpg + hp + cyl ~ am, data = mtcars)

See Also

cohens_d(), mahalanobis_d()

  • Maintainer: Mattan S. Ben-Shachar
  • License: MIT + file LICENSE
  • Last published: 2024-12-10