[AstroPy] Fit statistics in astropy.fitting

Erik Bray embray at stsci.edu
Tue Jul 7 14:15:58 EDT 2015


On 07/07/2015 01:28 PM, José Vinícius wrote:
> Hey,
>
> I'm not sure, but I think there exists an implementation for the covariance
> matrix (in astropy.fitting), so that the diagonal of this matrix gives you the
> variance of the estimator for each parameter that you are fitting.

Some of the fitters do this.  For example, any fitter that uses 
scipy.optimize.leastsq (i.e. LevMarLSQFitter) has this since leastsq returns a
cov_x [1] array that can be converted to the covariances (which LevMarLSQFitter 
does and stores of in a 'param_cov' key in the fit_info dict.

As was discussed at the Python in Astronomy workshop later this year, a goal for 
the astropy.modeling fitting framework should be as a glue between different 
fitting / optimization packages.  It sort of already works this way, by 
providing wrappers around (some of) scipy.optimize, though there's no reason it 
can't wrap other code as well (we discussed what it would take to integrate 
Sherpa into the framework for example).

Part of this "glue" would include improving the handling of various fit 
statistics and provide a reasonably common (and less cryptic) interface between 
fitters.  So while scipy.optimize.leastsq makes it easy to return a covariance 
matrix for the fitted parameters, other optimizers might require more work (this 
has been discussed a little bit such as in this issue: [2])  But either way the 
user interface to getting the cov matrix (just as an example) should be the same 
between "fitters"  It would be great to see more progress on issues like that.

It would also be great to collect more concrete requirements on this.

Also following that meeting there has been a flurry of activity adding various 
statistical tests to the astropy.stats package [3] [4].  The next logical step 
with these is to integrate them more tightly into astropy.modeling.fitting.

Erik


[1] 
http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.optimize.leastsq.html

[2] https://github.com/astropy/astropy/issues/1055

[3] https://github.com/astropy/astropy/pulls?q=label%3Astats+is%3Apr+is%3Aopen

[4] https://github.com/astropy/astropy/issues?q=label%3Astats+is%3Aopen+is%3Aissue

>
> CVLattes: http://lattes.cnpq.br/3267230342393209
>
> On Tue, Jul 7, 2015 at 10:25 AM, Thøger Emil Rivera-Thorsen <trive at astro.su.se
> <mailto:trive at astro.su.se>> wrote:
>
>     This may be me having missed something, but is it not possible to get
>     fit statistics - goodmes-of-fit, confidence intervals etc. - from a
>     fitter in astropy.fitting?
>     I have usually been using LMFit for this kind of task, but
>     Astropy.modelling and astropy.fitting seem much quicker and simpler to
>     use - but I cannot seem to get fit statistics from the fitter anywhere.
>
>     Am I missing something or is it simply not implemented?
>
>
>     Emil Rivera-Thorsen
>     Ph.D. candidate, Astronomy
>     Stockholm University
>     Sweden
>     _______________________________________________
>     AstroPy mailing list
>     AstroPy at scipy.org <mailto:AstroPy at scipy.org>
>     http://mail.scipy.org/mailman/listinfo/astropy
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>




More information about the AstroPy mailing list