The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Finding a Best-Fit Regression Plane

Date: 12/15/2005 at 12:31:37
From: Brad
Subject: Best Fit Regression Planes

Dr. Math,

I have a height map of a certain terrain where the x and y values are
fixed.  The dataset is in the form of a spreadsheet.  The spreadsheet
program I used was able to calculate my best-fit slopes in the x and y
directions, but I cannot figure out how to combine these slopes into a
unique best-fit regression plane.  I want the regression plane to
minimize only the z distances from my original points; the x and y
points will remain fixed.

So far, I have been able to figure the best fit of the plane for x and
y.  What I'm trying to figure out is with the best fit data, where
does one start to create a plane?

Date: 12/16/2005 at 06:57:57
From: Doctor George
Subject: Re: Best Fit Regression Planes

Hi Brad,

Thanks for writing to Doctor Math.

Let your N points be (xi,yi,zi) and let your plane be

     z = f(x,y) = a*x + b*y + c

We want to find a, b and c such that

     g(a,b,c) = SUM[(a*xi + b*yi + c - zi)^2]

is minimized.

Now take the partial derivative of g with respect to a and set it 
equal to zero.  Do the same for b and c.  This will give you three
linear equations to solve for a, b and c.

You can make it even more compact if you recognize that the partial
derivative with respect to c leads to the conclusion that the
regression plane contains the centroid of the data.  Then you can
write the plane as

     z = f(x,y) = a*(x-xo) + b*(y-y0) + z0

where (x0,y0,z0) is the centroid.  Now you just need to solve for a
and b in the same way described above.

Does that make sense?  Write again if you need more help.

- Doctor George, The Math Forum 
Associated Topics:
College Higher-Dimensional Geometry
High School Higher-Dimensional Geometry

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.