title: alpha & beta (for linear regression) calculations output nan?
body: <p>I am new to Python and have been attempting to calculate the linear regression/Beta/Alpha for two securities, however my code is outputting Nan for both Beta &amp; Alpha, and therefore I am unable to draw the regression line. </p>
  
  <p>here is the code in question:</p>
  
  <pre><code>#calculate linear regression
  beta_yPlt, alpha_yPlt = np.polyfit(xPlt, yPlt, 1)  # fit poly degree 1
  print "Y Beta", beta_yPlt
  print "Y Alpha", alpha_yPlt
  plt.plot(xPlt, beta_yPlt * xPlt + alpha_yPlt, '-', color='red')
  </code></pre>
  
  <p>and here is the full script:</p>
  
  <pre><code>from pandas.io.data import DataReader
  from datetime import datetime
  import matplotlib.pyplot as plt
  import numpy as np
  
  #inputs
  symbols   = ['EUR=X', 'JPY=X']
  startDate = datetime(2011,1,1)
  endDate   = datetime(2016,12,31)
  
  #get data from yahoo
  instrument = DataReader(symbols, 'yahoo', startDate, endDate)
  #isolate column
  close = instrument['Adj Close']
  
  #calculate daily returns
  def compute_daily_returns(df):
      daily_returns = (df / df.shift(1)) - 1
      return daily_returns
  
  dlyRtns = compute_daily_returns(close)
  xPlt = dlyRtns[symbols[0]]
  yPlt = dlyRtns[symbols[1]]
  
  #draw "scatter plot" - using "o" workaround
  dlyRtns.plot(x=symbols[0], y=symbols[1], marker='o', linewidth=0)
  
  #calculate linear regression
  beta_yPlt, alpha_yPlt = np.polyfit(xPlt, yPlt, 1)  # fit poly degree 1
  print "Y Beta", beta_yPlt
  print "Y Alpha", alpha_yPlt
  plt.plot(xPlt, beta_yPlt * xPlt + alpha_yPlt, '-', color='red')
  
  # Calculate correlation coefficient
  print "Correlation", dlyRtns.corr(method='pearson')
  plt.show()
  </code></pre>
  
  <p>and here is the output:</p>
  
  <pre><code>C:\Python27\python.exe C:/Users/Us/Desktop/untitled3/scatterPlot.py
  Y Beta nan
  Y Alpha nan
  Correlation           EUR=X     JPY=X
  EUR=X  1.000000  0.228223
  JPY=X  0.228223  1.000000
  
  Process finished with exit code 0
  </code></pre>
  
  <p>Any ideas why I getting Nan here? I am at a loss, any help is much appreciated.</p>