Closed Thread
Results 1 to 11 of 11

Best fit plane in Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Red face Best fit plane in Excel

    Hi, there
    Does anyone have the code to get a best fit plane in VBA?

    Thanks.
    Best regards,
    Lily
    Last edited by SpringLily; 01-13-2011 at 04:21 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Best fit plane in Excel

    Best-fit plane to a bunch of points {x,y,z}? You can use LINEST to regress z=ax+by+c. Post a workbook if you need help.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Best fit plane in Excel

    Thanks, shg. Please see the attached.
    Attached Files Attached Files

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Best fit plane in Excel

    Like this:
           --D--- ---E--- ---F--- G --H-- --------------------I--------------------
       6     x       y       z       fit                                           
       7       12      53      98   71.22 H7 and down: =$E$15*D7 + $D$15*E7 + $F$15
       8       12      76      87   82.28                                          
       9       41      89      54   69.18                                          
      10       63      87      78   53.55                                          
      11       34      56       9   57.99                                          
      12       45      23      43   34.79                                          
      13                                                                           
      14                                                                           
      15   0.4808 -0.6670 53.7416         D15:F15: {=LINEST(F7:F12, D7:E12)}
    Note that (1) D15:F15 is an array formula, (2) the coefficients appear in the order opposite the arguments in LINEST, and (3) it's not a great fit.

  5. #5
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Best fit plane in Excel

    Thanks, shg. Are you happy to send me the Spreadsheet with formula in. Best regards, Lily.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Best fit plane in Excel

    In your workbook, select D15:F15

    Paste =LINEST(F7:F12, D7:E12) in the formula bar, but DON'T press Enter. Instead, press and hold the Ctrl and Shift keys, then press Enter.

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    Netanya, Israel
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Best fit plane in Excel

    Hi,
    If the data points are in an X-Y array: (example)
    1 2 3 4
    1 0 -1 0 -2
    2 1 -2 0 0
    3 2 1 1 -1
    How can I use the LINEST function?
    Thanks,
    Amit

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Best fit plane in Excel

    Amit,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Registered User
    Join Date
    03-07-2024
    Location
    london
    MS-Off Ver
    365
    Posts
    1

    Re: Best fit plane in Excel

    How do you plot this in 3D?

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,106

    Re: Best fit plane in Excel

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #1 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1