[R] fit data to y~A+B*sin(C*x)

Jonas Stein news at jonasstein.de
Mon Feb 13 23:54:53 CET 2012


I want to fit discrete data that was measured on a wavegenerator.
In this minimal example i generate some artificial data:

testsin <- 2+ 5 * sin(1:100) #generate sin data
testsin <-  testsin+ rnorm(length(testsin), sd = 0.01) #add noise

mydata <- list(X=1:100, Y=testsin) # generate mydata object

nlmod <- nls(X ~ A+B*sin(C* Y), data=mydata, start=list(A=2, B=4, C=1), trace=TRUE)

# this nls fit fails. 

Who can help me to fit this type of data?
Kind regards,

-- 
Jonas Stein <news at jonasstein.de>



More information about the R-help mailing list