+ Reply to Thread
Results 1 to 2 of 2

find the trend-line coefficients for a 5th order polynomial

  1. #1
    Registered User
    Join Date
    03-04-2014
    Location
    Taiwan
    MS-Off Ver
    Excel 2010
    Posts
    1

    find the trend-line coefficients for a 5th order polynomial

    I try to find the trend-line coefficients for a 5th order polynomial in VBA, using two different methods to find it, but the results are totally different. I have verified the answer, method 1 is the correct one. Then how can I get the correct coefficients by method 2?
    or are there any different method to get the answer?

    y=a5*x^5+a4*x^4+a3*x^3+a2*x^2+a1*x+a0

    method 1:
    .Range("A4:F4").FormulaArray = _
    "=LINEST(R[4]C[3]:R[416]C[3],R[4]C[2]:R[416]C[2]^{1,2,3,4,5})"
    .Range("H4:M4").FormulaArray = _
    "=LINEST(R[4]C[3]:R[392]C[3],R[4]C[2]:R[392]C[2]^{1,2,3,4,5})"

    result 1:
    a5=-7.18753E-10
    a4=2.67996E-07
    a3=-3.28137E-05
    a2=0.001175343
    a1=0.073740487
    a0=-0.242915521


    method 2:
    a5 = WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), Application.Power(.Range("c8:c400").Value, Array(1, 5))), 1)
    a4 = WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), Application.Power(.Range("c8:c400").Value, Array(1, 4))), 1)
    a3 = WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), Application.Power(.Range("c8:c400").Value, Array(1, 3))), 1)
    a2 = WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), Application.Power(.Range("c8:c400").Value, Array(1, 2))), 1)
    a1= WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), .Range("c8:c400")), 1)
    a0= WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), .Range("c8:c400")), 2)

    result 2:
    a5=-2.09188E-11
    a4=-3.77071E-09
    a3=-7.50941E-07
    a2=-0.000194511
    a1=0.049233564
    a0=0.766998923



    Thanks.
    Leeann

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: find the trend-line coefficients for a 5th order polynomial

    Your use of Array is incorrect. What you have is a 2 item array with the values 1 and 5. You need it to be Array(1,2,3,4,5)

    WorksheetFunction.Index(WorksheetFunction.LinEst(.Range("d8:d400"), Application.Power(.Range("c8:c400").Value, Array(1, 2, 3, 4, 5))), 1)
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Trend Line Equation Coefficients
    By Jake in forum Excel General
    Replies: 4
    Last Post: 04-17-2006, 03:50 PM
  2. Replies: 5
    Last Post: 10-09-2005, 09:05 AM
  3. [SOLVED] using linest to generate 3rd order polynomial coefficients
    By Incoherent in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-14-2005, 10:05 AM
  4. higher order polynomial fit line x-coefficients
    By barrfly in forum Excel General
    Replies: 3
    Last Post: 07-12-2005, 05:05 AM
  5. 4th order polynomial trend line coefficients
    By RJS in forum Excel General
    Replies: 3
    Last Post: 03-30-2005, 11:36 AM

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