Convert between Chi square ($$\chi^2$$), Cramer's V, phi ($$\phi$$), Cohen's w, normalized Chi ($$\chi$$) and Pearson's C for contingency tables or goodness of fit.

## Usage

chisq_to_phi(
chisq,
n,
nrow = 2,
ncol = 2,
ci = 0.95,
alternative = "greater",
...
)

chisq_to_cohens_w(
chisq,
n,
nrow,
ncol,
ci = 0.95,
alternative = "greater",
...
)

chisq_to_cramers_v(
chisq,
n,
nrow,
ncol,
ci = 0.95,
alternative = "greater",
...
)

chisq_to_normalized(
chisq,
n,
nrow,
ncol,
p,
ci = 0.95,
alternative = "greater",
...
)

chisq_to_pearsons_c(
chisq,
n,
nrow,
ncol,
ci = 0.95,
alternative = "greater",
...
)

phi_to_chisq(phi, n, ...)

## Arguments

chisq

The Chi-squared statistic.

n

Total sample size.

nrow, ncol

The number of rows/columns in the contingency table.

ci

Confidence Interval (CI) level

alternative

a character string specifying the alternative hypothesis; Controls the type of CI returned: "greater" (default) or "less" (one-sided CI), or "two.sided" (default, two-sided CI). Partial matching is allowed (e.g., "g", "l", "two"...). See One-Sided CIs in effectsize_CIs.

Should the effect size be bias-corrected? Defaults to FALSE.

...

Arguments passed to or from other methods.

p

Vector of expected values. See stats::chisq.test().

phi

The Phi statistic.

## Value

A data frame with the effect size(s), and confidence interval(s). See cramers_v().

## Details

These functions use the following formulae:
$$\phi = \sqrt{\chi^2 / n}$$
$$Cramer's V = \phi / \sqrt{min(nrow,ncol)-1}$$
$$Pearson's C = \sqrt{\chi^2 / (\chi^2 + n)}$$
$$\chi_{Normalized} = w \times \sqrt{\frac{q}{1-q}}$$ Where q is the smallest of the expected probabilities.

For adjusted versions of phi and V, see Bergsma, 2013.

## Confidence (Compatibility) Intervals (CIs)

Unless stated otherwise, confidence (compatibility) intervals (CIs) are estimated using the noncentrality parameter method (also called the "pivot method"). This method finds the noncentrality parameter ("ncp") of a noncentral t, F, or $$\chi^2$$ distribution that places the observed t, F, or $$\chi^2$$ test statistic at the desired probability point of the distribution. For example, if the observed t statistic is 2.0, with 50 degrees of freedom, for which cumulative noncentral t distribution is t = 2.0 the .025 quantile (answer: the noncentral t distribution with ncp = .04)? After estimating these confidence bounds on the ncp, they are converted into the effect size metric to obtain a confidence interval for the effect size (Steiger, 2004).

For additional details on estimation and troubleshooting, see effectsize_CIs.

## CIs and Significance Tests

"Confidence intervals on measures of effect size convey all the information in a hypothesis test, and more." (Steiger, 2004). Confidence (compatibility) intervals and p values are complementary summaries of parameter uncertainty given the observed data. A dichotomous hypothesis test could be performed with either a CI or a p value. The 100 (1 - $$\alpha$$)% confidence interval contains all of the parameter values for which p > $$\alpha$$ for the current data and model. For example, a 95% confidence interval contains all of the values for which p > .05.

Note that a confidence interval including 0 does not indicate that the null (no effect) is true. Rather, it suggests that the observed data together with the model and its assumptions combined do not provided clear evidence against a parameter value of 0 (same as with any other value in the interval), with the level of this evidence defined by the chosen $$\alpha$$ level (Rafi & Greenland, 2020; Schweder & Hjort, 2016; Xie & Singh, 2013). To infer no effect, additional judgments about what parameter values are "close enough" to 0 to be negligible are needed ("equivalence testing"; Bauer & Kiesser, 1996).

## References

• Cumming, G., & Finch, S. (2001). A primer on the understanding, use, and calculation of confidence intervals that are based on central and noncentral distributions. Educational and Psychological Measurement, 61(4), 532-574.

• Bergsma, W. (2013). A bias-correction for Cramer's V and Tschuprow's T. Journal of the Korean Statistical Society, 42(3), 323-328.

• Johnston, J. E., Berry, K. J., & Mielke Jr, P. W. (2006). Measures of effect size for chi-squared and likelihood-ratio goodness-of-fit tests. Perceptual and motor skills, 103(2), 412-414.

• Rosenberg, M. S. (2010). A generalized formula for converting chi-square tests to effect sizes for meta-analysis. PloS one, 5(4), e10059.

Other effect size from test statistic: F_to_eta2(), t_to_d()

## Examples

contingency_table <- as.table(rbind(c(762, 327, 468), c(484, 239, 477), c(484, 239, 477)))

# chisq.test(contingency_table)
#>
#>         Pearson's Chi-squared test
#>
#> data:  contingency_table
#> X-squared = 41.234, df = 4, p-value = 2.405e-08

chisq_to_cohens_w(41.234,
n = sum(contingency_table),
nrow = nrow(contingency_table),
ncol = ncol(contingency_table)
)
#> Cohen's w |       95% CI
#> ------------------------
#> 0.10      | [0.07, 1.41]
#>
#> - One-sided CIs: upper bound fixed at [1.41~].

Smoking_ASD <- as.table(c(ASD = 17, ASP = 11, TD = 640))

# chisq.test(Smoking_ASD, p = c(0.015, 0.010, 0.975))
#>
#>   Chi-squared test for given probabilities
#>
#> data:  Smoking_ASD
#> X-squared = 7.8521, df = 2, p-value = 0.01972

chisq_to_normalized(
7.8521,
n = sum(Smoking_ASD),
nrow = 1,
ncol = 3,
p = c(0.015, 0.010, 0.975)
)
#> Norm. Chi |       95% CI
#> ------------------------
#> 0.01      | [0.00, 1.00]
#>
#> - Adjusted for non-uniform expected probabilities.
#> - One-sided CIs: upper bound fixed at [1.00].