python - Relationship of two time series using Scikit or Pandas -
say have 2 hypothetical time series data 1 rainfall , other ocean surface temperature.
rainfall time series: 2001-12-31 25 mm 2002-12-31 50 mm 2003-12-31 75 mm 2004-12-31 50 mm 2005-12-31 25 mm 2006-12-31 10 mm 2007-12-31 6 mm 2008-12-31 8 mm 2009-12-31 10 mm 2010-12-31 12 mm 2011-12-31 20 mm 2012-12-31 75 mm rainfall time series: 2001-12-31 36 (degrees celsius) 2002-12-31 37 (degrees celsius) 2003-12-31 38 (degrees celsius) 2004-12-31 37 (degrees celsius) 2005-12-31 36 (degrees celsius) 2006-12-31 34 (degrees celsius) 2007-12-31 32 (degrees celsius) 2008-12-31 33 (degrees celsius) 2009-12-31 34 (degrees celsius) 2010-12-31 35 (degrees celsius) 2011-12-31 35.9 (degrees celsius) 2012-12-31 38 (degrees celsius)
i wanted answer these questions:
1.) how 2 time series related? 2.) there way find out if either 1 of time series changes other 1 change? , if how much?
we know rainfall , ocean surface temperature related , not spurious (unlike time series example of airline passengers , rice production in https://goo.gl/ecr3so) have read approximate entropy , regression of 2 time series, read arima way to determine relationship of 2 time series data yet havent found detailed example in python using scikit or pandas. prefer use entropy not know if can answer question 2. ask if there permutation distribution clustering in python, seems interesting way solve question 1. help!
just plot them in scatterplot , should able tell relation:
1) how 2 series related? (example using univariatespline, use whatever prefer)
x = 25,50,75,50,25,10,6,8,10,12,20,75 y = 36,37,38,37,36,34,32,33,34,35,35.9,38 import numpy np scipy import interpolate f = interpolate.univariatespline(x, y) xo = np.linspace(min(x),max(x),1000) yo = f(xo) df = np.diff(yo) / np.diff(xo) print(df.shape,xo.shape) import matplotlib.pyplot plt plt.scatter(x,y) plt.plot(xo,yo) plt.show()
2) how change? using 1st derivative of function "fitted" data.
plt.plot(xo[:-1],df) plt.show()
Comments
Post a Comment