+ Reply to Thread
Results 1 to 4 of 4

Trendline fits badly

  1. #1
    Registered User
    Join Date
    10-08-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    1

    Trendline fits badly

    Hi all,

    I am trying to fit a trendline to some data given by (x,y)-coordinates which I have plotted in a xy-scatter plot. I fit a exponential trendline which give a formula
    • 5.3234*exp(0.0061x)

    and an R-squared value of 0.911. So far so good. This fitting looks very bad, actually. So I made a least square fitting using the solver and the grg nonlinear solver to optimize the parameters k and h in the expression
    • k*exp(h*x)

    This lead to the expression
    • 36.0210863 * exp(0.003343605*x)
    which yields a R-sqared value of 0.985. That is, a significantly better fitting, with the same function. Does any one of you know how excel fits these trendlines?
    The data are
    x y
    100 3.569225062
    200 17.77877873
    300 63.61274436
    400 89.51683479
    500 169.8632096
    600 292.3772838
    700 410.8622885
    800 568.3814671
    900 756.7649326
    1000 977.6198348

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Trendline fits badly

    I looked around a little bit, but I couldn't find any math-heavy documentation for how trendlines are calculated by excel; if the methodology is published, it's buried under "baby's first trendline"-type blog posts etc.

    Offhand? The number that the linefit used by default may have been too imprecise to capture the data behavior. Or maybe you had better starting values for your 2nd approximation compared to your first; or maybe you told Solver to use more steps than the trendline uses by default. That's all just semi-wild guessing by me, though.
    Click the [* Add Reputation] Button to thank people for help!
    Post Attachment: Click [Go Advanced] under the reply box; then click [Manage Attachments] to launch the attachments dialogue.
    Mark Thread Solved: Go to the top of the first post; Select [Thread Tools] dropdown; Pick the [Mark thread as Solved] option.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,357

    Re: Trendline fits badly

    I am not enough of a statistician to give you the full analysis, but a few notes and observations to prompt your own research and study:

    1) The chart trendlines and the LINEST/LOGEST functions use the same basic linear least squares algorithm. I am not going to remember all of the details correctly off the top of my head, but linear least squares regression comes down to solving a matrix equation like Y=A*X (where Y, A, and X are matrices). The key step in solving for the coefficient matrix is, of course, the matrix inversion algorithm (computer scientist generally argue that QR decomposition is the most efficient, most numerically stable algorithm, and so Excel uses a QR decomposition algorithm).

    2) One key thing to realize when working with exponential equations is recognizing the transformation used to make the function "linear". In the case of y=b*exp(mx), the actual equation that is fed into the linear least squares algorithm is ln(y)=ln(b)+mx. This means that the objective function is really minimize (ln(ymeas)-ln(ycalc))^2. Your analysis of the equation is based on the standard (ymeas-ycalc)^2 objective function -- not the same objective function.

    3) This latter point is an important part of this kind of analysis, and only you as the analyst can decide which is more correct. One of the criticisms of the standard least squares objective function (ymeas-ycalc)^2 is that it tends to strongly favor larger values over smaller values. Your values range from 10ish to 1000ish -- 3 orders of magnitude. I think if you analyzed your results more closely, you will see that your equation shows a strong preference for fitting the larger y values and almost ignores the small y values. One could argue that the chart trendline does not have the same bias, though, as you describe it, it might be biased towards fitting the small values. I think this will be easier to see if you plot your data on a semilog plot (format y axis to be logarithmic).

    That should be a brief explanation of why you are getting two different regressions. It will be up to you to decide which variation is more correct.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

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

    Re: Trendline fits badly

    R2 = 0.997 if you use a power series trendline, which is linear on a log-log chart.

    Row\Col
    A
    B
    C
    D
    E
    1
    2.4401
    -9.9740
    B1:C3: {=LINEST(LN(B8:B17), LN(A8:A17), , TRUE)}
    2
    0.0448
    0.2755
    3
    0.9973
    0.0984
    4
    5
    4.660E-5
    C5: =EXP(C1)
    6
    7
    x
    y
    Fit
    8
    100
    3.57
    3.54
    C8: =$C$5 * A8^$B$1
    9
    200
    17.78
    19.19
    10
    300
    63.61
    51.61
    11
    400
    89.52
    104.13
    12
    500
    169.86
    179.49
    13
    600
    292.38
    280.07
    14
    700
    410.86
    407.96
    15
    800
    568.38
    565.09
    16
    900
    756.76
    753.25
    17
    1000
    977.62
    974.07
    Last edited by shg; 10-08-2014 at 12:12 PM.
    Entia non sunt multiplicanda sine necessitate

+ 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. [SOLVED] Excel 2010 Trendline With Data labels or number on forward forecast trendline
    By camelight in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 10-15-2015, 08:35 AM
  2. i dont have the knowledge to create a macro
    By romarkevinruiz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2014, 07:07 AM
  3. I really need help with Excel badly
    By jimmysom in forum Excel General
    Replies: 3
    Last Post: 09-30-2009, 10:12 AM
  4. Need Help Badly
    By textboom in forum Excel General
    Replies: 5
    Last Post: 11-08-2008, 06:55 AM
  5. Excel behaving badly
    By no_name in forum Excel General
    Replies: 1
    Last Post: 12-23-2005, 06:50 AM

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