% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/es_from_2x2.R
\name{es_from_2x2}
\alias{es_from_2x2}
\title{Convert a 2x2 table into several effect size measures}
\usage{
es_from_2x2(
  n_cases_exp,
  n_cases_nexp,
  n_controls_exp,
  n_controls_nexp,
  table_2x2_to_cor = "tetrachoric",
  reverse_2x2
)
}
\arguments{
\item{n_cases_exp}{number of cases/events in the exposed group}

\item{n_cases_nexp}{number of cases/events in the non exposed group}

\item{n_controls_exp}{number of controls/no-event in the exposed group}

\item{n_controls_nexp}{number of controls/no-event in the non exposed group}

\item{table_2x2_to_cor}{formula used to obtain a correlation coefficient from the contingency table (see details).}

\item{reverse_2x2}{a logical value indicating whether the direction of generated effect sizes should be flipped.}
}
\value{
This function estimates and converts between several effect size measures.

\tabular{ll}{
\code{natural effect size measure} \tab OR + RR + NNT + RD\cr
\tab \cr
\code{converted effect size measure} \tab D + G + R + Z \cr
\tab \cr
\code{required input data} \tab See 'Section 7. Contingency (2x2) table or proportions'\cr
\tab https://metaconvert.org/input.html\cr
\tab \cr
}
}
\description{
Convert a 2x2 table into several effect size measures
}
\details{
This function first computes (log) odds ratio (OR), (log) risk ratio (RR) and number needed to treat (NNT)
from the 2x2 table. Note that if a cell is equal to 0, we applied the typical adjustment (add 0.5) to all cells.
This adjustment is used for the OR/RR only; the RD and NNT are obtained from the raw cell counts.
Cohen's d (D), Hedges' g (G) and correlation coefficients (R/Z) are then estimated from the OR.

\strong{To estimate an OR}, the formulas used (Box 6.4.a in the Cochrane Handbook) are:
\deqn{logor = log(\frac{n\_cases\_exp / n\_cases\_nexp}{n\_controls\_exp / n\_controls\_nexp})}
\deqn{logor\_se = \sqrt{\frac{1}{n\_cases\_exp} + \frac{1}{n\_cases\_nexp} + \frac{1}{n\_controls\_exp} + \frac{1}{n\_controls\_nexp}}}

\strong{To estimate an RR}, the formulas used (Box 6.4.a in the Cochrane Handbook) are:
\deqn{logrr = log(\frac{n\_cases\_exp / n\_exp}{n\_cases\_nexp / n\_nexp})}
\deqn{logrr\_se = \sqrt{\frac{1}{n\_cases\_exp} - \frac{1}{n\_exp} + \frac{1}{n\_cases\_nexp} - \frac{1}{n\_nexp}}}

\strong{To estimate a risk difference (RD) and NNT}, the formulas used are (Wen et al., 2005; Altman, 1998):
\deqn{pt = \frac{n\_cases\_exp}{n\_cases\_exp + n\_controls\_exp}}
\deqn{pc = \frac{n\_cases\_nexp}{n\_cases\_nexp + n\_controls\_nexp}}
\deqn{rd = pc - pt}
\deqn{rd\_se = \sqrt{\frac{pt(1-pt)}{n\_exp} + \frac{pc(1-pc)}{n\_nexp}}}
\deqn{nnt = \frac{1}{rd}}
\deqn{nnt\_se = \frac{rd\_se}{rd^2}}
Note that NNT confidence intervals are set to NA when the RD confidence interval crosses zero
(discontinuous CI; Altman, 1998).

\strong{Direction convention.} The risk difference is defined as \eqn{rd = pc - pt}
(control risk minus exposed risk), so a POSITIVE RD means the control group has the
higher risk. This is the OPPOSITE direction to the OR and RR produced from the same
2x2 table, which are exposed-over-non-exposed (an OR/RR \eqn{> 1} means the exposed
group has the higher risk). Consequently, for the same table, a protective exposure
yields \eqn{OR < 1}, \eqn{RR < 1} but \eqn{RD > 0}; keep this in mind when pooling RD
alongside OR/RR, and use \code{reverse_2x2} if you need to align the directions.

\strong{To convert the 2x2 table into a SMD},
the function estimates an OR value from the 2x2 table (formula above)
that is then converted to a SMD
(see formula in \code{\link{es_from_or_se}()}).

\strong{To convert the 2x2 table into a correlation coefficient},
For now, only the tetrachoric correlation is currently proposed
\itemize{
\item \code{table_2x2_to_cor = "tetrachoric"}.
Given the heavy calculations required for this effect size measure,
we relied on the implementation of the formulas of the 'metafor' package. More
information can be retrieved here
(https://wviechtb.github.io/metafor/reference/escalc.html#-b-measures-for-two-dichotomous-variables).
}
}
\examples{
es_from_2x2(n_cases_exp = 467, n_cases_nexp = 22087, n_controls_exp = 261, n_controls_nexp = 8761)
}
\references{
Cooper, H., Hedges, L.V., & Valentine, J.C. (Eds.). (2019). The handbook of research synthesis and meta-analysis. Russell Sage Foundation.

Higgins JPT, Thomas J, Chandler J, Cumpston M, Li T, Page MJ, Welch VA (editors). Cochrane Handbook for Systematic Reviews of Interventions version 6.3 (updated February 2022). Available from www.training.cochrane.org/handbook.

Lipsey, M. W., & Wilson, D. B. (2001). Practical meta-analysis. Sage Publications, Inc.

Sedgwick, P. (2013). What is number needed to treat (NNT)? Bmj, 347.

Altman, D. G. (1998). Confidence intervals for the number needed to treat. BMJ, 317(7168), 1309-1312.

Wen, S., Zhang, L., & Yang, B. (2005). Two approaches to incorporate clinical data uncertainty into number needed to treat. Journal of Clinical Pharmacy and Therapeutics, 30(2), 105-109.
}
