Brian Scholl
2002-May-16 14:34 UTC
[R] grid search with failed evaluations (and nonlinear start values as a secondary consideration)
Hello,
Please copy all replies directly to me (my account is having difficulty with
receiving lists these days).
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).
I'm using nls to estimate a nonlinear time series equation of the form:
y=p*cos(w*t+a)
where p,w and a are amplitude, frequency and phase. 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). A reference for this sort of model is Brillinger
(1987) "Fitting Cosines: Some Procedures and Some Physical Examples."
My main interest in estimating the frequency parameter(s).
Starting values are not so easy to come by for such a model. 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:
Error in nls(y ~ rho * cos(omega * tau + phi), start = list(rho = 1, omega =
grid[i], :
number of iterations exceeded maximum of 5.32761e-306
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. I could make a
grid to search on, then simply pick the minimizer. 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. My
main question is how can I get around this to complete the search?
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). But convergence is not
generally achieved for the model in this range. A priori knowledge/deductions
are generally consistent with the periodogram's results.
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. My main
question, however, is on completing the simple grid search. If it is helpful,
here is simple grid search code:
for (i in 1:length(grid)){
n<-nls(y~rho*cos(omega*tau+phi),start=list(rho=1,omega=grid[i],phi=1))
summ<-summary(n)
resids<-summ$resid
SSR<-sum(resids^2)
}
Thank you,
(Please remember to cc this message directly to me.)
Brian
---------------------------------
LAUNCH - Your Yahoo! Music Experience
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
https://stat.ethz.ch/pipermail/r-help/attachments/20020516/efbdd32e/attachment.html
Thomas Lumley
2002-May-16 15:30 UTC
[R] grid search with failed evaluations (and nonlinear start values as a secondary consideration)
On Thu, 16 May 2002, Brian Scholl wrote:> > 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. I > could make a grid to search on, then simply pick the minimizer. 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. My main question is how can I get around > this to complete the search? >You can use try() around the trials in the grid search to catch the errors. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._