Learn R Programming

misty (version 0.3.2)

cohens.d: Cohen's d for Between- and Within-Subject Design

Description

This function computes Cohen's d for between- and within-subject designs with confidence intervals. By default, the function computes the standardized mean difference divided by the weighted pooled standard deviation without applying the correction factor for removing the small sample bias.

Usage

cohens.d(formula, data, paired = FALSE, weighted = TRUE,
         ref = NULL, correct = FALSE, digits = 2,
         conf.level = 0.95, as.na = NULL, check = TRUE,
         output = TRUE)

Arguments

formula

in case of a between-subject design (i.e., paired = FALSE), a formula of the form y ~ group for one outcome variable or cbind(y1, y2, y3) ~ group for more than one outcome variable where y is a numeric variable giving the data values and group a numeric variable, character variable or factor with two values or factor levels giving the corresponding group; in case of a within-subject design (i.e., paired = TRUE), a formula of the form post ~ pre where post and pre are numeric variables. Note that analysis for more than one outcome variable is not permitted in within-subject design.

data

a matrix or data frame containing the variables in the formula.

paired

logical: if TRUE, Cohen's d for within-subject design is computed.

weighted

logical: if TRUE (default), in case of a between-subject design the weighted pooled standard deviation is used; in case of a within-subject design the correlation between measures is controlled when computing the pooled standard deviation.

ref

a numeric value or character string indicating the reference group in a between-subject design or a character string indicating the reference variable in a within-subject design. The standard deviation of the reference group or reference variable is used to standardized the mean difference. If the standard deviation of the control group is used (e.g. group = "control"), the effect size is usually called Glass' delta.

correct

logical: if TRUE, correction factor to remove positive bias in small samples is used. Note that correction factor is only applied when weighted = TRUE and ref = NULL.

digits

an integer value indicating the number of decimal places to be used for displaying results.

conf.level

a numeric value between 0 and 1 indicating the confidence level of the interval.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis. Note that as.na() function is only applied to y but not to group in a between-subject design, while as.na() function is applied to pre and post in a within-subject design.

check

logical: if TRUE, argument specification is checked.

output

logical: if TRUE, output is shown on the console.

Value

Returns an object of class misty.object, which is a list with following entries: function call (call), type of analysis type, matrix or data frame specified in x (data), specification of function arguments (args), and list with results (result).

Details

Cohen (1988, p.67) proposed to compute the standardized mean difference by dividing the mean difference by the unweighted pooled standard deviation (i.e., weighted = FALSE).

Glass et al. (1981, p. 29) suggested to use the standard deviation of the control group (e.g., ref = "control") to compute the standardized mean difference since the standard deviation of the control group is unaffected by the treatment and will therefore more closely reflect the population standard deviation.

Hedges (1981, p. 110) recommended to weight each group's standard deviation by its sample size resulting in a weighted and pooled standard deviation (i.e., weighted = TRUE). According to Hedges and Olkin (1985, p. 81), the standardized mean difference based on the weighted and pooled standard deviation has a positive small sample bias, i.e., standardized mean difference is overestimates in small samples (i.e., sample size less than 20 or less than 10 in each group). However, a correction factor can be applied to remove the small sample bias (i.e., correct = TRUE). Note that a gamma function is used for computing the correction factor when \(n\) < 200, while a approximation method is used when \(n\) >= 200.

Note that the terminology is inconsistent because the standardized mean difference based on the weighted and pooled standard deviation is usually called Cohen's d, but sometimes called Hedges' g. Oftentimes, Cohen's d is called Hedges' d as soon as the correction factor is applied. It is recommended to avoid the term Hedges' g (Cumming & Calin-Jageman, 2017, p. 171), but to report which standard deviation was used to standardized the mean difference (e.g., unweighted/weighted pooled standard deviation, or the standard deviation of the control group) and whether a small sample correction factor was applied.

As for the terminology according to Lakens (2013), in between subject design (paired = FALSE) Cohen's \(d_s\) is computed when using weighted = TRUE and Hedges's \(g_s\) is computed when using correct = TRUE in addition. In within-subject designs (paired = TRUE), Cohen's \(d_rm\) is computed when using weighted = TRUE, while Cohen's \(d_av\) is computed when using weighted = FALSE, and corresponding Hedges' \(g_rm\) and Hedges' \(g_av\) are computed when using correct = TRUE.

References

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Academic Press.

Cumming, G., & Calin-Jageman, R. (2017). Introduction to the new statistics: Estimation, open science, & beyond. Routledge.

Glass. G. V., McGaw, B., & Smith, M. L. (1981). Meta-analysis in social research. Sage Publication.

Goulet-Pelletier, J.-C., & Cousineau, D. (2018) A review of effect sizes and their confidence intervals, Part I: The Cohen's d family. The Quantitative Methods for Psychology, 14, 242-265. https://doi.org/10.20982/tqmp.14.4.p242

Hedges, L. V. (1981). Distribution theory for Glass's estimator of effect size and related estimators. Journal of Educational Statistics, 6(3), 106-128.

Hedges, L. V. & Olkin, I. (1985). Statistical methods for meta-analysis. Academic Press.

Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: A practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4, 1-12. https://doi.org/10.3389/fpsyg.2013.00863

See Also

eta.sq, cont.coef, cramers.v,cor.matrix, na.auxiliary

Examples

Run this code
# NOT RUN {
#--------------------------------------
# Between-Subject Design
dat.bs <- data.frame(group = c("cont", "cont", "cont", "treat", "treat"),
                     y1 = c(1, 3, 2, 5, 7),
                     y2 = c(4, 3, 3, 6, 4),
                     y3 = c(7, 5, 7, 3, 2), stringsAsFactors = FALSE)

# Standardized mean difference divided by the weighted pooled
# standard deviation without small sample correction factor
cohens.d(y1 ~ group, data = dat.bs)

# Standardized mean difference divided by the unweighted pooled
# standard deviation without small sample correction factor
cohens.d(y1 ~ group, data = dat.bs, weighted = FALSE)

# Standardized mean difference divided by the weighted pooled
# standard deviation with small sample correction factor
cohens.d(y1 ~ group, data = dat.bs, correct = TRUE)

# Standardized mean difference divided by the standard deviation
# of the control group without small sample correction factor
cohens.d(y1 ~ group, data = dat.bs, ref = "cont")

# Cohens's d for for more than one outcome variable
cohens.d(cbind(y1, y2, y3) ~ group, data = dat.bs)

#--------------------------------------
# Within-Subject Design
dat.ws <- data.frame(pre = c(1, 3, 2, 5, 7),
                     post = c(2, 2, 1, 6, 8))

# Standardized mean difference divided by the pooled
# standard deviation while controlling for the correlation
# without small sample correction factor
cohens.d(post ~ pre, data = dat.ws, paired = TRUE)

# Standardized mean difference divided by the pooled
# standard deviation whithout controlling for the correlation
# without small sample correction factor
cohens.d(post ~ pre, data = dat.ws, paired = TRUE, weighted = FALSE)

# Standardized mean difference divided by the pooled
# standard deviation while controlling for the correlation
# with small sample correction factor
cohens.d(post ~ pre, data = dat.ws, paired = TRUE, correct = TRUE)

# Standardized mean difference divided by the standard deviation
# of the pretest without small sample correction factor
cohens.d(post ~ pre, data = dat.ws, paired = TRUE, ref = "pre")
# }

Run the code above in your browser using DataLab