Learn R Programming

JWileymisc (version 1.4.1)

smd: Calculate Standardized Mean Difference (SMD)

Description

Simple function to calculate effect sizes for mean differences.

Usage

smd(x, g, index = c("all", "1", "2"))

Value

The standardized mean difference.

Arguments

x

A continuous variable

g

A grouping variable, with two levels

index

A character string: “all” uses pooled variance, “1” uses the first factor level variance, “2” uses the second factor level variance.

Examples

Run this code
smd(mtcars$mpg, mtcars$am)
smd(mtcars$mpg, mtcars$am, "all")
smd(mtcars$mpg, mtcars$am, "1")
smd(mtcars$mpg, mtcars$am, "2")

smd(mtcars$hp, mtcars$vs)

d <- data.table::as.data.table(mtcars)
d[, smd(mpg, vs)]
rm(d)

Run the code above in your browser using DataLab