I tried to use the function lsqcurvefit to find p and q parameters for Bass Diffusion Model.
At first I wrote Bass function the following way:
function F = Bass(x, cummulativeAdoptersBefore)
m = 1500000;
F = x(1)*m + (x(2)-x(1))*cummulativeAdoptersBefore + x(2)/m*cummulativeAdoptersBefore.^2;
end
x(1) = p
x(2) = q
and then FitBass:
function [ x, resnorm ] = FitBass(priorCumulativeAdopters, currentAdoptersCount)
xData = priorCumulativeAdopters;
yData = currentAdoptersCount;
x0 = [0.08; 0.41];
[x, resnorm] = lsqcurvefit(@Bass, x0, xData, yData);
end
But when compared the results F = Bass(x, cummulativeAdoptersBefore), where x is the vector of matched parameters and yData which is actual data, I noticed that the F (the lower curve – x ~ 1) is not even similar to yData:
Does anayone know what could be wrong here or how to find the parameters x for satisfactory fit in this case (and in general)?
Thank you!

For gawds sake, why not just use simple linear regression? 🙂 Throwing a nonlinear fit at this is like using a Mack truck to take a pea to Boston. This is a simple quadratic polynomial.
Combine terms.
See that p and q are linearly estimable coefficients. Assuming that your data falls in a pair of column vectors, solve for p and q like this…
pq will be a column vector of length 2.
Having said this, expect to see potential numerical problems, as there appears to be a scaling issue.
M is 1.5e6, and the vector of priorCumulativeAdopters appears to be scaled in the interval 0 to 16. See what happens when you subtract N from M. So don’t be surprised if there is a problem, and you come running back, telling us there is a problem. I already expect you’ve got something screwed up. I’ll guess this is why you got a poor fit before.