[SciPy-User] confidence interval for leastsq fit
josef.pktd at gmail.com
josef.pktd at gmail.com
Thu Apr 28 06:09:14 EDT 2011
On Wed, Apr 27, 2011 at 11:08 PM, dima osin <dima.osin at gmail.com> wrote:
> How to calculate confidence interval for scipy.optimize.leastsq fit using
> the Student's t distribution and NOT the bootstrapping method?
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
if you mean the confidence interval for the parameter estimates
formula and calulation for the covariance matrix of the parameter
estimate is in optimize curvefit
bse = np.sqrt(np.diag(cov)
confint = params + np.array([-1, +1]) * stats.t.ppf(alpha/ 2) * bse[:,None]
(from scikits.statsmodels LikelihoodModel confint: )
lower = self.params[cols] - dist.ppf(1-\
alpha/2,self.model.df_resid) * bse[cols]
upper = self.params[cols] + dist.ppf(1-\
alpha/2,self.model.df_resid) * bse[cols]
there is also a scikits.statsmodels.miscmodels.NonlinearLS which is
similar to scipy.optimize curvefit but a class with all regression
results using the gradient information. Caution: doesn't have complete
test suite yet, only partially tested on some examples.
If you mean confidence interval for prediction, then I'm not
completely sure the analogy to the linear models works unchanged.
Josef
More information about the SciPy-User
mailing list