+ Reply to Thread
Results 1 to 16 of 16

Mann Kendall test for trend in time-series data help please!!

  1. #1
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Mann Kendall test for trend in time-series data help please!!

    I am basically trying to use the Mann-Kendall test for a trend in time series data (Daily data sets going back to about 1980).

    The only part I cannot calculate with normal excel formulas is the second half of the formula for VaR(S) from this website..

    http://tenyearsnow.wordpress.com/201...rical-example/

    Basically, i want to calculate this figure at each data point, looking back at the previous n-1 points. I guess i should try and explain the rationale of this part of the equation...

    If we had n=1 to 10 as the following data points.. 9,8,8,6,5,4,4,3,2,1 (obviously there would also be lots of preceding data points).

    g is a tied group when, in a data set, 2 or more of the data is the same. so here we have two tied groups as there are two 8's and two 4's. For each tied group we need to calculate tp(tp-1)(tp+5), (where tp is the number of data points in each group g, so here both groups would have tp=2 as there are two 8's and two 4's).

    Then summing together all tp(tp-1)(tp+5) for all g's withing the 10 data points.

    The hard part is that i want to do this at every point in the data. I also want to test this for varying lengths, for example n=1 to 20, n=1 to 30 etc.

    The furthest i have ever really got with VBA is Alt-F11, so any help will be most appreciated.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Mann Kendall test for trend in time-series data help please!!

    Hi,

    You won't necessarily need VBA. Standard Excel functions will be sufficient. Put together an example workbook and manually add the results that you expect for each element of the

    formula.jpg

    formula and add notes explaining which values/cells you have used so that we can cross check the Excel formulae that are needed.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    Thank you, I have done as said, on sheet 1. The yellow column is where the help is needed,with some notes added. If any further info is required please say. Many Thanks again.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    For Cell R5, the comment is meant to say "Looking at O5:O13", apologies.

  5. #5
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    I am a beginner at this and the following formula is about as far as i can get, which is obviously nowhere near.....





    Sub Loop1()

    Do

    If ActiveCell.Offset(0, -2).Value = ActiveCell.Offset(i, -2).Value Then


    c = 1

    ActiveCell.Value = "c * (c-1) * ((2*c)+5)"

    ActiveCell.Offset(1, 0).Select

    Loop Until IsEmpty(ActiveCell.Offset(0, 1))


    End Sub

  6. #6
    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: Mann Kendall test for trend in time-series data help please!!

    If you can relate what you want in terms of the example at http://www.statsdirect.com/help/nonp...thods/kend.htm, I have a UDF that computes the Kendall tau rank correlation coefficient.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    Thanks. What I really need help on is coding a conditional summation for, say, Cell R3, that can check the values in cells O3 to O12, against the range of O3:O12.

    I just dont really know how to start. I mean, I have done programming in MatLab before, it is somewhat similar but i dont know a lot of the function names.

  8. #8
    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: Mann Kendall test for trend in time-series data help please!!

    That's not what I'm asking.

    The link has this example:

    Please Login or Register  to view this content.
    The formula in C2 computes the coefficient using the equation shown, and gets the same result shown at the link. Can you relate that to what you're trying to do?

  9. #9
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    Kind of, from my data set i have calculated the S value for each point. (there are about 5000 data points) I now need to calculate Var(S) for each point but cannot find an obvious way to do it with normal Excel formulas.

    If you see my original post, there is a link to the formula for Var(S) of which the second half I am trying to code in VBA. I have (tried) to give an explanation in the original post as to the logic behind the calculation.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Mann Kendall test for trend in time-series data help please!!

    Hi,

    Does the attached help? You'll need to check it for other values. Column Z is the calculation.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-07-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Mann Kendall test for trend in time-series data help please!!

    Hi Richard, thats almost it, looking at z 13 for example, its taking three -20's as two tied groups, because its found -20 appears 3 times (cell AG13) and -20 appears twice (cell AH13). This should be one tied group of tp =3, and the figure in the z column should equal 3*(3-1)*([3*2]+5)=66. Hope this makes sense.

    As another example, cell z19 (which should find tied groups of three -20's, two -19's and two -15's, should equal 3*(3-1)*([3*2]+5) + 2*(2-1)*([2*2]+5) + 3*(2-1)*([2*2]+5)

  12. #12
    Registered User
    Join Date
    09-19-2013
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Mann Kendall test for trend in time-series data help please!!

    Hello,
    I urgently need a sheet in excel format through which I can use the test mann kendall ... Thank you for the valuable help that you give me .... I do not know really how to do ...

  13. #13
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Mann Kendall test for trend in time-series data help please!!

    luca 71

    Welcome to the forum.

    Unfortunately your post is against Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  14. #14
    Registered User
    Join Date
    09-19-2013
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Mann Kendall test for trend in time-series data help please!!

    I apologize, but I do not know English well, and I have not figured out how to open a new discussion although I have read the forum rules, although I have much urgency to solve my problem with the test mann kendall
    Thanks for the forbearance

  15. #15
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Mann Kendall test for trend in time-series data help please!!

    Hi,

    Go to http://www.excelforum.com/

    Pick one of the forums that covers your subject, click on the forum hyperlink and then click the 'Post New Thread' button

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Mann Kendall test for trend in time-series data help please!!


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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