I have some temperature data gathered over the course of a few days which follow a cyclic pattern. I've fit a linear regression model to it with sine and cosine waves of multiple periods and the result is very close to what it should be.
My question is the following: the model produces a cyclic wave which matches the phase of my data (with peaks and troughs in the same place). How is this possible since I only vary the period length and amplitudes? I don't explicitly model the phase.
My code (Python): note that I adjust the time in hours so that a full day corresponds to 2$\pi$ hours. Is the phase modeled implicitly with the intercept of the linear model?
order = 10
var = temp
T = np.asarray([x.hour*np.pi*(1/12.0) for x in time])
sT = [np.sin((a+1)*T) for a in range(order)]
cT = [np.cos((a+1)*T) for a in range(order)]
X = np.asarray(sT)
X = np.vstack([np.vstack([X,cT])]).transpose()
from sklearn import linear_model
clf = linear_model.LinearRegression()
clf.fit(X,var)