+ Reply to Thread
Results 1 to 10 of 10

Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

  1. #1
    Registered User
    Join Date
    03-21-2015
    Location
    Milwaukee
    MS-Off Ver
    2010
    Posts
    16

    Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    I'm trying to plot coronavirus data against time and add an exponential trend line.

    The domain runs from March 1 2020 into April, so the numbers that represent the dates run from 43891 to 43935.
    The range is from 75 to 33,500 (as of today).

    There are no zero or negative values in the range, so the exponential trend line selection is not greyed out.

    But nothing happens when I add an exponential trend line.

    If I switch the domain values for the dates to numbers from 1 to 45, the exponential trend line plots just fine.

    In other charts in the past I have been able to use dates along the x-axis, but these dates spanned a longer period, from 1940 to the present (date code numbers from 14612 to 43890)

    Is this an accuracy/precision problem with the internal exponential trendline calculations?

    Is there some minimum date domain time period you need to specify to get this to work, or should I just delete the regular axis labels and add my own text string for the dates?

    Or, should I just shift the dates down to March 1, 1900 so that the date values range from 61 to 106?
    Last edited by jerbes; 03-23-2020 at 05:44 PM. Reason: solved

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Axis may be set to categorical. Try setting it to continuous or dates/numbers.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

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

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Is this an accuracy/precision problem with the internal exponential trendline calculations?
    I don't know exactly how microsoft has it programmed under the hood, but I strongly suspect that, yes, this is an accuracy/precision problem inside of the chart trendline calculations.

    The basic exponential equation that the chart trendline uses is y=b*exp(mx) (or, equivalently, as the LOGEST() function does it, y=b*m^x). Anytime you have a number like 44000 (your date values) in the exponent, you have the potential for some massive (or tiny) numbers -- easily extending beyond what Excel can handle.

    One solution, as you've already discovered, is to transform dates from the actual serial number to "days since a recent start date".

    Another solution is to perform all the calculations in log(y) vs. x space, then wait until the very end to perform the final exponentiation.

    I'm sure there are others. The basic idea is -- using actual date serial numbers in a regression has the potential to create overflow errors, so you need to do something to avoid those overflows.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,451

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Hi jerbes,

    I'm at home looking for viruses (like looking for electricity)

    Here is an example that shows dates, days and an exponential graph. I always work better from an example. If you click on the curve itself it brings up options for it specifically. The user interface is a bit different between different versions of Excel. See if this helps.
    Exponential Trend Line Virus.xlsx
    I made up some random data using the Rand() function. Each cell was (1+Rand()) times the cell above it. I copy and pasted values only to keep it from changing for the final save. If you had some real numbers you could type over my numbers and get a much better idea and formula for the trend.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    03-21-2015
    Location
    Milwaukee
    MS-Off Ver
    2010
    Posts
    16

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Quote Originally Posted by CK76 View Post
    Axis may be set to categorical. Try setting it to continuous or dates/numbers.
    Axis was set to Category: Date.
    If I set it to Category: Numbers, I get 43891 .... 43935.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Hmm, on my end using Date type axis has no issue showing exponential trendline.

    Best bet is to upload sample file.

  7. #7
    Registered User
    Join Date
    03-21-2015
    Location
    Milwaukee
    MS-Off Ver
    2010
    Posts
    16

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    I solved the problem by mapping the dates from March 2020 down to March 1900.

    This changed the domain date values from 43891 through 43935, down to 61 through 105.

    Not a problem since I don't show the year in the axis labels.
    I suppose I could always go down to 1920 if a two digit year was important to show.

    Attachment 668717

  8. #8
    Registered User
    Join Date
    03-21-2015
    Location
    Milwaukee
    MS-Off Ver
    2010
    Posts
    16

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Quote Originally Posted by CK76 View Post
    Hmm, on my end using Date type axis has no issue showing exponential trendline.

    Best bet is to upload sample file.
    Here's the file.
    Attached Files Attached Files

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    Ah, I see the issue. I didn't check for the wide range of y values.

    Your technique is probably the right one.

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

    Re: Exponential Trend Line Will Not Display on Chart When Using Dates on X-axis

    The one caution I would make when mapping dates down to 1900 is to be aware of the long standing "bug" where Excel treats 1900 as a leap year. It works for 2020, because 2020 is a leap year, but other years, your dates will potentially be "off" by a day.

    To see why the problem in the OP occurs, enter =LINEST(LOG(B4:B25),A4:A25) across two cells. You will see that the b in y=b*exp(mx) wants to be about 1E-5500, but the smallest value Excel's double precision can handle is about 1E-300. This underflow error is what causes the chart trendline to fail.

    In addition to this solution (mapping dates to the year 1900), you could also change the order of calculation to avoid the underflow. With the output from the LINEST(...) function above, you can use =10^(a*date+b) to compute the smoothed values. This order of operations should avoid the underflow error that causes the chart trendline to fail.

+ 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. Add a Partial Trend Line for Y2 Axis
    By e602043 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-28-2016, 11:40 AM
  2. Need help Stacked BAR chart 2 axis with trend line
    By krillin_boi in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-30-2016, 12:31 AM
  3. Replies: 2
    Last Post: 03-11-2016, 11:06 AM
  4. Exponential Trend Line Is Off From Input Data
    By Ryepod in forum Excel General
    Replies: 1
    Last Post: 12-06-2013, 01:56 PM
  5. Generating a formula for a Exponential trend line in a cell
    By Andrew Stanbury in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-02-2012, 06:05 AM
  6. Problem With Exponential Trend Line Equation
    By brian314m in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-26-2012, 09:51 PM
  7. line chart-format x axis for dates
    By Scatter in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-29-2011, 04:59 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