 fit(deprecated)/leastmed - Maple Help

stats[fit, leastmediansquare]

Fit a Curve to data using the least median of squares method Calling Sequence stats[fit, leastmediansquare[vars]](data) fit[leastmediansquare[vars]](data) Parameters

 data - list of statistical lists vars - list of variables, corresponding, in order, to the lists in data Description

 • Important: The stats package has been deprecated. Use the superseding package Statistics instead.
 • The function leastmediansquare of the subpackage stats[fit, ...] fits a curve to the given data using the method of least median of squares.
 • The equation to fit will be linear (affine) in the unknown parameters. The equation itself need not be linear. For example, specifying vars to be $\left[x,y\right]$ implies fitting to the equation $y=a{x}^{2}+bx+c$.
 • The well-known least square regression method suffer from leverage points. By adding a single point to the data, one can change the result to an arbitrary extent. The least median of squares method allows one to add up to half the number of points without changing the result. The price to pay for this robustness is a substantial increase in computation cost.
 • Missing data  and ranges cannot be handled.
 • Weighted data are handled in the following fashion. The weight associated with the dependent variable is the weight given to the corresponding point. The weight specifications corresponding to the independent variables are ignored.
 • The command with(stats[fit],leastmediansquare) allows the use of the abbreviated form of this command. Examples

Important: The stats package has been deprecated. Use the superseding package Statistics instead.

 > $\mathrm{with}\left(\mathrm{stats}\right):$
 > $\mathrm{data}≔\mathrm{convert}\left({\mathrm{linalg}}_{\mathrm{transpose}}\left(\left[\left[1,3\right],\left[2,4\right],\left[3,5\right],\left[1,2\right]\right]\right),\mathrm{listlist}\right):$
 > ${\mathrm{fit}}_{{\mathrm{leastmediansquare}}_{\left[x,y\right]}}\left(\mathrm{data}\right)$
 ${y}{=}{x}{+}{2}$ (1)

This is calculated as follows. For example, pick two points, say [1,3] and [2,4]. Pass a straight line through them. In this case it is y=2+x. For each point compute the square of the distance of the line to the point This gives [0,0,0,sqrt(2)/2]. Find the median through these distances: this gives 0. Now minimize over all possible lines. This is the result.

Here's an example using Weight

 > $\mathrm{data}≔\mathrm{convert}\left({\mathrm{linalg}}_{\mathrm{transpose}}\left(\left[\left[1,3\right],\left[2,4\right],\left[3,5\right],\left[1,\mathrm{Weight}\left(2,4\right)\right]\right]\right),\mathrm{listlist}\right):$
 > ${\mathrm{fit}}_{{\mathrm{leastmediansquare}}_{\left[x,y\right]}}\left(\mathrm{data}\right)$
 ${x}{=}{1}$ (2) References

 Rousseeuw, P. J. "Least Median of Squares Regression." Journal of the American Statistical Association, (December 1984): 871-880.