I have data that can apparently be fitted by a sinusoidal function in form $D+A\sin(B(x-\frac CB))$.
I tried doing the best fit in Mathematica using NonlinearModelFit function. I got a message saying it failed to converge with current accuracy and max iterations, so I tinkered a little bit with the function, but it made a model far from being the best fit for the data. I tried replacing parameters with constants and it turned out the problem was in finding $B$, or the horizontal shift, since I got a satisfactory fit when I specified the shift.
So my question is: Is there a work-around for this problem, so I can find the best horizontal shift?
Note: I tried it with the form $D+A\sin(Bx-C)$ with the same problem.
Edit: This is the requested data, note that in the second NonlinearModelFit, I specified b and it worked like a charm:
data = {{10, 716}, {20, 727}, {30, 744}, {40, 762}, {50, 783},{60, 804},
{70, 826}, {80, 848}, {90, 872}, {100, 894}, {110, 915}, {120, 935},
{130, 954}, {140, 969}, {150, 982}, {160, 990}, {170, 993},
{180, 992}, {190, 986}, {200, 975}, {210, 961}, {220, 944},
{230, 926}, {240, 905}, {250, 883}, {260, 861}, {270, 839},
{280, 817}, {290, 795}, {300, 774}, {310, 755}, {320, 738},
{330, 723}, {340, 712}, {350, 706}, {360, 706}}
NonlinearModelFit[data, d + a Sin[b (x - c)], {a, b, c, d}, x]["BestFit"]
During evaluation of NonlinearModelFit::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations.
853.439 - 1717.86 Sin[0.94244 (10.0078 + x)]
NonlinearModelFit[data, d + a Sin[b (x - c)] /. b -> π/185, {a, c, d}, x]["BestFit"]
849.276 + 141.098 Sin[π/185 (-1930.24 + x)]
bat $\pi/180$ anddat the mean of the data:NonlinearModelFit[data, d + a Sin[b (x - c)], {a, {b, π/180}, c, {d, Mean@data[[All, 2]]}}, x]["BestFit"]; this gives the desired fit. – Jul 08 '14 at 19:57