Skip to main content
1-Visitor
August 2, 2010
Question

How to find correlation coefficient for 3-D polynomial regression

  • August 2, 2010
  • 3 replies
  • 15564 views

Hello all,

I'm working with a set of 3-D data (2 independent variables, 1 dependent value) in which I'm using the regress and interp functions to find a 3rd degree polynomial function to describe it. I have looked through the help and quicksheets and it appears that MathCAD does not automatically calculate the correlation coefficient for such a regression, so I'm wondering if there is something close in definition to a correlation coefficient to help me quantify the accuracy of the best-fit plane. I'm basically trying to quantify the fit difference between a 2nd-order polynomial, 3rd order, and 4th order.

Any help is appreciated!

Attached is a little eye candy of the a best-fit plane and superimposed data.

Best-fit, 3rd order.jpg

3 replies

1-Visitor
August 2, 2010

[deleted content]

. Why not a spline fit for that surface.

Good idea to check thw qs for "Regress",

Minerr ... fit "

jmG

1-Visitor
August 2, 2010

I'm afraid I don't understand your post. I'm trying to figure out how to calculate the correlation coefficient for the best-fit surface, what's the problem? A best-fit spline doesn't help me because:

  1. The 3rd order polynomial fit is obviously an excellent fit. I need to quantify "excellent" however.
  2. I need to take the polynomial equation for the best-fit plane, and use it in the control software for this application. I can't give an interpolated spline equation to the control system!

As for your comment regarding the tags, I simply added some tags to make it easier to find this thread using a keyword search. That's what they're there for...

19-Tanzanite
August 2, 2010

Mech_Engineer wrote:

I'm afraid I don't understand your post.

Don't worry about it. Neither do I

  1. The 3rd order polynomial fit is obviously an excellent fit. I need to quantify "excellent" however.

Be very careful regarding what you mean by "quantify". You can use the correlation coefficient to judge the difference between the quality of different fits to the same data, but do not make the mistake of over interpreting it. For example, you cannot use it to compare different fits of the same function to completely different data.

19-Tanzanite
August 2, 2010

See here:

http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBIQFjAA&url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.79.1143%26rep%3Drep1%26type%3Dpdf&ei=D1ZXTPeNLpCRnwer6KmWAw&usg=AFQjCNGfAGFJk4Vt7gCYV3j8M41xWBmvCw

(long URL!!!)

But I think that's overkill. If you want to compare the difference in the quality of different fits to the same data all you really need is the sum of the squares of the residuals (i.e. sum[(z-fit)^2]).

1-Visitor
August 3, 2010

I think I'll just sum the squares of the residuals. I was hoping there was a built-in function that I could call, but alas there is not.

Thanks for the help Richard.

1-Visitor
August 4, 2010

Mech_Engineer wrote:

I think I'll just sum the squares of the residuals. I was hoping there was a built-in function that I could call, but alas there is not.

Thanks for the help Richard.

The Mathcad built-in ERR is paired with Minerr

jmG

1-Visitor
August 4, 2010

Thanks for the feedback, I'm hoping the polynomial will work for this particular application (but it's possible to see some of the undulating errors you describe in the error plots). The data is positioning output from a Solidworks motion study, so there's no noise in it.

4th degree polynomial error plot (only valid at data points):

Error Plot, 4th order.jpg

Basically I have a tilt-rot table that I'm positioning using two linear actuators attached to it; I need an equation that describes the actuator lengths as a function of tilt and rotation angles of the table. I've thus far been unsuccessful in describing the geometry analytically, so I've gone to using Solidworks and MathCAD to develop an approximation. Due to the required accuracy of the table I need the error of the approximation formula to be less than 0.010" within the space I'll be positioning, which based on my error calculation necessitates a 4th degree polynomial (results in a Root Mean Error of .009", although the error in some areas is as high as .020"). Unfortunately, a 4th (or even 5th) degree fit results in not only a huge equation to put into the control system, but the points used in my regression are not evenly distributed accross the motion space meaning I only "know" I'm accurate at the data lines I'm regressing, and the fit may be undulating between them. I think my next step to minimize this problem is to try getting a more random distribution of points accross the motion space.

I've attached the MathCAD sheets from both the regression, as well as my original attempt at formulating an analytical symbolic solution using a system of equations (25 unknowns) and a Solve block in MathCAD. I suspect the symbolic solution is not solving because I have not yet fully constrained the system; the one I'm missing is "Line DE is always parallel to a plane that is at a known angle from plane ABC," but I haven't figured out how to describe that in an equation for the solve block.

Any feedback you have on either sheet is most welcome. It's nice to get some outside advice

1-Visitor
August 4, 2010

You seem to be at a point of not understanding and not possibly reverse engineering the material you are passing . The CNC will fabricate from a data set, a data set that can come from a mathematical function like the breather or a set of coordinates in the space. The Catmull-Clark being is convex to the hull, no correlation will apply except for you to determine from experimental runs and how fine the meshing must be. Hope some collabs can help, on my side the project does not even exist yet as you have no data set in the space and no function.

jmG

1-Visitor
August 4, 2010

Sorry about that I forgot the Worksheet is linked to an Excel file for the values. I uploaded an updated Worksheet and the excel file it pulls the data from, so as long as you download both files in the same directory it should work.

I can tell that we're communicating accross a language barrier, but I think I'm getting that I can do a cubic spline interpolation which will allow a polynomial interpolation through the data points I have, rather than a regression which does not actually pass through all of the data points provided. I'll try the cubic spline and see if it works for me, thanks!