Inconsistent behavior of dseries2Q() depending on the input shape
Hello everyone,
I'm encountering a suprising issue with dseries2Q() where its behavior seems to be inconsistent depending on the form of the inputed data while the function "sees" there seems to be an issue with said data. Specifically:
I'm using it to transform monthly data to quarterly frequency using the 'arithmetic average' method and these three inputs give different results:
Prepararing my data
toto_m = dseries([1 2 3 4 5 NaN]', dates('2020m10'):dates('2021m3'), 'toto');
titi_m = dseries([1 2 3 4 5]', dates('2020m10'):dates('2021m2'), 'titi');
tata_m = dseries([1 2 3 4]', dates('2020m10'):dates('2021m1'), 'tata');
Applying the function
toto_q = dseries2Q(toto_m, 'arithmetic-average');
titi_q = dseries2Q(titi_m, 'arithmetic-average');
tata_q = dseries2Q(tata_m, 'arithmetic-average');
I'm having an issue with titi and tata the most and think what the function does on toto is the right thing to do when facing incomplete data for 2021Q1. Although it seems to do it for the wrong reason (aka computing the average on some numbers + NaN gives NaN).
-
In the toto case: the function gives a NaN for 2021Q1, seemingly because it computes the average on [4, 5, NaN], and does not warn about imcomplete data.
-
In the tata case: the function happily provides the data in 2021M1 as the number for 2021Q1 while warning that the data is imcomplete for that quarter.
-
In the titi case: the function averages 2021M1 and 2021M2 to give 2021Q1, with a warning about imcomplete data for 2021Q1 too.
Idealy, I do think the function should always refuse to compute the average on incomplete quarters (because it would be inventing data else?) and give a NaN instead.