From: Sheeja Krishnan on
While using nlpredci, I find that the confidence interval is sensitive to the 'fdiffstep' which is the step used in numerical finite difference in 'getjacobian' routine. How to fix the problem? I find that the fdiffstep is calculated using options.DerivStep in statset fucntion in statistics toolbox. How to find out the DerivStep that will not give a sensitive confidence interval in nlpredci?

Thanks Sheeja
From: Tom Lane on
> While using nlpredci, I find that the confidence interval is sensitive to
> the 'fdiffstep' which is the step used in numerical finite difference in
> 'getjacobian' routine. How to fix the problem? I find that the fdiffstep
> is calculated using options.DerivStep in statset fucntion in statistics
> toolbox. How to find out the DerivStep that will not give a sensitive
> confidence interval in nlpredci?

Sheeja, it's true. The confidence intervals from nlpredci are based on the
Jacobian, and the Jacobian is computed using finite differences in nlinfit,
with the step size determined by DerivStep. That is as intended.

I don't understand what problem this is causing. Do the intervals vary by an
unreasonable amount as this setting changes? I suppose it's possible that
the best step size for carrying out the nonlinear fitting is not the best
one for computing confidence intervals. You could try re-running the nlinfit
procedure using the estimates from the first round as starting values, and
using a smaller DerivStep. Or, since you seem to have looked at and
understood the code, you could try to extract just the Jacobian calculation
and compute that separately after fitting the model.

But I haven't tried this, as I don't have your data and your model function.

-- Tom


From: Sheeja Krishnan on
Thanks Tom for the reply..

What I have done :
I have found some parameters say beta1, beta2 through nlinfit for some model that depends on (t,beta,phi) where phi was kept constant. t-time, beta is the fitted parameter and phi=phi_1 is some drug concentration in the plasma. I obtian confidence on beta and model prediction by nlinfit and nlpredci. Till this I am perfectly fine.

Now I say that phi has changed to phi_2. I say that betas along with betaci that I obtained earlier for phi_1 is the mean parameter and I would like to get the predicted response through the nlpredci. Here since model estimation depends on the value of phi_2, I have to calculate J. I can get residuals, since there is experimental data available for model prediction with phi_2.

While calculating J for phi_2, I copied what nlinfit does to get J. The inputs are fdiffstep, model, X, beta. I found that nlinfit finds fdiffstep from 'eps' (which gives the the positive distance from absolute value to the next larger in
magnitude floating point number of the same precision).The particular value for my system under concern is 6.05e-6.But this provides an oscillatory confidence intervals through nlpredci. I changed the fdiffstep to a lower value to 1e-13 and 1e-14 where there is no oscillatory behavior, but the confidence intervals do vary from each other( double the difference).

Now how to get rid of this problem. Hope I made my problem clear. I am not sending the codes, since the model that I write is a system of ODEs constructed by discretizing a hyperbolic PDE.

Thanks for the help.