Functions > Data Analysis > Curve Fitting > Example: Median-Median Regression
  
Example: Median-Median Regression
Use the medfit function to calculate the median-median straight line fit for a data set.
1. Define a data set.
Click to copy this expression
Click to copy this expression
The last point is an outlier:
Click to copy this expression
2. Call the medfit function to find the coefficients of the median-median straight line fit. Use these coefficients to define the median-median line.
Click to copy this expression
Click to copy this expression
3. Call the line function to find the coefficients of the least-squares linear fit. Use these coefficients to define the line of best fit.
Click to copy this expression
Click to copy this expression
4. Plot the data points and the two lines defined above.
Click to copy this expression
The linear fit is much more affected by the outlier than is the median-median fit.