OK, I suspected but then didn't check, that was dumb of me..
So with that in mind:
resid = y-yfit;
residDFT = fft(resid);
Fs = 1;
freq = 0:Fs/length(resid):Fs/2;
residDFT = residDFT(1:floor(length(resid)/2)+1);
plot(freq(1:100),abs(residDFT(1:100)))
You'll see the biggest peak at a frequency of 0.002 cycles/day, which is a period of 500 days. Looks to me like the next most prominent peak is at 0.0059 cycles/day which is a period of almost 170 days (169.89).
I think if you fit those two frequencies using the Fourier coefficients along with the linear model fitted above, you'll have a very good fit to the data.
Best Answer