简体   繁体   English

R矩阵相关p值

[英]R matrix correlation p value

We are measuring the groundwater-level at five different spots in an area.我们正在测量一个地区五个不同地点的地下水位。

Null hypothesis : the trend/progression of the groundwater-level of each spot is NOT different零假设:每个点的地下水位的趋势/进展没有不同

Alternative hypothese : the trend/progression of the groundwater-level of each spot is different替代假设:每个点的地下水位的趋势/进展是不同的

We want to proove this statistically.我们想在统计上证明这一点。

Below you can see part of the measurement data:下面你可以看到部分测量数据:

 > head(mydf)
      x1    x2   x3   x4   x5
1    -160  -76  -66  -29  -95
2    -159  -66  -63  -20  -85
3    -153  -63  -55  -19  -81
4    -156  -76  -54  -27  -83
5    -155  -75  -53  -30  -81
6    -145  -64  -49  -20  -71

Here is a chart of the measurement data .这是测量数据图表

We did correlate the data:我们确实关联了数据:

> cor(mydf)
    x1         x2         x3         x4         x5
x1  1.0000000  0.8033349  0.8569253  0.8262110  0.8523034
x2  0.8033349  1.0000000  0.8228611  0.9036943  0.8965484
x3  0.8569253  0.8228611  1.0000000  0.8486466  0.9091440
x4  0.8262110  0.9036943  0.8486466  1.0000000  0.8828055
x5  0.8523034  0.8965484  0.9091440  0.8828055  1.0000000

We also tried to calculate the p-values using rcorr(as.matrix(mydf)) , but received only a matrix of zeros.我们还尝试使用rcorr(as.matrix(mydf))计算 p 值,但只收到一个零矩阵。

We have several questions:我们有几个问题:

  1. Why is the p value zero and how can we fix that?为什么 p 值为零,我们如何解决这个问题?
  2. Is our way of solving the problem wrong?我们解决问题的方式是错误的吗?
  3. How can we extrapolate the given measurement data (see chart) in R?我们如何在 R 中推断给定的测量数据(见图表)?

Guide for you to look at:指南供您查看:

http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze-format-and-visualize-a-correlation-matrix-using-r-software http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze-format-and-visualize-a-correlation-matrix-using-r-software

For interpretation of results and how to use, Cross Validated is a better place to post.对于结果的解释以及如何使用, Cross Validated是一个更好的发布地点。

With regards to your R questions:关于你的 R 问题:

The rcorr() function from the Hmisc package is pretty easy to use. Hmisc包中的rcorr()函数非常易于使用。

Example Data:示例数据:

require(Hmisc)

set.seed(1)
x1 = rnorm(10,seed)
x2 = rnorm(10,seed)
x3 = x2 + rnorm(10,sd=.1,seed)
mydf <- data.frame(x1,x2,x3)
rcorr(as.matrix(mydf))

Gives an output of the Correlation Matrix as well as a pvalue matrix.给出相关矩阵的输出以及 pvalue 矩阵。 The guide above can help you flatten it and manipulate it for your needs.上面的指南可以帮助您将其展平并根据您的需要对其进行操作。

      x1    x2    x3
x1  1.00 -0.38 -0.42
x2 -0.38  1.00  1.00
x3 -0.42  1.00  1.00

n= 10 


P
   x1     x2     x3    
x1        0.2833 0.2304
x2 0.2833        0.0000
x3 0.2304 0.0000 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM