tsibble icon indicating copy to clipboard operation
tsibble copied to clipboard

New vignette on extending tsibble's index support

Open earowang opened this issue 5 years ago • 6 comments

  • index_valid()
  • index_pull()
  • new_interval() and gcd_interval()
  • seq() and + for new_data() and *_gaps()

earowang avatar Jul 10 '20 02:07 earowang

Hi Earo, many thanks for the tsibble package: it is great to work with and makes my data processing so much more elegant!

I frequently work with data in 10-days intervals (36 values per year) and will now try to implement index_valid() and index_pull() for my example. Do you already have minimal examples that you could share with me?

Trice monthly is a very common reporting interval for water-related data in (former) socialist countries. If(!) I get it running, would you be interested in a working example for 10-day tsibbles?

mabesa avatar Jan 20 '21 10:01 mabesa

I work in the field of demand planning and we also use some 10-day (roughly) intervals for determining the demand in the first/middle/last part of the month. This somewhat tries to model the fact that people get their salaries in different parts of the month (around 4th, 15th and 25th is most common in my region) and this has often an effect on spending.

I would be very interested in a built-in 10 day interval, but specifically relative to its "parent" month. That is, Jan-Part1, Jan-Part2, Jan-Part3, Feb-Part1, etc..., never a 10 day interval overlapping two different months. Is this what you have in mind @mabesa ? If not, would something like this be implementable in the index framework @earowang ?

Fuco1 avatar Jan 22 '21 19:01 Fuco1

Hi @Fuco1, yes, dekad 1 to 3 per month sounds good as well. I envision two date conversions month-dekad and year-dekad. But the vision is always the simple part, I only started reading the code and don't yet understand how I should use the index_valid etc. functions.

mabesa avatar Jan 22 '21 21:01 mabesa

@mabesa Have you implemented your own S3 class to represent data in 10-day intervals? If not, you perhaps need to implement the class and a few supporting methods first. You can check out R/yearweek.R for the yearweek() class to get some ideas. Defining index_pull() for your S3 class happens later.

@Fuco1 I don't have plans to implement scenario-varying index in {tsibble}.

earowang avatar Jan 23 '21 03:01 earowang

@earowang Thank you for the the hint! I understand now hot to go about it. Just need time now...

mabesa avatar Jan 28 '21 08:01 mabesa

I've posted a SO answer which shows how a new index can be created using a minimal example of creating a year() index: https://stackoverflow.com/questions/65846176/r-tsibble-add-support-for-custom-index/66102152#66102152

mitchelloharawild avatar Feb 08 '21 13:02 mitchelloharawild