[R] fitting periodic 'sine wave' model

From: Jon Loehrke <jloehrke_at_umassd.edu>
Date: Tue, 10 Jun 2008 10:25:12 -0400

I have been attempting to estimate the periodic contribution of an effect to some data but have not been able to fit a sine wave within R. It would be nice to start by being able to fit a sine wave with an amplitude and frequency.

y<-2*sin(2*pi*.5*x) #amplitude =2, frequency=0.5

# This failed to converge

r<-nls(y ~ A*sin(2*pi*F*x), start=list(A = 1, F = 1), trace=T)

# even this gave a max iteration error

r<-nls(y ~ A*sin(2*pi*F*x), start=list(A = 1, F = .5), trace=T)

I have a feeling I am approaching this incorrectly. Thank you all very much for the guidance.

R 2.7.0
mac os 10.5

Jon Loehrke
Graduate Research Assistant
Department of Fisheries Oceanography
School for Marine Science and Technology University of Massachusetts
200 Mill Road, Suite 325
Fairhaven, MA 02719
T 508-910-6393
F 509-910-6396

R-help_at_r-project.org 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. Received on Tue 10 Jun 2008 - 14:29:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 21:30:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive