<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">Dear NCL talk<br><div>How can I put the equation for the linear regression?</div><div><br></div><div>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</div><div>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</div><div><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/regline_stats.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Contributed/regline_stats.shtml</a><br></div><div>My code is </div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; calculate the regression coefficient (slope)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>;************************************************</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc1 = regline_stats(x, y2) ; slope</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc1@units = "(W/m2)"</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc2 = regline_stats(x, y3) ; slope</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc2@units = "(W/m2)"</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc3 = regline_stats(x, y4) ; slope</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> rc3@units = "(W/m2)"</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>;************************************************</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; create an array to hold both the original data</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; and the calculated regression line</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; ---------</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; y = mx+b</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; m is the slope: rc returned from regline</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>; b is the y intercept: rc@yave attribute of rc returned from regline</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>;************************************************</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>pltarry = new ((/2,2191/),float)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry(0,:) = y2 ; use markers</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry(1,:) = rc1*(x-rc1@xave) + rc1@yave ; use solid line</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>pltarry1 = new ((/2,2191/),float)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry1(0,:) = y3 ; use markers</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry1(1,:) = rc2*(x-rc2@xave) + rc2@yave ; use solid line</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>pltarry2 = new ((/2,2191/),float)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry2(0,:) = y4 ; use markers</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> pltarry2(1,:) = rc3*(x-rc3@xave) + rc3@yave ; use solid line</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> x1 = ispan(-100,500,1)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> y = x1</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>labels1 = "y=" + sprintf("%4.2f",rc1@b(1)) + "x+" + sprintf("%4.2f",rc1@b(0))</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>labels2 = "y=" + sprintf("%4.2f",rc2@b(1)) + "x" + sprintf("%4.2f",rc2@b(0))</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>labels3 = "y=" + sprintf("%4.2f",rc3@b(1)) + "x+" + sprintf("%4.2f",rc3@b(0))</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span><br></span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span><br></span></p></div></div>
</div><br></div>
</div><br></div>