stats[fit, leastmediansquare]
Fit a Curve to data using the least median of squares method
Calling Sequence
Parameters
Description
Examples
References
stats[fit, leastmediansquare[vars]](data)
fit[leastmediansquare[vars]](data)
data
-
list of statistical lists
vars
list of variables, corresponding, in order, to the lists in data
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 x,y implies fitting to the equation y=a⁢x2+b⁢x+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.
with⁡stats:
data≔convert⁡linalgtranspose⁡1,3,2,4,3,5,1,2,listlist:
fitleastmediansquarex,y⁡data
y=x+2
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
data≔convert⁡linalgtranspose⁡1,3,2,4,3,5,1,Weight⁡2,4,listlist:
x=1
Rousseeuw, P. J. "Least Median of Squares Regression." Journal of the American Statistical Association, (December 1984): 871-880.
See Also
describe(deprecated)[linearcorrelation]
Statistics
Download Help Document