If I have to write a model for exponential decline in deaths and therefore write it
X(n) = X(n-1) - r*X(n-1);
Then I have to use sum of squares and the matlab function fminbnd to estimate the parameter giving the rate of decrease.
Should it be something like
function X = exponentialDecline(X1,r,nmax)
%Computes death under exponential decline, with decline rate r
X = zeros(1,nmax);
X(1) = X1;
for n=2:nmax
X(n) = X(n-1) - r*X(n-1);
end
Would that be the proper way? I don’t really know how to use the fminbnd function if you know a good reference it would be very much appreciated.
fminbndfinds a minima of a 1D function.For example if you want to find the minimum of a quadratic function (x-1)^2 in [0, 2], then do
In your case, since you want to optimize for the r, make a function (say
decayRate(r)) that takes parameter r and returns the decay rate, and you can run something like