test_r | R Documentation |
Test the significance, analyze the power, and plan the sample size for r.
test_r(r = NULL, n = NULL, sig_level = 0.05, power = 0.8)
r |
Pearson's correlation. Cohen(1988) suggested >=0.1, >=0.3, and >=0.5 as cut-off values of Pearson's correlation r for small, medium, and large effect sizes, respectively. |
n |
Sample size of r. Non-integer |
sig_level |
Expected significance level. |
power |
Expected statistical power. |
To test the significance of the r using the one-sample t-test,
the SE of r
is determined by the following formula: SE = sqrt((1 - r^2)/(n - 2))
.
Another way is transforming r
to Fisher's z using the following formula:
fz = atanh(r)
with the SE of fz
being sqrt(n - 3)
.
Fisher's z is commonly used to compare two Pearson's correlations from independent samples.
Fisher's transformation is presented here only to satisfy the curiosity of users who are
interested in the difference between t-test and Fisher's transformation.
The post-hoc power of r
's t-test is computed through the way of Aberson (2019).
Other software and R packages like SPSS and pwr
give different power estimates due to
underlying different formulas. Keng
adopts Aberson's approach because this approach guarantees
the equivalence of r and PRE.
A list with the following results:
[[1]]
r
, the given r;
[[2]]
d
, Cohen's d derived from r
; Cohen (1988) suggested >=0.2, >=0.5, and >=0.8
as cut-off values of d
for small, medium, and large effect sizes, respectively.
[[3]]
Integer n
;
[[4]]
t-test of r
(incl., r
, df
of r, SE_r
, t
, p_r
),
95% CI of r
based on t -test (LLCI_r_t
, ULCI_r_t
),
and post-hoc power of r
(incl., delta_post
, power_post
);
[[5]]
Fisher's z transformation (incl., fz
of r
, z-test of fz
[SE_fz
, z
, p_fz
],
and 95% CI of r
derived from fz
.
Note that the returned CI of r
may be out of r's valid range [-1, 1].
This "error" is deliberately left to users, who should correct the CI manually in reports.
Aberson, C. L. (2019). Applied power analysis for the behavioral sciences. Routledge.
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Routledge.
test_r(0.2, 193)
# compare the p-values of t-test and Fisher's transformation
for (i in seq(30, 200, 10)) {
cat(c("n = ", i, ", difference between ps = ",
format(
abs(test_r(0.2, i)[["t_test"]]["p_r"] - test_r(0.2, i)[["Fisher_z"]]["p_fz"]),
nsmall = 12,
scientific = FALSE)),
sep = "",
fill = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.