There was a post here about obtaining non-standard p-values for testing the correlation coefficient. The R-library

SuppDists
deals with this problem efficiently.

library(SuppDists)
plot(function(x)dPearson(x,N=23,rho=0.7),-1,1,ylim=c(0,10),ylab="density")
plot(function(x)dPearson(x,N=23,rho=0),-1,1,add=TRUE,col="steelblue")
plot(function(x)dPearson(x,N=23,rho=-.2),-1,1,add=TRUE,col="green")
plot(function(x)dPearson(x,N=23,rho=.9),-1,1,add=TRUE,col="red");grid()
legend("topleft", col=c("black","steelblue","red","green"),lty=1,
legend=c("rho=0.7","rho=0","rho=-.2","rho=.9"))
This is how it looks like,
Now, let’s construct a table of critical values for some arbitrary or not significance levels.

q=c(.025,.05,.075,.1,.15,.2)
xtabs(qPearson(p=q, N=23, rho = 0, lower.tail = FALSE, log.p = FALSE) ~ q )
# q
# 0.025 0.05 0.075 0.1 0.15 0.2
# 0.4130710 0.3514298 0.3099236 0.2773518 0.2258566 0.1842217
We can calculate p-values as usual too…

1-pPearson(.41307,N=23,rho=0)
# [1] 0.0250003

Related

To

leave a comment for the author, please follow the link and comment on their blog:

Stats raving mad » R .

R-bloggers.com offers

daily e-mail updates about

R news and

tutorials on topics such as:

Data science ,

Big Data, R jobs , visualization (

ggplot2 ,

Boxplots ,

maps ,

animation ), programming (

RStudio ,

Sweave ,

LaTeX ,

SQL ,

Eclipse ,

git ,

hadoop ,

Web Scraping ) statistics (

regression ,

PCA ,

time series ,

trading ) and more...

If you got this far, why not

subscribe for updates from the site? Choose your flavor:

e-mail ,

twitter ,

RSS , or

facebook ...

Tags: code , distribution , hypothesis , P-value , pearson , R , statistics , test