Results 1 to 19 of 19

Thread: Trend Analysis Question

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Trend Analysis Question

    I have the following data:

    Code:
        100 	Feb. 4, 2000
        200 	Aug. 31, 2000
        300 	Mar. 25, 2001
        400 	Feb. 26, 2002
        500 	Aug. 14, 2002
        600 	Apr. 29, 2003
        700 	Dec. 2, 2003
        800 	Jun. 11, 2004
        900 	Jan. 15, 2005
    Column 1 is "discovery number" and Column 2 is the date on which that discovery was made. So, discovery #200 was made on August 31, 2000.

    What I want to do is figure out when Discovery #1000 will be made.

    How would you go about this?

  2. #2

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    I should also show you a little of what I did:

    If you remember from stats class, for a given X (In this case, X = 1000), you can get Y by the formula:

    Code:
    Y = a + bX
    Where



    and



    The only confusion I have is regarding the date column.

    Should I take the first date as a base and take the difference of each, or should I be taking the difference between that date and the date before it?
    Attached Images Attached Images   

  3. #3
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking Re: Trend Analysis Question

    I think your first option is right...
    if you convert each date to a 'Days After First Date' number, then you can predict how many days after the first date the next should be.

    However, it would be interesting to see if the answer is exactly the same if you convert each date to a 'Days Since Previous Date' number, and predict it that way.

    If they are not the same, then it's up to the question...it may be worded to indicate one way, but if not, then with appropriate reasoning, either should be fine.
    sql_lall

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    Alright. Let me try this out, I'll be back with something useful.

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    Here's what I wrote. I took care of both conditions. If you have VB.NET, you can copy-paste this into the form's code. I can't upload any EXEs.

    The two dates I got were:

    September 5, 2005 --> Days since previous date method.
    January 10, 2006 --> Days since first date method.


    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.  
    4. #Region " Windows Form Designer generated code "
    5.  
    6.     Public Sub New()
    7.         MyBase.New()
    8.  
    9.         'This call is required by the Windows Form Designer.
    10.         InitializeComponent()
    11.  
    12.         'Add any initialization after the InitializeComponent() call
    13.  
    14.     End Sub
    15.  
    16.     'Form overrides dispose to clean up the component list.
    17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    18.         If disposing Then
    19.             If Not (components Is Nothing) Then
    20.                 components.Dispose()
    21.             End If
    22.         End If
    23.         MyBase.Dispose(disposing)
    24.     End Sub
    25.  
    26.     'Required by the Windows Form Designer
    27.     Private components As System.ComponentModel.IContainer
    28.  
    29.     'NOTE: The following procedure is required by the Windows Form Designer
    30.     'It can be modified using the Windows Form Designer.  
    31.     'Do not modify it using the code editor.
    32.     Friend WithEvents Button1 As System.Windows.Forms.Button
    33.     Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
    34.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    35.         Me.Button1 = New System.Windows.Forms.Button
    36.         Me.CheckBox1 = New System.Windows.Forms.CheckBox
    37.         Me.SuspendLayout()
    38.         '
    39.         'Button1
    40.         '
    41.         Me.Button1.Location = New System.Drawing.Point(56, 112)
    42.         Me.Button1.Name = "Button1"
    43.         Me.Button1.Size = New System.Drawing.Size(184, 32)
    44.         Me.Button1.TabIndex = 0
    45.         Me.Button1.Text = "Button1"
    46.         '
    47.         'CheckBox1
    48.         '
    49.         Me.CheckBox1.Location = New System.Drawing.Point(88, 56)
    50.         Me.CheckBox1.Name = "CheckBox1"
    51.         Me.CheckBox1.TabIndex = 1
    52.         Me.CheckBox1.Text = "Pairs Method"
    53.         '
    54.         'Form1
    55.         '
    56.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    57.         Me.ClientSize = New System.Drawing.Size(292, 273)
    58.         Me.Controls.Add(Me.CheckBox1)
    59.         Me.Controls.Add(Me.Button1)
    60.         Me.Name = "Form1"
    61.         Me.Text = "Form1"
    62.         Me.ResumeLayout(False)
    63.  
    64.     End Sub
    65.  
    66. #End Region
    67.  
    68.     Dim nmArr(8) As Integer
    69.     Dim dtArr(8) As Date
    70.     Dim dtDiffs(8) As Integer
    71.     Dim blMethod As Boolean
    72.     Dim A As Decimal
    73.     Dim B As Decimal
    74.     Dim n As Integer = 9
    75.     Dim YFinal As Decimal
    76.     Dim XFinal As Decimal = 1000
    77.     Dim DtFinal As Date
    78.  
    79.  
    80.  
    81.     '    100    Feb. 4, 2000
    82.     '200    Aug. 31, 2000
    83.     '300    Mar. 25, 2001
    84.     '400    Feb. 26, 2002
    85.     '500    Aug. 14, 2002
    86.     '600    Apr. 29, 2003
    87.     '700    Dec. 2, 2003
    88.     '800    Jun. 11, 2004
    89.     '900    Jan. 15, 2005
    90.  
    91.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    92.  
    93.    
    94.  
    95.  
    96.         'Initialize Array
    97.         dtArr(0) = Date.Parse("02/04/2000")
    98.         dtArr(1) = Date.Parse("08/31/2000")
    99.         dtArr(2) = Date.Parse("03/25/2001")
    100.         dtArr(3) = Date.Parse("02/26/2002")
    101.         dtArr(4) = Date.Parse("08/14/2002")
    102.         dtArr(5) = Date.Parse("04/29/2003")
    103.         dtArr(6) = Date.Parse("12/02/2004")
    104.         dtArr(7) = Date.Parse("06/11/2004")
    105.         dtArr(8) = Date.Parse("01/15/2005")
    106.  
    107.         Dim i As Integer
    108.         For i = 0 To 8
    109.             nmArr(i) = (i + 1) * 100
    110.         Next
    111.  
    112.  
    113.  
    114.     End Sub
    115.  
    116.  
    117.    
    118.  
    119.  
    120.  
    121.     Private Function Exy() As Integer
    122.  
    123.         Dim i As Integer
    124.         Dim intSum As Integer = 0
    125.  
    126.         For i = 0 To 8
    127.             intSum = intSum + (nmArr(i) * dtDiffs(i))
    128.         Next
    129.  
    130.         Return intSum
    131.  
    132.  
    133.     End Function
    134.  
    135.     Private Function Ex() As Integer
    136.  
    137.         Dim i As Integer
    138.         Dim intSum As Integer = 0
    139.  
    140.         For i = 0 To 8
    141.             intSum = intSum + nmArr(i)
    142.         Next
    143.  
    144.         Return intSum
    145.  
    146.  
    147.     End Function
    148.  
    149.     Private Function Ey() As Integer
    150.  
    151.         Dim i As Integer
    152.         Dim intSum As Integer = 0
    153.  
    154.         For i = 0 To 8
    155.             intSum = intSum + dtDiffs(i)
    156.         Next
    157.  
    158.         Return intSum
    159.  
    160.     End Function
    161.  
    162.     Private Function Ex2() As Integer
    163.  
    164.         Dim i As Integer
    165.         Dim intSum As Integer = 0
    166.  
    167.         For i = 0 To 8
    168.             intSum = intSum + (nmArr(i) * nmArr(i))
    169.         Next
    170.  
    171.         Return intSum
    172.  
    173.     End Function
    174.  
    175.     Private Function YBar() As Decimal
    176.  
    177.         Dim i As Integer
    178.         Dim intSum As Integer = 0
    179.  
    180.         For i = 0 To 8
    181.             intSum = intSum + dtDiffs(i)
    182.         Next
    183.  
    184.         Return (intSum / 9)
    185.  
    186.     End Function
    187.  
    188.     Private Function XBar() As Decimal
    189.  
    190.  
    191.         Dim i As Integer
    192.         Dim intSum As Integer = 0
    193.  
    194.         For i = 0 To 8
    195.             intSum = intSum + nmArr(i)
    196.         Next
    197.  
    198.         Return (intSum / 9)
    199.     End Function
    200.  
    201.  
    202.  
    203.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    204.  
    205.  
    206.         blMethod = CheckBox1.Checked
    207.  
    208.         GetDateDiffs()
    209.  
    210.  
    211.  
    212.         B = ((n * Exy()) - ((Ex()) * (Ey()))) / ((n * Ex2()) - (Ex() * Ex()))
    213.  
    214.         A = YBar() - (B * XBar())
    215.  
    216.         YFinal = A + (B * XFinal)
    217.  
    218.         If blMethod Then
    219.             DtFinal = DateAdd(DateInterval.Day, YFinal, dtArr(8))
    220.         Else
    221.             DtFinal = DateAdd(DateInterval.Day, YFinal, dtArr(0))
    222.         End If
    223.  
    224.  
    225.         MessageBox.Show(DtFinal.ToLongDateString)
    226.     End Sub
    227.  
    228.  
    229.     Private Sub GetDateDiffs()
    230.  
    231.         Dim intCount As Integer
    232.  
    233.         For intCount = 0 To 8
    234.  
    235.             If blMethod Then
    236.                 dtDiffs(intCount) = DateDiff(DateInterval.Day, dtArr(IIf(intCount = 0, 0, intCount - 1)), dtArr(intCount))
    237.             Else
    238.                 dtDiffs(intCount) = DateDiff(DateInterval.Day, dtArr(0), dtArr(intCount))
    239.             End If
    240.  
    241.         Next
    242.  
    243.     End Sub
    244.  
    245.    
    246. End Class

    I guess I'll go with 2006.

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Trend Analysis Question

    Roboplot would eat this for breakfast with weetabix.

    It's a shame I can't be bothered finishing it yet though.
    I don't live here any more.

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    You might be interested in the "source/reason" for this:

    The SOHO satellite recently found comet #900. They announced a contest: Whoever can guess the date+time for discovery of comet #1000 will win... are you ready... a DVD and a pair of solar glases and even a T-Shirt!!!

    http://soho.nascom.nasa.gov/comet1000/

    Curiosity got the better of me, had to find out.

    Now, I'll be using the January date and working with other factors like

    a) Increased webcam hits due to news of the contest
    b) More people "logging on" to the internet every day, a small percentage of them interested in things other than cybersex.
    c) Political events which may divert attention from this.
    d) Mercury explodes

  8. #8
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228

    Thumbs up Re: Trend Analysis Question

    The MS Excel FORECAST function places #1000 on Sep. 30, 2005. The data you gave also does look pretty linear (converting the date to the MS serial number format and then back again), which should fit your original Y = a + bX assumption. The MS Excel TREND function gives exactly the same answer.
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

  9. #9

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    I see. I was wondering why I had gone through this trouble when an existing solution was in place, but since our answers are different, it makes me wonder if Excel knows what it's doing

    Perhaps their function has different logic?

  10. #10
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Trend Analysis Question

    Quote Originally Posted by mendhak
    a small percentage of them interested in things other than cybersex.
    May be difficult to prove.
    I don't live here any more.

  11. #11
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Trend Analysis Question

    Here´s what I got using the Add-Trendline of MS-EXCEL and two buit-in functions: Intercept() and Slope(). It was fun and easy. See the attached MS-EXCEL file.

    Hope you get your T-shirt
    Attached Files Attached Files

  12. #12

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Trend Analysis Question

    Thanks Ras. It's interesting to see how no two answers are alike.

    And to speculate on whether I had known about Excel's functions, whether I'd still have written that code.

    *bites fingers*

  13. #13
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Trend Analysis Question

    Why not use Tarot cards to predict the future? Or goat entrails, or sandpaper.
    I don't live here any more.

  14. #14
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Trend Analysis Question

    Quote Originally Posted by wossname
    Why not use Tarot cards to predict the future? Or goat entrails, or sandpaper.
    Math methods are rational and work just fine in case the near future proceeds with the same pattern as the recent past. In case you predict some change (sudden or continuous) math can still be of use by applying proper algorithms (with damping effects when a sudden change is foreseen or a trend is foreseen). If data doesn’t exist at all, then you can still use stat methods to predict the future in corporations such as the Delphi method.

    Tarot cards, goat entrails or sandpaper…NEVER!

    Be happy.

  15. #15
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228

    Talking Re: Trend Analysis Question

    Rassis,
    Nice color scheme on the spreadsheet.
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

  16. #16
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trend Analysis Question

    Don't let Wossy confuse you:

    Here's the source that will generate a trend curve, and the function you need in order to predict further into the future.

    http://www.vbforums.com/showthread.php?t=311225

  17. #17
    Junior Member
    Join Date
    Jul 2005
    Posts
    23

    Re: Trend Analysis Question

    Quote Originally Posted by Rassis
    Here´s what I got using the Add-Trendline of MS-EXCEL and two buit-in functions: Intercept() and Slope(). It was fun and easy. See the attached MS-EXCEL file.

    Hope you get your T-shirt
    Nice Rassis!!

    I was also working on the Forecasting for incoming calls I have taken data for last 2 years but the y=a+b.x does not give me data approx to any of the past data. Do u have any suggestion for this sort of forecasting.

  18. #18
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Trend Analysis Question

    Quote Originally Posted by iqkh
    I was also working on the Forecasting for incoming calls I have taken data for last 2 years but the y=a+b.x does not give me data approx to any of the past data. Do u have any suggestion for this sort of forecasting.
    You can try the "add trend line" tool to fit any of the functions prebuilt in Excel to your data or use Crystal Ball, BestFit, Stat::Fit, ExpertFit or any other similar software.

    Alternatively, I attach an example in Excel for the power, linear and the exponential that you can modify and expand at your will.

    Hope this helps.
    Attached Files Attached Files
    ...este projecto dos Deuses que os homens teimam em arruinar...

  19. #19
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trend Analysis Question

    If you want to get really technical you can find the trend (a reasonably low polynomial) and then get the moving average (the simple one will do)

    Where the lines intersect you can expect a reverse change in the gradient of the line in the near future in say about 80% of cases.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width