Multiple Linear Regression and Orthogonal Distance

192 Views Asked by At

Problem

The problem is to measure the Perpendicular Distance of a Retangular Shape.

Problem

Some edge points are taken from the shape and the data below is acquired:

+-----+-----+
|  x  |  y  |
+-----+-----+
| 192 |  52 |
|  69 |  89 |
| 204 |  89 |
|  80 | 126 |
| 216 | 126 |
|  91 | 163 |
| 227 | 163 |
| 102 | 200 |
| 239 | 200 |
| 113 | 237 |
| 250 | 237 |
| 124 | 274 |
| 261 | 274 |
| 135 | 311 |
| 272 | 311 |
| 146 | 348 |
| 284 | 348 |
+-----+-----+

The following points are seen:

Points

Linear Regression

I tried to make a linear regression so the m of y=mx+b would be the same, however, that's what i got:

Linear Regression

Question

How do i get to identify multiple lines and make a linear regression for each one, so that the width can be measured?

Is There another way?

The next step is to have 2 retangular shapes and try to calculate the width.

1

There are 1 best solutions below

0
On BEST ANSWER

Assuming that the points $(x_i,y_i)$ contain errors and that you want the "best" parallel lines, I should introduce another variable $t_i$ which would be $0$ for any point on one edge and $1$ for any point on the other edge.

Now, take all points together and perform the multilinear regression for the model $$y=a+bx+ct$$ When done, select one point along $y=a+bx$ and compute its distance to the line $y=a+bx+c$.

The perpendicular distance will be $$d=\frac{|c|}{\sqrt{1+b^2}}$$ (see here).

Edit

Hoping no mistake, you data are then $$\left( \begin{array}{ccc} x & t & y \\ 192 & 1 & 52 \\ 69 & 0 & 89 \\ 204 & 1 & 89 \\ 80 & 0 & 126 \\ 216 & 1 & 126 \\ 91 & 0 & 163 \\ 227 & 1 & 163 \\ 102 & 0 & 200 \\ 239 & 1 & 200 \\ 113 & 0 & 237 \\ 250 & 1 & 237 \\ 124 & 0 & 274 \\ 261 & 1 & 274 \\ 135 & 0 & 311 \\ 272 & 1 & 311 \\ 146 & 0 & 348 \\ 284 & 1 & 348 \end{array} \right)$$ and the multilinear regression leads to $$y=-135.049+3.28883 \,x-448.788\, t$$ making $d\approx 130.6$