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>
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.