Title: | Transforms Statistical Measures Commonly Used for Meta-Analysis |
---|---|
Description: | Helps calculate statistical values commonly used in meta-analysis. It provides several methods to compute different forms of standardized mean differences, as well as other values such as standard errors and standard deviations. The methods used in this package are described in the following references: Altman D G, Bland J M. (2011) <doi:10.1136/bmj.d2090> Borenstein, M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009) <doi:10.1002/9780470743386.ch4> Chinn S. (2000) <doi:10.1002/1097-0258(20001130)19:22%3C3127::aid-sim784%3E3.0.co;2-m> Cochrane Handbook (2011) <https://handbook-5-1.cochrane.org/front_page.htm> Cooper, H., Hedges, L. V., & Valentine, J. C. (2009) <https://psycnet.apa.org/record/2009-05060-000> Cohen, J. (1977) <https://psycnet.apa.org/record/1987-98267-000> Ellis, P.D. (2009) <https://www.psychometrica.de/effect_size.html> Goulet-Pelletier, J.-C., & Cousineau, D. (2018) <doi:10.20982/tqmp.14.4.p242> Hedges, L. V. (1981) <doi:10.2307/1164588> Hedges L. V., Olkin I. (1985) <doi:10.1016/C2009-0-03396-0> Murad M H, Wang Z, Zhu Y, Saadi S, Chu H, Lin L et al. (2023) <doi:10.1136/bmj-2022-073141> Mayer M (2023) <https://search.r-project.org/CRAN/refmans/confintr/html/ci_proportion.html> Stackoverflow (2014) <https://stats.stackexchange.com/questions/82720/confidence-interval-around-binomial-estimate-of-0-or-1> Stackoverflow (2018) <https://stats.stackexchange.com/q/338043>. |
Authors: | Robert Emprechtinger [aut, cre]
|
Maintainer: | Robert Emprechtinger <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2025-02-25 02:59:35 UTC |
Source: | https://github.com/robertemprechtinger/metahelper |
Calculates the Absolute Risk Difference (ARD) from a Risk Ratio and baseline risk using simulations. The result is ARD as a decimal. The number of replications is fixed at 100,000.
ARD_from_RR(BR, BRLL, BRUL, RR, RRLL, RRUL, seed = 1)
ARD_from_RR(BR, BRLL, BRUL, RR, RRLL, RRUL, seed = 1)
BR |
baseline risk |
BRLL |
baseline risk lower limit confidence interval |
BRUL |
baseline risk upper limit confidence interval |
RR |
risk ratio |
RRLL |
risk ratio lower limit confidence interval |
RRUL |
risk ratio upper limit confidence interval |
seed |
seed that is used for the simulation to ensure reproducibility |
Named numeric vector containing median ARD, the lower and upper CI of the ARD.
Murad M H, Wang Z, Zhu Y, Saadi S, Chu H, Lin L et al. Methods for deriving risk difference (absolute risk reduction) from a meta-analysis BMJ 2023; 381 :e073141 doi:10.1136/bmj-2022-073141
# Input : Baseline risk and 95% CI (BR BRLL and BRUL), risk ratio and 95% CI (RR, RRLL, RRUL) BR <- 0.053; BRLL <- 0.039; BRUL <- 0.072 RR <- 0.77; RRLL <- 0.63; RRUL <- 0.94 ARD_from_RR(BR, BRLL, BRUL, RR, RRLL, RRUL)
# Input : Baseline risk and 95% CI (BR BRLL and BRUL), risk ratio and 95% CI (RR, RRLL, RRUL) BR <- 0.053; BRLL <- 0.039; BRUL <- 0.072 RR <- 0.77; RRLL <- 0.63; RRUL <- 0.94 ARD_from_RR(BR, BRLL, BRUL, RR, RRLL, RRUL)
Calculates a confidence interval for proportions. For a discussion on the differences between methods to calculate confidence intervals, see the Stack Overflow discussion under References. This method uses the R package "confintr" to calculate the confidence intervals.
CI_from_proportions(events, n, method = "Clopper-Pearson")
CI_from_proportions(events, n, method = "Clopper-Pearson")
events |
number of events |
n |
sample size |
method |
the method ("Clopper-Pearson", "Agresti-Coull", "Wilson") that should be used to calculate the confidence intervals. |
List of confidence interval of proportions if input length > 1. If input length = 1 Lower CI and Upper CI.
Confintr Function Description Stackoverflow Method Discussion
# CI for 9 events in a sample of 10 CI_from_proportions(9, 10)
# CI for 9 events in a sample of 10 CI_from_proportions(9, 10)
Computes the standard deviation from the confidence interval and sample size. This method is valid only for single groups and assumes the confidence interval is symmetrical around the mean. For two groups (e.g., intervention effects), use SDp_from_CIp()
. For sample sizes smaller than 60, the t-distribution (parameter "t-dist") is typically used to calculate the confidence interval.
SD_from_CI(CI_low, CI_up, n, sig_level = 0.05, two_sided = TRUE, t_dist = TRUE)
SD_from_CI(CI_low, CI_up, n, sig_level = 0.05, two_sided = TRUE, t_dist = TRUE)
CI_low |
lower limit confidence interval |
CI_up |
upper limit confidence interval |
n |
sample size |
sig_level |
significance level |
two_sided |
whether a two sided test for significance was used |
t_dist |
whether a t-distribution has been used to calculate the CI. See description. |
Standard deviation single group
SDp_from_CIp()
for two groups (e.g. intervention effects).
# lower CI = -0.5, upper CI = 2, sample size = 100 SD_from_CI(-05, 2, 100)
# lower CI = -0.5, upper CI = 2, sample size = 100 SD_from_CI(-05, 2, 100)
IMPORTANT: When there are two groups, use the method for calculating the pooled standard error provided by the function SDp_from_SEp()
!
Calculates the standard deviation from the standard error for a single group.
SD_from_SE(SE, n)
SD_from_SE(SE, n)
SE |
standard error |
n |
sample size |
Single group standard deviation
SDp_from_SEp()
in case of two groups.
# Standard error = 2 and sample size = 100 SE <- 2 n <- 100 SD_from_SE(SE, n)
# Standard error = 2 and sample size = 100 SE <- 2 n <- 100 SD_from_SE(SE, n)
Computes the pooled standard deviation for multiple groups.
SD_M_n_pooled_from_groups(M, SD, n)
SD_M_n_pooled_from_groups(M, SD, n)
M |
vector of group means |
SD |
vector of group SDs |
n |
vector of group sample sizes |
This function also returns the combined mean and the total sample size across all groups.
Requires also the mean for all individual groups. If there are only two groups and the mean is not available SDp_from_SD()
can be used instead.
Within standard deviation
Rücker G, Cates CJ, Schwarzer G. Methods for including information from multi-arm trials in pairwise meta-analysis. Res Synth Methods. 2017 Dec;8(4):392-403. doi: 10.1002/jrsm.1259. Epub 2017 Aug 25. PMID: 28759708.
# Compute the Standard deviation for the following grouped data M <- c(1, 1.5, 2) # Means SD <- c(2, 3, 2.5) # SDs n <- c(72, 80, 55) # sample sizes SD_M_n_pooled_from_groups(M, SD, n)
# Compute the Standard deviation for the following grouped data M <- c(1, 1.5, 2) # Means SD <- c(2, 3, 2.5) # SDs n <- c(72, 80, 55) # sample sizes SD_M_n_pooled_from_groups(M, SD, n)
Computes the within-group standard deviation for matched groups. This within-group standard deviation can be used to calculate standardized mean differences for matched groups. This method requires a correlation coefficient r.
SD_within_from_SD_r(SD_diff, r)
SD_within_from_SD_r(SD_diff, r)
SD_diff |
standard deviation of the difference |
r |
correlation between pair of observations |
Within standard deviation
Borenstein, M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009). Effect Sizes Based on Means . In Introduction to Meta-Analysis (eds M. Borenstein, L.V. Hedges, J.P.T. Higgins and H.R. Rothstein). https://doi.org/10.1002/9780470743386.ch4
# SD_diff is the standard deviation of the group difference SD_diff <- 2 # r is the correlation coefficient between the groups r <- 0.5 SD_within_from_SD_r(SD_diff, r)
# SD_diff is the standard deviation of the group difference SD_diff <- 2 # r is the correlation coefficient between the groups r <- 0.5 SD_within_from_SD_r(SD_diff, r)
Computes the pooled standard deviation (e.g., standard deviation of an intervention effect) from confidence intervals and sample sizes. According to the Cochrane Handbook (see references), this standard deviation is referred to as the "within-group standard deviation." This method is valid only if the confidence interval is symmetrical around the mean and if either the t-distribution or normal distribution (when "t_dist = FALSE") was used to calculate the confidence interval.
SDp_from_CIp( CI_low, CI_up, n1, n2, sig_level = 0.05, two_sided = TRUE, t_dist = TRUE )
SDp_from_CIp( CI_low, CI_up, n1, n2, sig_level = 0.05, two_sided = TRUE, t_dist = TRUE )
CI_low |
lower limit confidence interval |
CI_up |
upper limit confidence interval |
n1 |
sample size group 1 |
n2 |
sample size group 2 |
sig_level |
significance level |
two_sided |
whether a two sided test for significance was used |
t_dist |
whether a t distribution has been used to calculate the CI |
Pooled standard deviation
SD_from_CI()
for single group standard deviation.
#lower CI = 0.5, upper CI = 0.7, N1 = 50, N2 = 70 SDp_from_CIp(0.5, 0.7, 50, 70)
#lower CI = 0.5, upper CI = 0.7, N1 = 50, N2 = 70 SDp_from_CIp(0.5, 0.7, 50, 70)
Calculates the pooled standard deviation.
SDp_from_SD(SD1, SD2, n1 = NA, n2 = NA, method = "hedges")
SDp_from_SD(SD1, SD2, n1 = NA, n2 = NA, method = "hedges")
SD1 |
standard deviation of group 1 |
SD2 |
standard deviation of group 2 |
n1 |
sample size of group 1 |
n2 |
sample size of group 2 |
method |
the method ("hedges", "cohen") that should be used to calculate the SD. Method "hedges" requires sample sizes. The "cohen" method uses a simplified method by and does not rely on sample sizes. |
The method according to Hedges requires the sample sizes. If only standard deviations are available, the simpler equation provided by Cohen (1988) can be used. If there are more than two groups, SD_M_n_pooled_from_groups()
should be used.
Note: The use of the names "Cohen" and "Hedges" for the methods can be inconsistent in the literature. It is somewhat unusual because Cohen (1977) outlined both estimators for the pooled standard deviation before Hedges (1981) discussed them.
Pooled standard deviation
Borenstein, M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009). Converting Among Effect Sizes. In Introduction to Meta-Analysis (eds M. Borenstein, L.V. Hedges, J.P.T. Higgins and H.R. Rothstein). https://doi.org/10.1002/9780470743386.ch7
Cohen, J. (1977). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale, NJ, US: Lawrence Erlbaum Associates, Inc.
Ellis, P.D. (2009), "Effect size equations". Link
Hedges, L. V. (1981). Distribution theory for Glass's estimator of effect size and related estimators. Journal of Educational Statistics, 6, 107-128.
Difference between Cohen's d and Hedges' g for effect size metrics. Stackoverflow. Link
SD_within_from_SD_r()
for matched groups
# Standard deviation according to Cohen: SDp_from_SD(2, 3, method = "cohen") # Standard deviation according to Hedges needs sample sizes: SDp_from_SD(2, 3, 50, 50)
# Standard deviation according to Cohen: SDp_from_SD(2, 3, method = "cohen") # Standard deviation according to Hedges needs sample sizes: SDp_from_SD(2, 3, 50, 50)
IMPORTANT: For a single group, use SD_from_SE()
!
Calculates the standard deviation from the pooled standard error and sample sizes of two groups (e.g., for intervention effects). This method is the reverse of SEp_from_SDp()
.
SDp_from_SEp(SEp, n1, n2)
SDp_from_SEp(SEp, n1, n2)
SEp |
pooled standard error |
n1 |
sample size group 1 |
n2 |
sample size group 2 |
Pooled standard deviation
SD_from_SE()
for a single group.
SEp_from_SDp()
if the standard error should be computed instead.
#pooled standard error, sample size 1 and sample size 2 SE <- 0.12 n1 <- 140 n2 <- 140 SDp_from_SEp(SE, n1, n2)
#pooled standard error, sample size 1 and sample size 2 SE <- 0.12 n1 <- 140 n2 <- 140 SDp_from_SEp(SE, n1, n2)
IMPORTANT: For cases involving two groups (e.g., intervention effects), use SEp_from_SDp()
instead.#'
Calculates the standard error for a single group. This method is only valid for single groups
SE_from_SD(SD, n)
SE_from_SD(SD, n)
SD |
standard deviation |
n |
sample size |
Single group standard error
SEp_from_SDp()
for two groups
# Standard deviation = 2, group size = 50 SE_from_SD(2, 50)
# Standard deviation = 2, group size = 50 SE_from_SD(2, 50)
Calculates the standard error from an odds ratio confidence interval.
SE.SMD_from_OR.CI(CI_low, CI_up, sig_level = 0.05, two_tailed = TRUE)
SE.SMD_from_OR.CI(CI_low, CI_up, sig_level = 0.05, two_tailed = TRUE)
CI_low |
lower odds ratio confidence interval limit |
CI_up |
upper odds ratio confidence interval limit |
sig_level |
the significance level |
two_tailed |
whether the two-tailed or one-tailed z statistics should be calculated |
This method uses multiple steps in the background: 1 Takes odds ratio (OR) limits and transforms them to log(OR) 2 Calculates the standard error for the log(OR) 3 Transforms the log(OR) standard error to standardized mean differences (SMD) standard error by multiplying it with sqrt(3)/pi
Standard Error
Chinn S. A simple method for converting an odds ratio to effect size for use in meta-analysis. Stat Med. 2000 Nov 30;19(22):3127-31. doi: 10.1002/1097-0258(20001130)
# lower CI = 0.6, upper CI = 0.9 SE.SMD_from_OR.CI(0.6, 0.9)
# lower CI = 0.6, upper CI = 0.9 SE.SMD_from_OR.CI(0.6, 0.9)
Approximates SMD standard error from sample sizes and SMD.
SE.SMD_from_SMD(SMD, n1, n2, method = "hedges")
SE.SMD_from_SMD(SMD, n1, n2, method = "hedges")
SMD |
standardized mean differences |
n1 |
sample size group 1 |
n2 |
sample size group 2 |
method |
transformation method ("hedges", "cohen") |
Standard error of SMD (e.g. standard error of intervention effect)
Cooper, H., Hedges, L. V., & Valentine, J. C. (Eds.). (2009). Link
# SMD = 0.6, sample size group_1 = 50, sample size group_2 = 75 SE.SMD_from_SMD(0.6, 50, 75)
# SMD = 0.6, sample size group_1 = 50, sample size group_2 = 75 SE.SMD_from_SMD(0.6, 50, 75)
Calculates the standard error from the confidence interval limits for differences of means (and can also be used for the confidence intervals of standardized mean differences, SMD).
This method is valid only when the confidence interval is symmetrical around the mean and is applicable for t-distributions or normal distributions (as specified by the t_dist
argument).
For sample sizes less than 60, it is generally recommended to use the t-distribution.
SEp_from_CIp( CI_low, CI_up, n1 = NA, n2 = NA, sig_level = 0.05, two_tailed = TRUE, t_dist = TRUE )
SEp_from_CIp( CI_low, CI_up, n1 = NA, n2 = NA, sig_level = 0.05, two_tailed = TRUE, t_dist = TRUE )
CI_low |
lover OR confidence interval limit |
CI_up |
upper OR confidence interval limit |
n1 |
sample size group 1 (not required if t_dist = FALSE) |
n2 |
sample size group 2 (not required if t_dist = FALSE) |
sig_level |
the significance level |
two_tailed |
whether the two-tailed or one-tailed statistics should be calculated |
t_dist |
whether the t-distribution should be calculated - requires samples sizes |
Pooled standard error (e.g. intervention effect)
# lower CI = -1.5, upper CI = 0.5 SEp_from_CIp(-1.5, 0.5)
# lower CI = -1.5, upper CI = 0.5 SEp_from_CIp(-1.5, 0.5)
IMPORTANT: When there is only one group, the following method has to be used: SE_from_SD()
Calculates the pooled standard error for two groups (e.g., intervention effect).
SEp_from_SDp(SDp, n1, n2)
SEp_from_SDp(SDp, n1, n2)
SDp |
pooled standard deviation |
n1 |
sample size group 1 |
n2 |
sample size group 2 |
Pooled standard error for two groups (e.g. standard error of intervention effect)
SE_from_SD()
for a single group
# Pooled standard deviation = 2, sample size group a = 50, sample size group b = 75 SEp_from_SDp(2, 50, 75)
# Pooled standard deviation = 2, sample size group a = 50, sample size group b = 75 SEp_from_SDp(2, 50, 75)
Calculates the pooled standard error using the treatment effect and p-value. To avoid an infinitive return when p-value = 1, the p-value is automatically adjusted to 0.99999
SEp_from_TE.p(TE, p, two_tailed = TRUE)
SEp_from_TE.p(TE, p, two_tailed = TRUE)
TE |
reported treatment effect |
p |
reported p-value |
two_tailed |
whether one-tailed or two-tailed statistics should be calculated |
Pooled standard error (e.g. standard error of intervention effect)
Altman D G, Bland J M. How to obtain the confidence interval from a P value BMJ 2011; 343 :d2090 doi:10.1136/bmj.d2090 Cochrane Handbook
# TE = 1.5, p = 0.8 SEp_from_TE.p(1.5, 0.8)
# TE = 1.5, p = 0.8 SEp_from_TE.p(1.5, 0.8)
Calculates SMD directly from group data. Method "hedges" needs sample size data and returns Hedges' g. Method "cohen" returns Cohen's d.
SMD_from_group(M1, M2, SD1, SD2, n1 = NA, n2 = NA, method = "hedges")
SMD_from_group(M1, M2, SD1, SD2, n1 = NA, n2 = NA, method = "hedges")
M1 |
treatment effect size group 1 |
M2 |
treatment effect size group 2 |
SD1 |
standard deviation group 1 |
SD2 |
standard deviation group 2 |
n1 |
sample size group 1 |
n2 |
sample size group 2 |
method |
calculation method ("hedges", "cohen") |
Standardized Mean Differences
Borenstein, M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009). Converting Among Effect Sizes. In Introduction to Meta-Analysis (eds M. Borenstein, L.V. Hedges, J.P.T. Higgins and H.R. Rothstein). https://doi.org/10.1002/9780470743386.ch7
Hedges L. V., Olkin I. (1985). Statistical methods for meta-analysis. San Diego, CA: Academic Press
Goulet-Pelletier, J.-C., & Cousineau, D. (2018). A review of effect sizes and their confidence intervals, Part 1: The Cohen’s d family. The Quantitative Methods for Psychology, 14(4), 242–265. https://doi.org/10.20982/tqmp.14.4.p242
# Mean control = 23, Mean intervention = 56, SD control = 30, # SD intervention = 35, sample size control = 45, sample size intervention = 60 SMD_from_group(23, 56, 30, 35, 45, 60)
# Mean control = 23, Mean intervention = 56, SD control = 30, # SD intervention = 35, sample size control = 45, sample size intervention = 60 SMD_from_group(23, 56, 30, 35, 45, 60)
Calculates the SMD. It needs to be provided with the pooled standard deviation. If the pooled standard deviation is not available SMD_from_group()
provides a direct method to calculate the SMD and also offers different forms like Hedges' g or Cohen's d.
SMD_from_mean(M1, M2, SD_pooled)
SMD_from_mean(M1, M2, SD_pooled)
M1 |
treatment effect size group 1 |
M2 |
treatment effect size group 2 |
SD_pooled |
the pooled standard deviation or the standard deviation of the control group in case Glass's delta should be calculated |
CAVE: If you want to get Hedges' g it is insufficient to simply pool the standard deviation with SDp_from_SD()
. The resulting SMD needs to be further multiplied with the hedges factor. This is done automatically when you use SMD_from_group()
.
Standardized Mean Differences
https://handbook-5-1.cochrane.org/chapter_9/9_2_3_2_the_standardized_mean_difference.htm
# Mean control = 153, Mean intervention = 136, pooled SD = 25 SMD_from_mean(153, 136, 25)
# Mean control = 153, Mean intervention = 136, pooled SD = 25 SMD_from_mean(153, 136, 25)
Calculates the standardized mean differences for matched groups. Needs either the mean of the groups or the difference between groups.
SD_within is usually not reported but can be calculated by the use of SD_within_from_SD_r()
.
SMD_from_mean_matched(M_diff = NA, M1 = NA, M2 = NA, SD_within)
SMD_from_mean_matched(M_diff = NA, M1 = NA, M2 = NA, SD_within)
M_diff |
mean difference between groups |
M1 |
mean group 1 (in case M_diff not provided) |
M2 |
mean group 2 (in case M_diff not provided) |
SD_within |
within standard deviation. CAVE this is usually not reported but needs to be computed from the difference standard deviation.
This can be done with |
Standardized Mean Differences
M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009). Converting Among Effect Sizes. In Introduction to Meta-Analysis (eds M. Borenstein, L.V. Hedges, J.P.T. Higgins and H.R. Rothstein). https://doi.org/10.1002/9780470743386.ch7
# Calcuation with group means SMD_from_mean_matched(M1 = 103, M2 = 100, SD_within = 7.1005) # Calculation with group difference SMD_from_mean_matched(M_diff = 3, SD_within = 7.1005) # Calculation with standard deviation between # Correlation Coefficient between groups r <- 0.7 # SD between groups SD_between <- 5.5 SMD_from_mean_matched(M_diff = 3, SD_within = SD_within_from_SD_r(SD_between, r))
# Calcuation with group means SMD_from_mean_matched(M1 = 103, M2 = 100, SD_within = 7.1005) # Calculation with group difference SMD_from_mean_matched(M_diff = 3, SD_within = 7.1005) # Calculation with standard deviation between # Correlation Coefficient between groups r <- 0.7 # SD between groups SD_between <- 5.5 SMD_from_mean_matched(M_diff = 3, SD_within = SD_within_from_SD_r(SD_between, r))
Approximates SMD from OR.
SMD_from_OR(OR)
SMD_from_OR(OR)
OR |
odds ratio |
Standardized Mean Difference
Borenstein, M., Hedges, L.V., Higgins, J.P.T. and Rothstein, H.R. (2009). Converting Among Effect Sizes. In Introduction to Meta-Analysis (eds M. Borenstein, L.V. Hedges, J.P.T. Higgins and H.R. Rothstein). https://doi.org/10.1002/9780470743386.ch7
# Transform an OR of 0.3 to SMD SMD_from_OR(0.3)
# Transform an OR of 0.3 to SMD SMD_from_OR(0.3)