# Struggling with FindFit

I'm trying to fit a sinusoidal wave to some numerical data. I can do it by hand using manipulate, so I know roughly the sort of parameter values that I should get back, but functions such as FindFit or NonlinearModel fit are hopeless for some of my datasets.

For example,

data = {0.316228, -0.316228, 0.316228, -0.316228, 0.316228, -0.316228, 0.316228, -0.316228, 0.316228, -0.316228, 0.316228}
FindFit[data, a Sin[bx + c], {a,b,c},x]


FindFit returns

{a -> 0.0687053, b -> 1.13454, c -> 1.04675}


which is hopelessly off. By hand I know I should get something along the lines of

a ~ 0.4,
c ~ -1,
b ~ 3.1


What am I doing wrong?

For other sinusoidal datasets, FindFit works perfectly!

• Please see this link for reasons why you should now be using NonlinearModelFit. Also, you'll find with a bit of digging on this site that nonlinear least squares fits are much more successful when you add better starting guesses. – bobthechemist Oct 19 '14 at 21:40

Use NonlinearModelFit and put in the best guess parameters from your Manipulate.
data = {0.316228, -0.316228, 0.316228, -0.316228, 0.316228, -0.316228,