Line of worst fit !

Getafix1066

Board Regular
Joined
May 15, 2016
Messages
57
Line of best fit that isn’t.

Have a look at this graph. It shows the latitude and longitude of a paraglider circling whilst drifting over the ground….
185x135.png


(if I’ve clicked the correct buttons, a good quality image of the graph called ‘LineOfworstFit.png’ should be here http://ge.tt/1cadawo2 )

The image clearly shows that a line-of-best-fit (aka a trend line) should be almost vertical (north-south), but the trend line added by excel is at a 45 degree angle (as shown)

After much head scratching I figured out why – it’s because the scales on the each axis aren’t equal, basically one unit of latitude on the vertical scale (Y) represents a different distance to one unit of longitude on the horizontal scale (X)

My question is - how to create a line-of-best-fit that matches the drift of the aircraft? The graph itself isn't complex, and the trend line function is performing correctly, but the result doesn't match the 'common sense' result expected.

(a simple spreadsheet containing the data and the graph is available at the above link)

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,074
I think this is what you want.

You want to calculate your own trend line and add it as a second series. The x values will be the latitude and the y values will be the longitude.

H2cKNaQ.png


In I5: =SLOPE(B6:B128, C6:C128)
In I6: =INTERCEPT(B6:B128, C6:C128)

F6 and F7 are manually entered; the latitude points were chosen to lie just above and below the collected values.

In E6: =$I$5*F6+$I$6
In E7: =$I$5*F7+$I$6

Chart the original data as a scatter plot.
Copy E5:F7.
Select the chart.
From the Home tab, select the dropdown menu below the large Paste icon then select "Paste Special...".
The selections on the popup menu should be:

3dkEuK7.png


Format as you would wish:

a6v98eb.png


My workbook: https://www.dropbox.com/s/pyx1tdyvnaohlgm/aircraft_drift.xlsx?dl=0
 

Getafix1066

Board Regular
Joined
May 15, 2016
Messages
57
Thanks thisoldman,

The line you've plotted is exactly what I wanted - except that I need to do it automatically! The method proposed relies on the manual selection of the two points at the end of the orange line (unless I've mis-understood).

I've done some more reading since my original post. The excel trend-line relies on something called the least-squares method, which (apparently) won't provide good fits for vertical data points. What I'm still trying to find out is how to do what you've shown automatically.

Thank you
 

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,074
If you switch latitude and longitude axes, the Excel chart trendline will work as you want. But you will create confusion for the viewer as latitude and longitude are not as they would appear on a map. See the second tab in my uploaded workbook. The slope and intercept functions do use a least-squares method, the same as clicking the option for a chart.

To automate the chart, use a scatterplot with two series. Where I manually selected the two points for the end points of the trend line, use the max and min of the latitude.

F6: =MIN(C6:C128)
F7: =MAX(C6:C128)

See the new third tab in my uploaded workbook.
If you want to do this automatically for a varying count of positional data, say up to 500 points, we can use a dynamic range to calculate the minimum and maximum latitudes.

F6: =MIN(C6:INDEX(C6:C506, COUNT(C6:C506)))
F7: =MAx(C6:INDEX(C6:C506, COUNT(C6:C506)))

I show this dynamic range formula on the third tab of the worksheet also.
 
Last edited:

Getafix1066

Board Regular
Joined
May 15, 2016
Messages
57

ADVERTISEMENT

Thanks thisoldman,

I've re-read your post, and (if I understand correctly) excel will return different values of SLOPE() and INTERCEPT() depending on which axis is treated as 'x' and which as 'y' - so switching the two axis around you get a better fit.

But there still remains the question of how to do this automatically? - if the wind is blowing from east to west then the fixes will be spread from left to right, and the first method for finding the trend line is probably best, but in other cases (north/south) then the 2nd method is better
 

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,074
If you are OK with a separate series for the trend line, we can automate which trend line is displayed using formulas.

I do use named formulas to create dynamic ranges for the collected latitude and longitude data.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">Original Data</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Trend Line</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="text-align: right;background-color: #EBEBEB;;">Longitude</td><td style="text-align: right;background-color: #EBEBEB;;">Latitude</td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #EBEBEB;;">Longitude</td><td style="text-align: right;background-color: #EBEBEB;;">Latitude</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.713917</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.9351</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.713131</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.934167</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.712917</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93505</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71275</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.939483</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.712617</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.934983</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.712333</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.9349</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E6</th><td style="text-align:left">=IF(<font color="Blue">ABS(<font color="Red">MAX(<font color="Green">Latitude</font>) - MIN(<font color="Green">Latitude</font>)</font>) > ABS(<font color="Red">MAX(<font color="Green">Longitude</font>) - MIN(<font color="Green">Longitude</font>)</font>),
SLOPE(<font color="Red">Longitude, Latitude</font>) * MIN(<font color="Red">Latitude</font>) + INTERCEPT(<font color="Red">Longitude, Latitude</font>),
MIN(<font color="Red">Longitude</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">F6</th><td style="text-align:left">=IF(<font color="Blue">ABS(<font color="Red">MAX(<font color="Green">Latitude</font>) - MIN(<font color="Green">Latitude</font>)</font>) < ABS(<font color="Red">MAX(<font color="Green">Longitude</font>) - MIN(<font color="Green">Longitude</font>)</font>),
SLOPE(<font color="Red">Latitude, Longitude</font>) * MIN(<font color="Red">Longitude</font>) + INTERCEPT(<font color="Red">Latitude, Longitude</font>),
MIN(<font color="Red">Latitude</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E7</th><td style="text-align:left">=IF(<font color="Blue">ABS(<font color="Red">MAX(<font color="Green">Latitude</font>) - MIN(<font color="Green">Latitude</font>)</font>) > ABS(<font color="Red">MAX(<font color="Green">Longitude</font>) - MIN(<font color="Green">Longitude</font>)</font>), SLOPE(<font color="Red">Longitude, Latitude</font>) * MAX(<font color="Red">Latitude</font>) + INTERCEPT(<font color="Red">Longitude, Latitude</font>), MAX(<font color="Red">Longitude</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">F7</th><td style="text-align:left">=IF(<font color="Blue">ABS(<font color="Red">MAX(<font color="Green">Latitude</font>) - MIN(<font color="Green">Latitude</font>)</font>) < ABS(<font color="Red">MAX(<font color="Green">Longitude</font>) - MIN(<font color="Green">Longitude</font>)</font>),
SLOPE(<font color="Red">Latitude, Longitude</font>) * MAX(<font color="Red">Longitude</font>) + INTERCEPT(<font color="Red">Latitude, Longitude</font>),
MAX(<font color="Red">Latitude</font>)</font>)</td></tr></tbody></table></td></tr></table><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Workbook Defined Names</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Name</th><th style="text-align:left">Refers To</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Latitude</th><td style="text-align:left">=Sheet1!$C$6:INDEX(<font color="Blue">Sheet1!$C$6:Sheet1!$C$506,COUNT(<font color="Red">Sheet1!$C$6:Sheet1!$C$506</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Longitude</th><td style="text-align:left">=Sheet1!$B$6:INDEX(<font color="Blue">Sheet1!$B$6:Sheet1!$B$506,COUNT(<font color="Red">Sheet1!$B$6:Sheet1!$B$506</font>)</font>)</td></tr></tbody></table></td></tr></table><br />
New workbook: https://www.dropbox.com/s/fshon0pmbpd7xfi/aircraft_drift_v2.xlsx?dl=0
 
Last edited:

Getafix1066

Board Regular
Joined
May 15, 2016
Messages
57

ADVERTISEMENT

Thank you for your help thisoldman.

What I've learnt elsewhere is that the SLOPE() and INTERCEPT() functions use 'least squares' regression which depends on which set of data you specify as the X and Y axis.

Apparently there's something called 'total least squares' regression which is independent of which is the 'x' and 'y' axis, unfortunately there doesn't seem to be a simple excel function to give this.
 

thisoldman

Well-known Member
Joined
Jan 5, 2014
Messages
1,074
Well, that's good. I felt the linear regression would not accurately show the drift. I avoided showing my misgivings because I assumed a proper solution would require a bunch of trigonometry and array formulas. It turns out, we can use Excel statistical functions to determine the total least squares.

I used the method shown by Charles Zaiontz at "Real Statistics Using Excel", http://www.real-statistics.com/regression/total-least-squares/.

Again I used named formulas for Latitude and Longitude. I also used a bunch of named cells—I needed to follow the formula logic and named formulas make that much easier than using Excel references. To reduce complexity, I did not combine formulas, even though the opportunities to do so may seem obvious.

The solution I came up with is similar to my last post—the trend line is a second series. To make the trend line display stay within the limits of the observed data, so that reasonable axes limits are maintained, I created a trend line takes into account the relative sizes of the latitude and longitude ranges. This means if the longitude range is greater than the latitude range, I use longitude as the independent variable, the x value in the line formula y = mx + b. If the latitude range is greater, latitude is used as the x in y = mx + b.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style=";">Original Data</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Trend Line</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="border-bottom: 1px solid black;;">Calculations</td><td style="text-align: right;border-bottom: 1px solid black;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style="text-align: right;background-color: #EBEBEB;;">Longitude</td><td style="text-align: right;background-color: #EBEBEB;;">Latitude</td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #EBEBEB;;">Lon</td><td style="text-align: right;background-color: #EBEBEB;;">Lat</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Minimum Longitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71415</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71392</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.9351</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71324</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93417</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Maximum Longitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.711767</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71292</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93505</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.7126</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93948</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Longitude Range</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">0.002383</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">11</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71262</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93498</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Minimum Latitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.934167</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">12</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71233</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.9349</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Maximum Latitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.939483</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">13</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.7122</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93475</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Latitude Range</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">0.005316</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">14</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71215</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93457</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Mean Longitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71292197</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">15</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71223</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.9344</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Mean Latitude</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93682446</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">16</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71248</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93423</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Observations</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">120</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">17</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71282</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93417</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Independent Variable</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Latitude</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">18</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71322</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93417</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">W_</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.00017971</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">19</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71362</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93427</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">R_</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">4.38389E-05</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">20</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.7141</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.93473</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Slope</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">0.120211916</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">21</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-0.71413</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">53.935</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #EBEBEB;;">Intercept</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">-7.19677099</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E9</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", MinLongitude, TrendSlope * MinLatitude + TrendIntercept</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">F9</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", TrendSlope * MinLongitude + TrendIntercept, MinLatitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E10</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", MaxLongitude, TrendSlope * MaxLatitude + TrendIntercept</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">F10</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", TrendSlope * MaxLongitude + TrendIntercept, MaxLatitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I8</th><td style="text-align:left">=MIN(<font color="Blue">Longitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I9</th><td style="text-align:left">=MAX(<font color="Blue">Longitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I10</th><td style="text-align:left">=ABS(<font color="Blue">MaxLongitude - MinLongitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I11</th><td style="text-align:left">=MIN(<font color="Blue">Latitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I12</th><td style="text-align:left">=MAX(<font color="Blue">Latitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I13</th><td style="text-align:left">=ABS(<font color="Blue">MaxLatitude - MinLatitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I14</th><td style="text-align:left">=AVERAGE(<font color="Blue">Longitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I15</th><td style="text-align:left">=AVERAGE(<font color="Blue">Latitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I16</th><td style="text-align:left">=COUNT(<font color="Blue">Longitude</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I17</th><td style="text-align:left">=REPT(<font color="Blue">"Longitude", LonRange > LatRange</font>) & REPT(<font color="Blue">"Latitude", LonRange <= LatRange</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I18</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", DEVSQ(<font color="Red">Latitude</font>) - DEVSQ(<font color="Red">Longitude</font>), DEVSQ(<font color="Red">Longitude</font>) - DEVSQ(<font color="Red">Latitude</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I19</th><td style="text-align:left">=2 * COVARIANCE.P(<font color="Blue">Longitude, Latitude</font>) * Observations</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I20</th><td style="text-align:left">=(<font color="Blue">W_ + SQRT(<font color="Red">W_^2 + R_^2</font>)</font>) / R_</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">I21</th><td style="text-align:left">=IF(<font color="Blue">IndepVar = "Longitude", MeanLat - MeanLon * TrendSlope, MeanLon - MeanLat * TrendSlope</font>)</td></tr></tbody></table></td></tr></table><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Workbook Defined Names</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Name</th><th style="text-align:left">Refers To</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">IndepVar</th><td style="text-align:left">=Sheet1!$I$17</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Latitude</th><td style="text-align:left">=Sheet1!$C$6:INDEX(<font color="Blue">Sheet1!$C$6:Sheet1!$C$506,COUNT(<font color="Red">Sheet1!$C$6:Sheet1!$C$506</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">LatRange</th><td style="text-align:left">=Sheet1!$I$13</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Longitude</th><td style="text-align:left">=Sheet1!$B$6:INDEX(<font color="Blue">Sheet1!$B$6:Sheet1!$B$506,COUNT(<font color="Red">Sheet1!$B$6:Sheet1!$B$506</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">LonRange</th><td style="text-align:left">=Sheet1!$I$10</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MaxLatitude</th><td style="text-align:left">=Sheet1!$I$12</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MaxLongitude</th><td style="text-align:left">=Sheet1!$I$9</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MeanLat</th><td style="text-align:left">=Sheet1!$I$15</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MeanLon</th><td style="text-align:left">=Sheet1!$I$14</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MinLatitude</th><td style="text-align:left">=Sheet1!$I$11</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">MinLongitude</th><td style="text-align:left">=Sheet1!$I$8</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Observations</th><td style="text-align:left">=Sheet1!$I$16</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">R_</th><td style="text-align:left">=Sheet1!$I$19</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">TrendIntercept</th><td style="text-align:left">=Sheet1!$I$21</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">TrendSlope</th><td style="text-align:left">=Sheet1!$I$20</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">W_</th><td style="text-align:left">=Sheet1!$I$18</td></tr></tbody></table></td></tr></table><br />
ZRfq72m.png


New workbook at: https://www.dropbox.com/s/bdnluvqptvi612r/aircraft_drift_v3.xlsx?dl=0
 

Getafix1066

Board Regular
Joined
May 15, 2016
Messages
57
Thanks @thisoldman - following some of your earlier tips I to had come across real-statistics.com and had been adapting it to use 'total least squares'. I had hoped (as per my other recent post on this forum) that the total least squares technique would be a standard excel feature, but apparently not! Thanks again.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,983
Messages
5,639,380
Members
417,084
Latest member
elitepaper

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top