[R] Fit a sine to data

Juan Manuel Barreneche jumanbar at gmail.com
Fri May 23 15:56:39 CEST 2008


i guess nls or gnls should work....

JM

El Viernes, 23 de Mayo de 2008 10:47, Zroutik Zroutik escribió:
> Dear R-users,
>
> I'd like to fit a sine function to my data. The result should have a format
> (and thus the formula, too)
>
> y ~ a + sin(x+b)
>
> where y and x are vectors, and a and b are (yet) unknown values.
>
> The data sets (vectors x and y) are OK, and I can do a simple lm fitting
> lm(y~x), or lm(y~I(sin(2*pi*x/360))), succesfully  My issue is that I'm not
> able to do the optional linear shift in x (e.g. x+b). What other
> possibilities should I use instead of lm? I looked searched the R-seek for
> terms: fit, sine, lm, and combinations, but I could not find anything
> useful. Anybody would be so kind and point me to the right direction where
> I can find other fitting possibilities?
>
> Thank you for listening and kind answers upfront.
>
> Regards,
> Milan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list