<P class=MsoNormal>Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P class=MsoNormal>Please copy all replies directly to me (my account is having difficulty with receiving lists these days).<o:p></o:p></P>
<P class=MsoNormal>This is primarily a programming question, but the specifics regard start values for a nonlinear regression (if you have suggestions on alternative ways to obtain start values they are welcome as well).<o:p></o:p></P>
<P class=MsoNormal>I'm using nls to estimate a nonlinear time series equation of the form:<o:p></o:p></P>
<P class=MsoNormal>y=p*cos(w*t+a)<o:p></o:p></P>
<P class=MsoNormal>where p,w and a are amplitude, frequency and phase.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Really I eventually want a sum of cosines model - i.e. multiple cosine terms, with the number of cosines determined by Quinn's (1989) AIC-like statistic (roughly, T*log(RSS)+2K, with k= number of cosines).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>A reference for this sort of model is Brillinger (1987) "Fitting Cosines: Some Procedures and Some Physical Examples."<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>My main interest in estimating the frequency parameter(s). <o:p></o:p></P>
<P class=MsoNormal>Starting values are not so easy to come by for such a model.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If I were to arbitrarily plug in values, I'll typically either get convergence somewhere in the neighborhood of the starting w (actually sometimes they can be far from this as well), or an error something like this:<o:p></o:p></P>
<P class=MsoNormal>Error in nls(y ~ rho * cos(omega * tau + phi), start = list(rho = 1, omega = grid[i],<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>: </P>
<P class=MsoNormal>number of iterations exceeded maximum of 5.32761e-306<o:p></o:p></P>
<P class=MsoNormal>One very simple way to think about this is to try a bunch of different start values and pick the one that minimized the regression's RSS.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I could make a grid to search on, then simply pick the minimizer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The problem though is that when a bad start value is used (i.e. the error above), the program stops entirely, so we don't do more than a few trials in the grid search.<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>My main question is how can I get around this to complete the search? <o:p></o:p></P>
<P class=MsoNormal>Just for discussion, another (simple-minded) way might be to look at the periodogram, but this has provided little success. Most of the peaks of interest are at the very low frequency range (e.g. w=.01).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>But convergence is not generally achieved for the model in this range.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>A priori knowledge/deductions are generally consistent with the periodogram's results.<o:p></o:p></P>
<P class=MsoNormal>Again, if people have other ideas for obtaining starting values, they are entirely welcome and encouraged - estimates are highly sensitive to the start values, so I'm interested in trying a number of approaches.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>My main question, however, is on completing the simple grid search. If it is helpful, here is simple grid search code:<o:p></o:p></P>
<P class=MsoNormal>for (i in 1:length(grid)){<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>n&lt;-nls(y~rho*cos(omega*tau+phi),start=list(rho=1,omega=grid[i],phi=1))<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>summ&lt;-summary(n)<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>resids&lt;-summ$resid<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>SSR&lt;-sum(resids^2)<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></P>
<P class=MsoNormal><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>Thank you,<o:p></o:p></P>
<P class=MsoNormal>(Please remember to cc this message directly to me.)<o:p></o:p></P>
<P class=MsoNormal>&nbsp;Brian</P><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/welcome/*http://launch.yahoo.com">LAUNCH</a> - Your Yahoo! Music Experience