First, you don't understand how to use fittype. fittype does not set something that fit can use, UNLESS YOU PASS IN THE RESULTS OF FITTYPE INTO FIT.
Second, your data really does not merit three terms.
Finally, you can just use the gauss2 model form anyway.
F = fittype('gauss2')
F =
General model Gauss2:
F(a1,b1,c1,a2,b2,c2,x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2)
Now, call fit. But what parameter start estimates make sense there? PLOT YOUR DATA. LOOK AT THE PLOT. THINK ABOUT WHAT YOU SEE. ALWAYS DO THESE THREE THINGS.
plot(DAY,NUMBERof,'o')
grid on
xlabel DAY
ylabel casualties
Now you clearly have a peak around day 23. How wide is it? The width of that main peak is probably around 25-30 days, if we guess where the 10% points on the peak are. Divide that width by 4, to give a decent scale parameter in this form. How high is the main peak? I'll guess 800 at the center.
The second term is off to the right. Say it peaks around day 40. The width is wider, maybe I'll guess a width of 60 days. (Again, divide by 4 to be the parameter estimate.) How high? Say 300.
We don't need perfect numbers here. How do we use fit now? PASS IN F!
mdl = fit(DAY,NUMBERof,F,'start',[ 800, 23, 7.5, 300, 40, 15])
mdl =
General model Gauss2:
mdl(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2)
Coefficients (with 95
a1 = 641.3 (247.6, 1035)
b1 = 20.62 (19.74, 21.5)
c1 = 8.827 (6.169, 11.48)
a2 = 522.1 (422.6, 621.7)
b2 = 36.25 (28.74, 43.76)
c2 = 17.25 (8.059, 26.44)
My initial estimates were not dead on, but reasonably close. The secondary peak is disappointingly higher than I would like to see. But then people are too often foolish.
plot(mdl)
hold on
plot(DAY,NUMBERof,'bo')
xlabel DAY
ylabel casualties
grid on
Again, the fit seems entirely reasonable. The noise around the curve seems pretty random at this point, with little apparent lack of fit. That tells me any attempt to estimate a THIRD gaussian peak from that data would be a complete joke. You would be kidding yourself if you tried that, without considerably more and considerably better data.
In order to choose intelligent estimates for starting points, you need to understand what each parameter in the model does, and how it impacts the shape of the curve. Sorry, but there is no magical way to do that without understanding the model you are using.