Moved from [Stack Overflow][1] Could someone help me to find adequate regression model for my data? I tried to seek it by changing model and initial approximation (ln 15-16) at this simple Python program: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import scipy.linalg as la from numpy import random from scipy.optimize import minimize def main(): a = np.loadtxt('group_all_tweets.dat', dtype=np.float32, delimiter='\t') sin_model = lambda p, x: (p[0] + p[1] * np.exp(np.sin((np.pi / p[2]) * x + p[3]))**3) x0 = np.array([1.58e+04, -1.72e+03, 24.0, 7.59]) res = minimize(lambda p: la.norm(sin_model(p, a[:, 0]) - a[:, 1]), x0=x0, method='Powell') print res sin_params = res['x'] plt.plot(a[:, 0], a[:, 1]) plt.plot(a[:, 0], sin_model(sin_params, a[:, 0])) plt.figure() rss = a[:, 1] - sin_model(sin_params, a[:, 0]) pol_model = lambda p, x: sum([p[i] * x**i for i in xrange(4)]) x0 = np.array([0.0 for i in xrange(4)]) res = minimize(lambda p: la.norm(pol_model(p, a[:, 0]) - rss), x0=x0, method='Powell') print res pol_params = res['x'] rss = a[:, 1] - sin_model(sin_params, a[:, 0]) - pol_model(pol_params, a[:, 0]) plt.plot(a[:, 0], rss) plt.figure() plt.plot(a[:, 0], a[:, 1]) plt.plot(a[:, 0], sin_model(sin_params, a[:, 0]) + pol_model(pol_params, a[:, 0])) plt.show() if __name__ == '__main__': main() Here, firstly I try to find a periodic pattern `((p[0] + p[1] * np.exp(np.sin((np.pi / p[2]) * x + p[3]))**3))` while `p[i]` are variating parameters, then approximating the remains of the first regression with second, polynomial regression. The best result that I managed to get with the method described shown in the [graph][2]. I'm pleased with how approaching the bottom part of the graph, but tops I just do not like. Has anyone here an experience of finding of regression models? I would be grateful for any help. Thank you. Datafile is [here][3]. I need to find a dependence of the second column from the first. I think, I want to build a model which contains a periodical component, "top-trend" and "bottom-trend" components, last two are indipendent. [1]: http://stackoverflow.com/questions/16631113/regression-model-for-periodic-data "Stack Overflow" [2]: https://i.sstatic.net/bE5A1.png [3]: http://codepad.org/4bn6uZIe "I need to find a dependence of the second column from the first"