# How to determine the function factors in order to fit the curve?

I am trying to calculate innovation and imitation factor by ovserving the usage of specific service among the population.

After going through an overview of the paper I wrote the fuction in matlab:

function F = Bass(x, inputData)
m = 364426;
inputData( inputData(:,1)==0 )= 1;
end


where x(1) = innovation factor and x(2) = imitation factor

In order to determine x(1) and x(2) I created a fuction which is supposed to solve least squares curve fitting:

function [ x, resnorm ] = FitBass(priorCumulativeAdopters, currentAdoptersCount)

x0 = [0.08; 0.41];
[x, resnorm] = lsqcurvefit(@Bass, x0, xData, yData);


but the problem is that for some (real) data it returns negative imitation factor and the curve doesn't fit well during the peak period.

Below is the comparison of real and predicted data using the functions above:

By observing the shape of the curve, the real data seems to correspond to bass model:

but I guess the predicted data should be similar to actual throghout whole observed period, not just the end.

Does anyone know how to correctly determine the innovation and imitation factor use them in prediction model?

Thank you!

-