[ncl-talk] Correlation coefficient for different threshold

Dennis Shea shea at ucar.edu
Wed Jul 11 08:24:00 MDT 2018


The question is not clear to me.

  x = (/..../)
  y = (/..../)

  i5 = ind(x.gt.5)


 r5 = *escorc*(x(i5),y(i5))                ; Pearson correlation
 n5 = *num*(x.gt.5)




On Wed, Jul 11, 2018 at 5:48 AM, Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com
> wrote:

> Hi,
> I've used "escorc" to compute Pearson correlation coefficient for my data,
> from this link: escorc
> <https://www.ncl.ucar.edu/Document/Functions/Built-in/escorc.shtml>.
>
> escorc
>
> NCL built-in functions (statistics)
> <https://www.ncl.ucar.edu/Document/Functions/Built-in/escorc.shtml>
>
>
> 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* <https://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(x)                ; n=11
>         df   = n-2
>                                           ; Fischer z-transformation
>         z    = 0.5**log* <https://www.ncl.ucar.edu/Document/Functions/Built-in/log.shtml>((1+*r*)/(1-*r*))  ; z-statistic
>         se   = 1.0/*sqrt* <https://www.ncl.ucar.edu/Document/Functions/Built-in/sqrt.shtml>(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* <https://www.ncl.ucar.edu/Document/Functions/Built-in/exp.shtml>(2*zlow)-1)/(*exp* <https://www.ncl.ucar.edu/Document/Functions/Built-in/exp.shtml>(2*zlow)+1)
>         rhi  = (*exp* <https://www.ncl.ucar.edu/Document/Functions/Built-in/exp.shtml>(2*zhi )-1)/(*exp* <https://www.ncl.ucar.edu/Document/Functions/Built-in/exp.shtml>(2*zhi )+1)
>
>         t    = *r***sqrt* <https://www.ncl.ucar.edu/Document/Functions/Built-in/sqrt.shtml>((n-2)/(1-*r*^2))
>         p    = *student_t* <https://www.ncl.ucar.edu/Document/Functions/Built-in/student_t.shtml>(t, df)
>         psig = 0.05                       ; test significance level
>         *print* <https://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>("t="+t+"  p="+p)            ; t=2.02755  p=0.0732238
>         if (p.le.psig) then
>             *print* <https://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>("*r*="+r+" is significant at the 95% level"))
>         else
>             *print* <https://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>("*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.
>
> Sincerely
> Ehsan
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180711/f6b59782/attachment.html>


More information about the ncl-talk mailing list