MPFITMPFITEXY and MPFITEXY2 are two IDL routines
written by Michael Williams. To use them:
Download and install MPFIT
Place the files mpfitexy.pro and/or
mpfitexy2.pro in your IDL path
Calling sequence, usage, etc. is described in each file. These routines have been tested with a relatively narrow set of data, so they may contain bugs or be missing crucial features. Please let me know if this is the case. Questions, comments, bug reports and complaints are welcome at williams@mpe.mpg.de. Notes on the features of these routines follow.
The features of the code are discussed, and relevant literature cited,
in Section 4 of Williams, Bureau & Cappellari
(2010). In
the interests of
reproducibility,
you should either cite that publication (which I would prefer) or refer
to the permanent URL at which MPFITEXY can always be found:
http://purl.org/mike/mpfitexy.
MPFITEXY is dependent on the MPFIT package,
which you must separately acknowledge by citing Markwardt
(2009).
So, you could cite MPFITEXY like this:
We fit a linear relationship to the data using the
MPFITEXYroutine (Williams, Bureau & Cappellari 2010). TheMPFITEXYroutine depends on theMPFITpackage (Markwardt 2009).
or like this
We fit a linear relationship to the data using the
MPFITEXYroutine.1 TheMPFITEXYroutine depends on theMPFITpackage (Markwardt 2009).
MPFITEXYMPFITEXY is a wrapper around Craig Markwardt’s
MPFIT. It finds the
best-fitting straight line through data with errors in both coordinates.
In the absence of intrinsic scatter it minimizes the same figure of
merit at the ASTROIDL
FITEXY
routine, which is itself an implementation of the well known Numerical
Recipes approach to fitting a straight line to data with errors in both
coordinates.
MPFITEXY adds a number of extra features not supported by
FITEXY:
User-specified intrinsic scatter, i.e. the weighting for each data point is of the form (σx2 + β2σy2 + σint2). Intrinsic scatter is physically significant and statistically necessary in situations where, even with perfect data (i.e. no observational errors), the data is scattered about the model. This is the “Nukers’ Estimate” described in Tremaine et al. (2002).
σint is automatically adjusted to ensure
χ2/(degrees or freedom) ≈ 1 (if the optional
/reduce keyword is enabled). This is done using the
iterative procedure described in Section 3.2.1 of Bedregal,
Aragón-Salamanca & Merrifield
(2006).
The inverse relationship is optionally fitted, i.e. y is regressed
onto x, if the inv keyword is enabled. You can of
course do this in FITEXY by swapping round the variables in the
procedure call, but MPFITEXY handles the inversion of the results
and the propagation of errors. Inverse fitting is therefore
completely transparent to the user. See, e.g. Willick
(1994) for the
background to why you might want to fit the inverse relationship.
You can fix the slope or the intercept using the
/fixslope and /fixint keywords.
MPFITEXY2
MPFITEXY2 simultaneously fits straight lines to two sets of data with a
shared slope. It is useful for measuring the offset between the straight
line fits to two samples, while simultaneously using as much information
as possible to constrain their shared slope and zero-point.
The data can have errors in the x and y directions, and intrinsic
scatter. MPFITEXY2 supports all the convenient features supported by
MPFITEXY (optimization of σint, inverse relationship
fitting, fixed slope or intercept – see above).
MPFITEXY2 is an implementation of the minimization problem
described in Section 4 of Williams, Bureau & Cappellari
(2010).
The details of your data will affect whether the assumptions we make are
justified. I urge you to read that short section before depending on the
results of MPFITEXY2. If you find MPFITEXY2
useful, please cite Williams, Bureau & Cappellari
(2010) and
Markwardt (2009).