title: r in stats.linregress compared to r-squared in statsmodels
body: <p>I'm working on a program to investigate the correlation between magnitude and redshift for some quasars, and I'm using <code>statsmodels</code> and <code>scipy.stats.linregress</code> to compute the statistics of the data; <code>statsmodels</code> to compute <code>r-squared</code> (among other parameters), and <code>stats.linregress</code> to compute <code>r</code> (among others).</p>
  
  <p>Some example output is:</p>
  
  <pre><code>W1 r-squared: 0.855715
  W1 r-value  : 0.414026
  W2 r-squared: 0.861169
  W2 r-value  : 0.517381
  W3 r-squared: 0.874051
  W3 r-value  : 0.418523
  W4 r-squared: 0.856747
  W4 r-value  : 0.294094
  Visual minus WISE r-squared: 0.87366
  Visual minus WISE r-value  : -0.521463
  </code></pre>
  
  <p>My question is, why do the <code>r</code> and <code>r-squared</code> values not match</p>
  
  <p>(i.e. for the W1 band, 0.414026**2 != 0.855715)?</p>
  
  <p>The code for my computation function is as follows:</p>
  
  <pre><code>def computeStats(x, y, yName):
      from scipy import stats
      import statsmodels.api as sm
  
      #   Compute model parameters
      model = sm.OLS(y, x, missing= 'drop')
      results = model.fit()
      #   Mask NaN values in both axes
      mask = ~np.isnan(y) &amp; ~np.isnan(x)
      #   Compute fit parameters
      params = stats.linregress(x[mask], y[mask])
      fit = params[0]*x + params[1]
      fitEquation = '$(%s)=(%.4g \pm %.4g) \\times redshift+%.4g$'%(yName,
                  params[0],  #   slope
                  params[4],  #   stderr in slope
                  params[1])  #   y-intercept
  
      print('%s r-squared: %g'%(name, arrayresults.rsquared))
      print('%s r-value  : %g'%(name, arrayparams[2]))
  
      return results, params, fit, fitEquation
  </code></pre>
  
  <p>Am I interpreting the statistics incorrectly? Or do the two modules compute the regressions using different methods?</p>