+ Reply to Thread
Results 1 to 5 of 5

Excel Formula to regression fit Cubic polynomial

  1. #1
    Registered User
    Join Date
    03-30-2013
    Location
    Troy, Mi, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Excel Formula to regression fit Cubic polynomial

    Hi,

    I am using the following function to do the curve fitting.

    =INDEX(LINEST($G9:$G22,$F9:$F22^{1,2,3}),1,1)

    It works most times but not for certain data.
    And there is a mismatch between the trendline (polynomial cubic) and the values returned by the function for this data set.

    Attached is a sample data set.
    Also, whenever this happens, the C term or coefficient of X term goes to zero from function calculation.

    Any pointers to the issue, most welcome.

    Thank you in advance.
    Attached Files Attached Files

  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: Excel Formula to regression fit Cubic polynomial

    You're doing the regression four times, which is Excel abuse. Select I34:L34, paste

    =LINEST($G9:$G22,$F9:$F22^{1,2,3})

    ... in the formula bar, and confirm with Ctrl+Shift+Enter.

    For whatever reason, charts and LINEST do polynomial regression differently. The chart gives R2 of 0.9843, LINEST 0.9697
    Last edited by shg; 03-31-2013 at 10:53 AM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-20-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel Formula to regression fit Cubic polynomial

    For whatever reason, charts and LINEST do polynomial regression differently. The chart gives R2 of 0.9843, LINEST 0.9697
    The reason is to do with how Excel handles collinearity, according to MS Help:

    "...The LINEST function checks for collinearity and removes any redundant X columns from the regression model when it identifies them. Removed X columns can be recognized in LINEST output as having 0 coefficients in addition to 0 se values...."

    Essentially the problem is that forming a polynomial basis of the x values leads to linear combinations of values that cannot be distinguished given the 15 digit precision. To correct for this center the data around the mean by replacing x by (x-average(x)):

    =LINEST(G9:G22,(F9:F22-AVERAGE(F9:F22))^{1,2,3},1,1)

    This gives the same x³ value and R² value as the chart trendline.

    To recover the other coefficients post-multiply by the matrix of binomial terms, i.e. enter using CTRL+SHIFT+ENTER in a 4 column range:

    =MMULT(LINEST(G9:G22,(F9:F22-AVERAGE(F9:F22))^{1,2,3}),IFERROR(COMBIN({3;2;1;0},{3,2,1,0})*(-AVERAGE(F9:F22))^({3;2;1;0}-{3,2,1,0}),0))

  4. #4
    Registered User
    Join Date
    03-30-2013
    Location
    Troy, Mi, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Excel Formula to regression fit Cubic polynomial

    Hi Lori_m,

    Thanks for the reply.

    Was able to use the first function and get X^3 term, but couldn't figure out how to use the 2nd equation.
    Can you pls explain what Ctrl+Shift+Enter in the 4 column range means and how to use/key-in the second equation.

    Thank you.

  5. #5
    Registered User
    Join Date
    03-30-2013
    Location
    Troy, Mi, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Excel Formula to regression fit Cubic polynomial

    Thanks Lori_m and shg, got it working.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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