Use R to to test hypothesis of correlation = .5

I am trying to make a hypothesis test for my correlation H0: r= .5, H1: R != .5. R works fine for testing the hypothesis H0: r= 0. I looked online to see if any parameter in "cor.test" allowed me to change the hypothesis test but it is not available.

cor.test(x, y, alternative = c("two.sided", "less", "greater"), method = c("pearson", "kendall", "spearman"), exact = NULL, conf.level = 0.95, continuity = FALSE, ...)

Here is my code

> avgTemp
 [1] 21 24 32 47 50 59 68 74 62 50 41 30
> usage
 [1] 185.79 214.47 288.03 424.84 454.68 539.03 621.55 675.06 562.03 452.93
[11] 369.95 273.98
> cor.test (avgTemp,usage)

        Pearson's product-moment correlation

data:  avgTemp and usage
t = 272.255, df = 10, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.9997509 0.9999817
sample estimates:
      cor 
0.9999326 

Again, everything is working fine. I just don't know how to make my hypothesis test H0: r=.5

Thanks !


Seeing if the null value is inside the confidence interval is equivalent to a test of hypothesis (sometimes with a little different assumptions). Since 0.5 is clearly outside of the confidence interval shown above that is equivalent to rejecting the null hypothesis that the true correlation is 0.5 at a 2-sided alpha level of 0.05.

Another option (which gives you more control of the assumptions) is to simulate a large number of datasets that have the same general properties as your original data (means, standard deviations) and the null value for the correlation (see the mvrnorm function in the MASS package), then compute the correlation for each of the simulated datasets. Compare the correlation from your data to the simulated correlations, your p-value is the proportion of simulated correlations that are more extreme than the observed one.

链接地址: http://www.djcxy.com/p/57752.html

上一篇: r统计假设如何检验

下一篇: 用R来检验相关性假设= 0.5