I have an experimental data set:
data1 = {{71.6`, 0.41`}, {27.2`, 4.96`}, {59.3`, 0.18`}, {46.`,2.72`},
{42.2`, 1.06`}, {89.1`, 3.75`}, {88.6`, 1.9`}, {62.3`,1.8`},
{35.5`,1.84`}}
In order to eliminate unrealistic data points step by step automatically, I fit and plot a relation between data in the two columns as below:
Show[{Plot[Evaluate[lm = Fit[Transpose[{dtx = data1[[All, 1]],
dty = data1[[All, 2]]}], {1,x}, x],
{x, mn = Min[dtx, dty], mx = Max[dtx, dty]},
PlotLabels -> "Expressions"],
PlotRange -> {{Min[dtx],Max[dtx]} , {Min[dty], Max[dty]}}],
ListPlot[Transpose[{dtx, dty}],
PlotStyle ->PointSize[.1],
PlotMarkers -> Automatic,
PlotStyle -> Automatic]},
Axes -> True, GridLines -> Automatic, ImageSize -> 600,
LabelStyle -> Medium, Frame -> True,
FrameLabel -> {{"y", ""}, {"x ", ""}}]
The found relation is: $y = 2.87217 - 0.0138549 x$
I want to use data x in the first column to calculate value y corresponding to the x and compare to the data in the second column. If the absolute relative difference is greater than 10% or absolute difference is greater than 1.5, I want to remove the abnormal data points (row) then refit again and continue to eliminate again. I don't know how to make it run automatically. It is great if each step I can eliminate 2 data points then refit and re-eliminate again. Please advise me on the code.