[R] Fiting a trend + periodic signal

Carl Witthoft carl at witthoft.com
Thu Aug 12 23:37:48 CEST 2010


Use nls().

But you should also take the time to learn a bit about data fits in 
general.  I'm far from expert, but it sure looks like that P(t) is 
overconstrained.  Since cos(wt) = sin(wt+pi/2),  why do you have all 
those different terms?


<quote>


Dear all,
I have a time series and I like to fit S(t) = T(t) + P(t)

  T(t) = Linear Trend = a + bt
  P(t) = Periodic Signal = sum(Ai*cos(wt) + Bi*sin(wt) ) for i=1,...,3.
</quote>



More information about the R-help mailing list