<div dir="ltr">Hi:<div><br></div><div>I didn't see that this function has been updated to calculate the coefficient of determination (r).</div><div><br></div><div>I did see this e-mail and one after (e.g.: <a href="https://www.ncl.ucar.edu/Support/talk_archives/2009/2202.html">https://www.ncl.ucar.edu/Support/talk_archives/2009/2202.html</a></div><div><br></div><div>but this (below) may be more useful for users wanting the simplest approach to calculating statistics for a line.</div><div><br></div><div>







<p class="gmail-p1"><span class="gmail-s1">begin</span></p>
<p class="gmail-p1"><span class="gmail-s1">x = (/1,2,3,4,5,6,7,8,9,10/)</span></p>
<p class="gmail-p1"><span class="gmail-s1">y = (/0.6,1.6,1.2,2.2,2.3,3.1,2.8,4.1,4.7,3.3/)</span></p>
<p class="gmail-p2"><span class="gmail-s1"></span><br></p>
<p class="gmail-p1"><span class="gmail-s1">rc = regline(x,y)  ; function as is.</span></p>
<p class="gmail-p1"><span class="gmail-s1">print("rc = " + rc)</span></p>
<p class="gmail-p1"><span class="gmail-s1">printVarSummary(rc)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>sum_xy = sum(x*y)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>sum_x = sum(x)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>sum_x2 = sum(x^2)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>sum_y = sum(y)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>sum_y2 = sum(y^2)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>n = dimsi</span><span class="gmail-s2">z</span><span class="gmail-s1">es(x)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>r_n = n*sum_xy - sum_x*sum_y</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>r_d =(n*sum_x2<span class="gmail-Apple-converted-space">  </span>- (sum_x)^2)*(n*sum_y2<span class="gmail-Apple-converted-space">  </span>- (sum_y)^2)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>r = r_n/sqrt(r_d)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>print(r)</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>r2 = r^2</span></p>
<p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    </span>print(r2)</span></p>
<p class="gmail-p1"><span class="gmail-s1">end</span></p><p class="gmail-p1"><span class="gmail-s1">Answer r = 0.9075 and r2 = 0.82364.</span></p><p class="gmail-p1"><span class="gmail-s1"><br></span></p><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>US 914 432 3108<br></div></div></div>
</div></div>