简体   繁体   中英

paired.r Function - Correct degrees of freedom?

I have a dataset in which I am testing for a significant difference between two dependent correlations. For example, I examined the correlations between variables X and Z (corXZ) and between variables Y and Z (corYZ), and also want to know if corXZ and corYZ are significantly different, taking into account the correlation between X and Y (corXY).

I have been using the R function paired.r, which generally works very well. But, as you can see, it does not provide the degrees of freedom in the output, simply a t-value:

https://www.rdocumentation.org/packages/psych/versions/1.7.8/topics/paired.r

For the purposes of reporting such tests in a manuscript, I need to provide the accurate degrees of freedom. How do I find this or calculate this?

For the test with a third (yz) correlation specified, the degrees of freedom are = n-3 :

> # install.packages("psych")
> library(psych)
> 
> n = 100
> paired.r(.5,.3, .4, n = n)
Call: paired.r(xy = 0.5, xz = 0.3, yz = 0.4, n = n)
[1] "test of difference between two correlated  correlations"
t = 2.06  With probability =  0.04

> 2 * pt(q = 2.06, df = n-3, lower.tail = F) # 2 tailed p value
[1] 0.04207664


> n = 10
> paired.r(.5,.3, .4, n = n)
Call: paired.r(xy = 0.5, xz = 0.3, yz = 0.4, n = n)
[1] "test of difference between two correlated  correlations"
t = 0.56  With probability =  0.6

> 2 * pt(q = 0.56, df = n-3, lower.tail = F)
[1] 0.5929396
> 

The nice point with open source software like R is that you can always inspect the source code to answer this kind of question. Here you can simply type paired.r in the console (without parentheses) in the console to obtain the source code...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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