Message Boards Message Boards

How can I recreate my equation within my following function

Posted 10 years ago

I want my function to take arguments that describe a 3D plane and take in data from a 3D table, my function is really wrong and I need help with it.

I would then like the program to output the equation for the plane so it will show in the Plot3D function,

I want in thesame box for the table Datas plot points with residuals going down or up to the plane

The equation i have is to sum the residuals I have this r (i) = z (i) - ax (i) - by (i) - c, where i is the table x y z data, better explained in my function

This function must sum up the residuals, I will show you what I have so far, the program and the table data are attached to this post:

First I get each column of the table data

t1 = Table[tp[[i]], {i, 2, Length[tp]}]    
xi = Table[t1[[i]][[1]], {i, 1, Length[t1]}];
ymax = Max[xi]; 
yi = Table[t1[[i]][[2]], {i, 1, Length[t1]}];
Max[yi];    
zi = Table[t1[[i]][[3]], {i, 1, Length[t1]}];
xmax = Max[Round[yi]];

Then the function I have is as follows:

DefineRSS[a_, b_, c_, d_] := 
 Block[{output}, output =(ax + by + c);

  rss =(sum[(xi) - ax (ji) - by (ki) - c,{xi,imin,imax},{zj,jmin,jmax},{kj,kmin,kmax}]);
  output]

This function is supposed to sit in manipulate, the idea is for the user to select the plane they want and find out what the sum of the residuals would be:

Manipulate[
 Plot3D[DefineRSS[a, b, c, ?], {x, -10, 10}, {y, -10, 10}, 
  AxesLabel -> {X, Y, Z}], {a, -5, 5}, {b, -5, 5}, {c, -5, 5}]

Show[ListPointPlot3D[t1, PlotStyle -> Red Gray ], 
 Plot3D[fit, {y, 0, ymax}, {x, 0, xmax}] ]

I havent quite got the RSS formulae right, I understand how it is the sum of yi - yi(hat) Im having trouble breaking maths down into sigma style notation or understanding

Attachments:
POSTED BY: jethro holcroft
3 Replies
Posted 10 years ago

After thoroughly review the problem you are having, i suggest you take a closer look at the command FindFit i ask you this recommendation because you'll see examples very related to your example, you will not forget to check the Scope section and other sections.

Luis Ledesma.

POSTED BY: Luis Ledesma
Posted 10 years ago

Hi, jethro holcroft, I didn't have much time to go much into your problem but I am very confused as to what you do, I've done the following but I still do not understand much, would serve too that put a step by step what to do so I can help you more, I agree with you that I have advanced

In[1]:= prb = Import["C:\\Users\\luis\\RegressionExample.xls"];

In[2]:= corr = Rest[Flatten[prb, 1]];

In[3]:= tif = Fit[corr, {1, x, y}, {y, x}];

In[4]:= xmax = Max[corr[[;; , 1]]]

Out[4]= 2271.86

I hope to have helped you although it is a little

POSTED BY: Luis Ledesma
Posted 10 years ago

I made further progress,;

This function here

DefineRSS[a_, b_, c_] := Block[{output}, output = ((a*3) + (b*2) + c);

  rss = (Sum[(zcol[i] - (a*xcol[i] - b*ycol[i] - c))^2, {i, 1, 
      Length[t1]}]);

  output]

I want to be the first argument of Plot3D, I want the arguments of that function to be the sliders that you get from manipulate function, so like this

Manipulate[
 Plot3D[(DefineRss[a, b, c, x, y]), {x, -10, 10}, {y, -10, 10}, 
  AxesLabel -> {X, Y, Z}], {a, -5, 5}, {b, -5, 5}, {c, -5, 5}]

xcol,ycol and zcol are tables zxy in a 3d plot.

What I would lie to know is:

*How do I update the rss value everytime the slider is manipulated

*how do I get the function to output data in such a way that it draws a plane in Plot3D like this little function would:

Manipulate[
 Plot3D[(a*x) + (b*y) + c, {x, 0, 10}, {y, 0, 10}], {a, 0, 5}, {b, 0, 
  5}, {c, -5, 5}]
POSTED BY: jethro holcroft
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract