p_r | R Documentation |
Generates correlated X-Y data and returns a p-value to assess the null of no correlation in the population. The X-Y data are generated assuming a bivariate normal distribution.
p_r(n, r, rho = 0, method = "pearson", two.tailed = TRUE, gen_fun = gen_r, ...)
gen_r(n, r, ...)
n |
sample size |
r |
correlation |
rho |
population coefficient to test against. Uses the Fisher's z-transformation approximation when non-zero |
method |
method to use to compute the correlation
(see |
two.tailed |
logical; should a two-tailed or one-tailed test be used? |
gen_fun |
function used to generate the required dependent bivariate data.
Object returned must be a |
... |
additional arguments to be passed to |
a single p-value
Phil Chalmers rphilip.chalmers@gmail.com
gen_r
# 50 observations, .5 correlation
p_r(50, r=.5)
p_r(50, r=.5, method = 'spearman')
# test against constant other than rho = .6
p_r(50, .5, rho=.60)
# compare simulated results to pwr package
pwr::pwr.r.test(r=0.3, n=50)
p_r(n=50, r=0.3) |> Spower()
pwr::pwr.r.test(r=0.3, power=0.80)
p_r(n=NA, r=0.3) |> Spower(power=.80, interval=c(10, 200))
pwr::pwr.r.test(r=0.1, power=0.80)
p_r(n=NA, r=0.1) |> Spower(power=.80, interval=c(200, 1000))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.