Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default How to put coefficients of trend line into spreadsheet?

I fit a 4th-order polynomial curve to data in a chart
and chose the option to display the equation. But when
I put that equation into cells in the spreadsheet, the
evaluated formula does not even come close to the
original Y values, even though I am usin the same X
values. I wonder if it is due to round-off error in
the displayed equation.

How can I get the exact coefficients of a trend line
-- specifically a polynomial of any order -- into a
spreadsheet?

PS: Is it mathematically true that there is always an
N-order polynomial that exactly fits N+1 data points?
That has been my experience so far.

  #2   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default

Hi,

Maybe there is a direct way of getting the coefficients from the trendline
equation for a nonlinear fit; I am not aware of any. The following approach
which uses the Solver utility in Excel, however, can do the job.

Let us suppose that the X- values are in A2:A12, and Y-values are in B2:B12,
and you are fitting a 4th order polynomial to your Y-data.
In five helper cells (say D1, E1, F1, G1, and H1) enter 1. (These would be
the initial guess values for the coefficients; let's imagine that D1 contains
the coefficient for the 4th order term, E1 for the 3rd order term, ....., and
H1 contains the zero-order term, the constant).
In a new column, say C2:C12, calculate the Y value for each X value, using
the 4th order polynomial equation.
In C2, =$D$1*A2^4+$E$1*A2^3+$F$1*A2^2+$G$1*A2+$H$1.
Drag the formula down to C12.
Calculate the sum of the squares of the differences between the actual Y and
the calculated Y values (i.e., columns B and C) in a cell, say I1, using the
following formula.
=SUMXMY2(B2:B12,C2:C12) confirm with ENTER.

Now in the Solver, set the "Target Cell" as I1, check "Min", select D1:H1
for "By Changing Cells") and OK. The solver should optimize the
coefficients, by minimizing the sum of the squared deviations.

This method would work for ANY user defined function; so it is particularly
useful for function types that are not available with the trendline utility.

PS: I think that any set of N+1 data points is described by a
clearly-determined Nth order polynomial (since it is system of N+1
simultaneous equations with N+1 unknowns).

Regards,
B. R. Ramachandran

" wrote:

I fit a 4th-order polynomial curve to data in a chart
and chose the option to display the equation. But when
I put that equation into cells in the spreadsheet, the
evaluated formula does not even come close to the
original Y values, even though I am usin the same X
values. I wonder if it is due to round-off error in
the displayed equation.

How can I get the exact coefficients of a trend line
-- specifically a polynomial of any order -- into a
spreadsheet?

PS: Is it mathematically true that there is always an
N-order polynomial that exactly fits N+1 data points?
That has been my experience so far.


  #3   Report Post  
 
Posts: n/a
Default

I wrote:
I fit a 4th-order polynomial curve to data in a chart
and chose the option to display the equation. But when
I put that equation into cells in the spreadsheet, the
evaluated formula does not even come close to the
original Y values, even though I am usin[g] the same X
values. I wonder if it is due to round-off error in
the displayed equation.


I confirmed that the problem is round-off error. When
I format the "data labels", increase the number of
decimal places displayed in the trendline formula and
enter those values manually into the spreadsheet, the
evaluated formula is close.

I still would prefer to access the exact coefficients
without having to transcribe the displayed values
manually.

  #5   Report Post  
 
Posts: n/a
Default

Jerry W. Lewis wrote:
you can compute then directly using the LINEST function
http://www.stfx.ca/people/bliengme/E...Polynomial.htm


Perfect! Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add data points to a scatter plot with trend line Samantha Charts and Charting in Excel 3 April 3rd 23 04:16 PM
Trend Line - break bob Excel Worksheet Functions 1 June 29th 05 09:24 PM
Trend line AndreasN Charts and Charting in Excel 2 February 12th 05 07:37 PM
trend line does not appear JB Charts and Charting in Excel 1 January 26th 05 08:24 PM
Code Post: Extract Trendline coefficients who Excel Discussion (Misc queries) 2 January 10th 05 11:36 PM


All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"