christophsax / tempdisagg

Methods for Temporal Disaggregation and Interpolation of Time Series
http://cran.r-project.org/web/packages/tempdisagg
36 stars 5 forks source link

Monthly to quarterly aggregation with ta-function #54

Open heinermikosch opened 9 months ago

heinermikosch commented 9 months ago

We are long-term users of the tempdisagg package. A very nice package.

We recently discovered the following error in our code using the ta-function:

cpiforecast <- ta(aux, conversion = "average", to = "quarterly") Fehler in if (start > end + eps) stop("'start' cannot be after 'end'") : Argument hat Länge 0 Zusätzlich: Warnmeldung: In .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]), : schnittfreie Zeitreihen

The function input argument ("aux") is at is should be (we guess), i.e. aux is a ts-object, more precisely a monthly time series starting January 1970 and ending December 2028.

class(aux) [1] "ts"

aux Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1970 6.898214 6.923260 6.955155 6.989254 7.005405 7.032039 7.061408 7.081966 7.117358 7.159550 7.206823 7.246305 1971 7.283223 7.310607 7.335092 7.368730 7.405892 7.448956 7.481838 7.517249 7.549818 7.575864 7.602929 7.638325 1972 7.656101 7.692411 7.723142 7.743428 7.774029 7.809559 7.853256 7.899723 7.939639 7.978800 8.017516 8.056942 1973 8.098221 8.149371 8.223447 8.292461 8.368558 8.437050 8.489801 8.598263 8.668713 8.749202 8.840195 8.956548 1974 9.083157 9.214492 9.328943 9.419732 9.518431 9.606936 9.721969 9.838729 9.956509 10.074717 10.200329 10.288302 1975 10.377074 10.455353 10.528852 10.616336 10.711837 10.808140 10.905267 10.960371 11.051865 11.128933 11.215670 11.295112 1976 11.382067 11.458492 11.531088 11.613409 11.702212 11.767232 11.847255 11.931021 12.045367 12.171643 12.282216 12.388782 1977 12.492080 12.607397 12.718460 12.834275 12.921663 13.017065 13.110841 13.208452 13.306649 13.390127 13.482567 13.572070 1978 13.658553 13.750841 13.859045 13.959739 14.079339 14.200038 14.333549 14.431667 14.536466 14.654543 14.747855 14.843441 1979 14.970016 15.091274 15.239203 15.386211 15.557088 15.731449 15.975659 16.118933 16.293234 16.476154 16.648913 16.850887 1980 17.125263 17.387283 17.601486 17.811875 17.989263 18.169972 18.308343 18.472074 18.636036 18.819155 19.013336 19.206427 1981 19.403758 19.590614 19.777872 19.938650 20.121099 20.298143 20.520338 20.696920 20.896850 21.054417 21.215143 21.362221 1982 21.520207 21.666854 21.800254 21.984806 22.241649 22.516009 22.716256 23.011245 23.193968 23.404542 23.559777 23.833466 1983 24.040641 24.190608 24.358151 24.583145 24.800844 24.955034 25.172649 25.373378 25.559851 25.758579 25.982298 26.161791 1984 26.345671 26.567332 26.743920 26.917974 27.105471 27.295754 27.480200 27.639162 27.810432 27.990460 28.129914 28.267401 1985 28.465039 28.684864 28.920308 29.098212 29.271130 29.405564 29.578655 29.726439 29.881877 30.089038 30.283536 30.511542 1986 30.715389 30.798481 30.859017 30.940259 31.155908 31.416720 31.591842 31.827707 32.069595 32.268649 32.499987 32.759629 1987 32.966873 33.207006 33.464995 33.759148 34.066963 34.336618 34.643649 34.992495 35.282274 35.600612 35.936244 36.543375 1988 36.809723 37.096021 37.388603 37.604420 37.818986 38.030603 38.253637 38.460770 38.668898 38.818765 38.995446 39.153777 1989 39.305678 39.504549 39.733698 40.047304 40.330038 40.515353 40.719057 40.870731 41.057372 41.293319 41.452016 41.677390 1990 41.999469 42.268056 42.511983 42.735342 42.982262 43.227090 43.431756 43.802755 44.157391 44.502187 44.726740 44.908007 1991 45.174270 45.356139 45.528809 45.720805 45.973783 46.215683 46.443766 46.666137 46.855481 47.123825 47.439194 47.644932 1992 47.770022 47.988183 48.247596 48.396025 48.552812 48.749373 48.878919 49.079406 49.288124 49.476655 49.693982 49.868880 1993 50.100529 50.304605 50.498439 50.632074 50.802657 50.996577 51.222034 51.416304 51.558811 51.763924 51.933167 52.125999 1994 52.251765 52.457945 52.649383 52.957117 53.201080 53.427555 53.657375 53.933020 54.119671 54.315277 54.566043 54.845211 1995 55.117726 55.445637 55.779357 56.143779 56.467414 56.801739 57.003677 57.277170 57.578212 57.810068 58.052828 58.351372 1996 58.696329 58.968044 59.291480 59.561776 59.851932 60.080994 60.304158 60.534561 60.776603 61.038742 61.301645 61.584856 1997 61.850889 62.071868 62.256257 62.465827 62.671209 62.927674 63.228995 63.521264 63.778667 64.057035 64.290691 64.536444 1998 64.778107 65.021163 65.206388 65.346607 65.580705 65.763140 65.978751 66.134047 66.327749 66.615004 66.844823 67.028322 1999 67.180489 67.306603 67.519381 67.837833 67.968440 68.095428 68.407514 68.664176 68.904425 69.157632 69.391212 69.680660 2000 69.872607 70.159909 70.508308 70.497253 70.671822 70.996222 71.333688 71.429895 71.680068 71.863931 72.128703 72.338839 2001 72.549527 72.739661 72.929468 73.271513 73.684893 73.889567 73.957538 74.066679 74.288578 74.367195 74.479206 74.618732 2002 74.850862 74.962193 75.194674 75.430134 75.561484 75.659205 75.847665 76.054933 76.149032 76.363968 76.608467 76.784700 2003 77.009001 77.309996 77.563400 77.395594 77.366189 77.470537 77.609595 77.815575 77.944959 78.029988 78.166331 78.361581 2004 78.551593 78.749564 78.955439 79.016289 79.331064 79.561180 79.600237 79.736553 79.789311 80.225436 80.487057 80.552536 2005 80.571176 80.795565 81.050405 81.200269 81.207885 81.274074 81.578222 81.887185 82.388865 82.651608 82.568403 82.663938 2006 83.017243 83.082575 83.173305 83.477909 83.727744 83.844204 84.103648 84.361370 84.182467 84.131399 84.326223 84.638260 2007 84.783425 84.997262 85.276449 85.505853 85.727536 85.792521 85.917530 86.000090 86.233213 86.660888 87.316257 87.572037 2008 87.863208 88.036313 88.373352 88.570445 89.124209 89.669666 90.165243 90.104746 90.173481 89.980004 89.353456 89.007420 2009 89.066722 89.268476 89.203549 89.202112 89.289930 89.632022 89.681254 89.896588 89.974619 90.187520 90.511353 90.641058 2010 90.878862 90.910177 90.979846 91.040840 91.051434 90.992302 91.147749 91.296256 91.464367 91.790632 92.068034 92.421765 2011 92.708676 92.941556 93.275313 93.580771 93.840452 93.777426 93.982849 94.213998 94.400923 94.596355 94.888679 95.043949 2012 95.282889 95.531554 95.741792 95.899748 95.790522 95.690566 95.763636 96.174009 96.496925 96.703431 96.708309 96.805543 2013 96.930981 97.289868 97.289321 97.153609 97.245046 97.426590 97.636511 97.817805 97.940102 97.943535 98.123393 98.392742 2014 98.548917 98.729116 98.876724 99.166130 99.298034 99.437656 99.559050 99.611957 99.671232 99.666580 99.638312 99.505844 2015 99.127777 99.375496 99.616569 99.751939 99.998159 100.138443 100.246427 100.285450 100.209236 100.347542 100.430104 100.452949 2016 100.387570 100.422114 100.592442 100.716828 100.930874 101.166782 101.265987 101.358138 101.518040 101.815434 101.966788 102.317082 2017 102.732338 102.954452 102.985290 103.157438 103.154591 103.201214 103.326383 103.634515 103.962726 104.098075 104.437474 104.722089 2018 104.965440 105.205738 105.337355 105.514974 105.888056 106.107920 106.309181 106.643225 107.027730 107.362979 107.283343 107.234587 2019 107.161147 107.396917 107.716066 108.150215 108.317312 108.322187 108.572667 108.738405 108.861772 109.156047 109.340910 109.587710 2020 109.705465 109.837067 109.578760 109.051833 109.098187 109.446367 109.775654 110.070132 110.281035 110.422939 110.667110 110.977368 2021 111.448690 111.791738 112.192201 112.688997 113.286232 113.846821 114.385447 114.851127 115.378067 116.190234 117.139972 118.249067 2022 119.415978 120.435748 121.980607 123.034705 124.268799 125.589812 126.168555 126.697655 127.582618 128.621759 129.214331 129.385132 2023 130.366478 131.070323 131.436848 132.102183 132.355926 132.731673 133.599041 134.799754 135.520340 135.840931 136.184200 136.773551 2024 137.358546 137.929122 138.485734 139.007938 139.520143 140.025711 140.516322 141.003431 141.487004 141.951793 142.415684 142.878666 2025 143.340268 143.802643 144.265787 144.729698 145.194375 145.659814 146.126015 146.592973 147.060689 147.529158 147.998379 148.468349 2026 148.939066 149.410528 149.882733 150.355677 150.829358 151.303775 151.778925 152.254805 152.731412 153.208744 153.686800 154.165575 2027 154.645068 155.125276 155.606196 156.087826 156.570163 157.053205 157.536948 158.021391 158.506530 158.992363 159.478886 159.966098 2028 160.453995 160.942575 161.431834 161.921771 162.412381 162.903663 163.395612 163.888228 164.381505 164.875442 165.370036 165.865283

image

The package version we are using is 1.1.

Our question: Do you know whether the ta function in the package version mentioned above has a bug or what the problem might be? Perhaps it is also because we are not using the function correctly (but so far the code line has always worked). Every hint is helpful.

heinermikosch commented 9 months ago

Add on: We have tried to debug the ta function. The problem seems to be that at one point the tail function is used, and then a time series is used to calculate the end date instead of real numbers.

christophsax commented 9 months ago

Thanks, will take a look!

christophsax commented 9 months ago

Sorry for the long wait. I need a reproducible example, so I can look into this. E.g., the output of dput(aux). See here for ideas how to create a reproducible example.

Thanks!