Statistics - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Quantities : Statistics/RepeatedMedianEstimator

Statistics

  

RepeatedMedianEstimator

  

compute the repeated median estimator

 

Calling Sequence

Parameters

Description

Notes

Examples

References

Compatibility

Calling Sequence

RepeatedMedianEstimator(X, Y, v)

RepeatedMedianEstimator(XY, v)

Parameters

X

-

values of independent variable(s)

Y

-

values of dependent variable

XY

-

values of independent and dependent variables

v

-

algebraic expression in which to express the result

Description

• 

The RepeatedMedianEstimator function computes a robust linear estimator from a collection of points in the plane. It is a quantity first described by Siegel [2], using an algorithm described by Matoušek, Mount, and Netanyahu [3].

• 

The repeated median estimator is a robust estimator. This means that it will continue to perform well if some points are replaced by outliers. Least-squares linear regression, the type of regression most commonly used and implemented by LinearFit and NonlinearFit, is very susceptible to outliers.

• 

Conceptually, one obtains the repeated median estimator by computing, for each data point P, the slopes of the lines connecting P to every other point, and then taking the median of those slopes. Then, one takes the median of these median slopes as P ranges over all data points. This gives the slope s for the repeated median estimator.

• 

Then one computes for all points P the intercept that would have the line with slope s going through P. The intercept for the repeated median estimator is the median of these intercepts.

• 

The repeated median estimator has a breakdown point of 12. This means that when less than half of all data points in a sample are changed, the value of the repeated median estimator at a given value can change only a limited amount.

• 

In the first calling sequence, the parameter X is a Vector (or a k-by-1 Matrix, or a list) containing the values of the independent variables. The ith element is the independent value for the ith data point. The parameter Y is a Vector containing the k values of the dependent variable, in the same way. Alternatively, these values can be specified in a single k-by-2 Matrix, XY, by using the second calling sequence.

• 

The returned value is an expression representing the estimator evaluated at the value v. By supplying a variable name here, you obtain the general expression for the estimator. If you supply a number, you obtain the value of the estimator at that number.

Notes

• 

The underlying computation is done in floating-point; therefore, all data points must have type realcons and all returned solutions are floating-point, even if the problem is specified with exact values.  For more information about numeric computation in the Statistics package, see the Statistics/Computation help page.

Examples

withStatistics:

Suppose we have a set of points in the plane where the X-coordinate is generated uniformly from the interval 1..1, and the Y-coordinate is given by y=2.4x+0.9+noise, with the noise coming from the Cauchy0,1 distribution. This typically generates serious outliers.

N1000

N1000

(1)

xvaluesSampleUniform1,1,N

xvalues 1 .. 1000 Vector[row]Data Type: float[8]Storage: rectangularOrder: Fortran_order

(2)

yvalues`~`[:-`+`]2.4xvalues+SampleCauchy0,1,N,` $`,0.9

yvalues 1 .. 1000 Vector[row]Data Type: float[8]Storage: rectangularOrder: Fortran_order

(3)

pointsPointPlotyvalues,'xcoords'=xvalues,'color'='green':points

We shrink the view a little, so that we can see more of what's going on.

pointsplots:-displaypoints,'view'=1..1,3..5:points

Now we would like to find the model y=2.4x+0.9 from the data. Using standard (least-squares) linear regression, we get an unsatisfactory fit:

leastsquaresFitax+b,xvalues,yvalues,x

leastsquares5.35146588080964x6.16980901266835

(4)

plots:-displaypoints,plotleastsquares,x=1..1,'thickness'=3

The repeated median estimator, however, deals well with the errors.

repeatedmedianRepeatedMedianEstimatorxvalues,yvalues,x

repeatedmedian0.958872442473601+2.42820627384362x

(5)

plots:-displaypoints,plotleastsquares,repeatedmedian,x=1..1,'thickness'=3,'legend'=least squares,repeated median

In the following example, we have one outlier in the data.

xydata0,11,1,0,2,8,3,9,4,8,5,4,6,4,7,3,8,4,9,0,10,1

xydata0,11,1,0,2,8,3,9,4,8,5,4,6,4,7,3,8,4,9,0,10,1

(6)

pointsPointPlotxydata..,2,'xcoords'=xydata..,1,'color'='green'

points

Once again, we compare the least squares and repeated median estimators.

leastsquaresFitax+b,xydata,x

leastsquares0.799999999999999x+8.54545454545454

(7)

repeatedmedianRepeatedMedianEstimatorxydata,x

repeatedmedian10.1.x

(8)

plots:-displaypoints,plotleastsquares,repeatedmedian,x=0..10,'legend'=least squares,repeated median

In this case, the difference is less dramatic than in the first example. It is clear, though, that the outlier has very little influence on the repeated median estimator, and some influence on the least squares fit.

References

  

[1] Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.

  

[2] Siegel, Andrew F. Robust Regression Using Repeated Medians. Biometrika 69 (1), 1982, pp.242-244.

  

[3] Matoušek, Jiří, Mount, David, and Netanyahu, Nathan. Efficient Randomized Algorithms for the Repeated Median Line Estimator. Algorithmica 20 (2), 1998, pp.136-150.

Compatibility

• 

The Statistics[RepeatedMedianEstimator] command was introduced in Maple 2015.

• 

For more information on Maple 2015 changes, see Updates in Maple 2015.