[ncl-talk] Correlation coefficient for different threshold
Ehsan Taghizadeh
ehsantaghizadeh at yahoo.com
Wed Jul 11 05:48:58 MDT 2018
Hi,I've used "escorc" to compute Pearson correlation coefficient for my data, from this link: escorc.
|
|
| |
escorc
NCL built-in functions (statistics)
|
|
|
However I want to do some manipulate for input arrays, and I want best function to do that. For example in Example 1 at above link:
x = (/ 0.20, 1.88, -0.76, 0.42, 0.32, -0.56, 1.55, -1.21, -0.66, -0.96, -0.21 /)
y = (/ 0.18, 0.54, -0.49, 0.92, 0.22, 0.75, 0.66, -2.65, -0.51, 0.47, -0.09 /)
r = escorc(x,y) ; Pearson correlation
;---Compute correlation confidence interval
n = dimsizes(x) ; n=11
df = n-2
; Fischer z-transformation
z = 0.5*log((1+r)/(1-r)) ; z-statistic
se = 1.0/sqrt(n-3) ; standard error of z-statistic
; low and hi z values
zlow = z - 1.96*se ; 95% (2.58 for 99%)
zhi = z + 1.96*se
; inverse z-transform; return to r space (-1 to +1)
rlow = (exp(2*zlow)-1)/(exp(2*zlow)+1)
rhi = (exp(2*zhi )-1)/(exp(2*zhi )+1) t = r*sqrt((n-2)/(1-r^2))
p = student_t(t, df)
psig = 0.05 ; test significance level
print("t="+t+" p="+p) ; t=2.02755 p=0.0732238
if (p.le.psig) then
print("r="+r+" is significant at the 95% level"))
else
print("r="+r+" is NOT significant at the 95% level"))
end if
For example how could I compute "r,n, ..." where(x.gt.5).
I'll be thankful for any help.
SincerelyEhsan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180711/e682e787/attachment.html>
More information about the ncl-talk
mailing list