[ncl-talk] Linear equation for regline_state

mark vogel mdvogelii at gmail.com
Mon May 2 10:50:10 MDT 2016


Dear NCL talk
How can I put the equation for the linear regression?

As my graph I got the y = 1.87x - 0.6 it does not seem right to me when x =
0 and y = -0.6
It does not seem right to me when x = 0 y is -0.6 but I follow the
reline_stats equation as in the ncl link
http://www.ncl.ucar.edu/Document/Functions/Contributed/regline_stats.shtml
My code is

; calculate the regression coefficient (slope)

;************************************************

   rc1    = regline_stats(x, y2)          ; slope

   rc1 at units = "(W/m2)"

   rc2    = regline_stats(x, y3)          ; slope

   rc2 at units = "(W/m2)"

   rc3    = regline_stats(x, y4)          ; slope

   rc3 at units = "(W/m2)"


;************************************************

; create an array to hold both the original data

; and the calculated regression line

;     ---------

;     y = mx+b

;     m is the slope:       rc      returned from regline

;     b is the y intercept: rc at yave attribute of rc returned from regline

;************************************************

pltarry   = new  ((/2,2191/),float)


   pltarry(0,:) = y2                                 ; use markers

   pltarry(1,:) = rc1*(x-rc1 at xave) + rc1 at yave          ; use solid line

pltarry1   = new  ((/2,2191/),float)


   pltarry1(0,:) = y3                                 ; use markers

   pltarry1(1,:) = rc2*(x-rc2 at xave) + rc2 at yave          ; use solid line

pltarry2   = new  ((/2,2191/),float)

   pltarry2(0,:) = y4                                 ; use markers

   pltarry2(1,:) = rc3*(x-rc3 at xave) + rc3 at yave          ; use solid line

 x1 = ispan(-100,500,1)

 y = x1


labels1 = "y=" + sprintf("%4.2f",rc1 at b(1)) + "x+" + sprintf("%4.2f",rc1 at b
(0))

labels2 = "y=" + sprintf("%4.2f",rc2 at b(1)) + "x" + sprintf("%4.2f",rc2 at b(0))

labels3 = "y=" + sprintf("%4.2f",rc3 at b(1)) + "x+" + sprintf("%4.2f",rc3 at b
(0))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160502/3fbaf947/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3Mregress.pdf
Type: application/pdf
Size: 1748245 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160502/3fbaf947/attachment-0001.pdf 


More information about the ncl-talk mailing list