IRIS-Solutions-Team / IRIS-Toolbox

[IrisToolbox] for Macroeconomic Modeling
Other
92 stars 42 forks source link

incorrect conversion in day2ww #365

Open ikarib opened 1 year ago

ikarib commented 1 year ago

If start = 3 in day2ww, then we get wrong conversion:

>> dat2str(dater.day2ww(dd(1986,12,28):dd(1987,1,1)))
ans =
  1×5 cell array
    {'1986W52'}    {'1987W01'}    {'1987W01'}    {'1987W01'}    {'1987W01'}

If start = 6 in day2ww, then we get right conversion:

>> dat2str(dater.day2ww(dd(1986,12,28):dd(1987,1,1)))
ans =
  1×5 cell array
    {'1986W52'}    {'1986W52'}    {'1986W52'}    {'1986W52'}    {'1987W01'}
jaromir-benes commented 1 year ago

Hi - the Iris week convention follows the ISO-8601 standard, and works alright. Two rules, put simply: (i) each week starts on Monday and ends on Sunday; (ii) to which year the week belongs is determined by Thursday.

28 December 1986 was Sunday 29 December 1986 was Monday 30 December 1986 was Tuesday 31 December 1986 was Wednesday 1 January 1987 was Thursday 2 January 1987 was Friday 3 January 1987 was Saturday 4 January 1987 was Sunday

Hence, the week from 29 December 1986 to 4 January 1987 is considered week

1 of 1987 (note that the rule makes sense since four days of that week

are in 1987 while only three are in 1986).

This is what we get from the function:

dater.toDefaultString(dater.day2ww(dd(1986,12,28):dd(1987,1,1)))

"1986W52"    "1987W01"    "1987W01"    "1987W01"    "1987W01"

Best Jaromir

On Sun, Feb 26, 2023 at 6:44 PM Iskander Karibzhanov < @.***> wrote:

If start = 3 in day2ww, then we get wrong conversion:

dat2str(dater.day2ww(dd(1986,12,28):dd(1987,1,1)))

ans =

1×5 cell array

{'1986W52'}    {'1986W52'}    {'1986W52'}    {'1986W52'}    {'1987W01'}

If start = 6 in day2ww, then we get right conversion:

dat2str(dater.day2ww(dd(1986,12,28):dd(1987,1,1)))

ans =

1×5 cell array

{'1986W52'}    {'1986W52'}    {'1986W52'}    {'1986W52'}    {'1987W01'}

— Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/365, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKSOPVC73OHBJ4PYJOLWZPTEPANCNFSM6AAAAAAVIX4Z4Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ikarib commented 1 year ago

Is it possible to add option to change Thursday convention to Wednesday? This worked on previous IRIS versions:

>> iris.set('WDay','Wed')
Unable to set the 'WDay' property of class 'Configuration' because it is read-only.
Error in iris.set (line 24)
    irisConfig.(ithOptionName) = ithNewValue; 

convert also doesn't have this option:

>> rn_mm=convert(rn_ww,12,'method=','last','WDay','Wed');
Error using Series.convert
'WDay' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for Series.convert.
Error in extend.InputParser/parse (line 59)
            parse@inputParser(this, varargin{:});
Error in Series/convert (line 35)
opt = parse(pp, this, newFreq, varargin{:}); 
jaromir-benes commented 1 year ago

Ok, will do :)

On Mon, Feb 27, 2023 at 10:09 AM Iskander Karibzhanov < @.***> wrote:

Is it possible to add option to change Thursday convention to Wednesday?

— Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/365#issuecomment-1446503988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKV3QRJRROXTDB5URLDWZS7TJANCNFSM6AAAAAAVIX4Z4Y . You are receiving this because you commented.Message ID: @.***>

ikarib commented 1 year ago

workaround for now: Change line 64 of DataManagement\+dater\convert.m (previously DataManagement\+numeric\convert.m) x = ww2day(inputDate(inxFromWeekly), 'Thu'); to x = ww2day(inputDate(inxFromWeekly), 'Wed');