I am migrating our applications from Python 3.6 / R 3.4.4 / Ubuntu 18.04 to Python 3.9 / R 4.2.2 / Debian Bookworm and have run into a problem where the seas() function fails. Although my actual code uses Python and rpy2, I was able to distill the failing example into an easy-to-try Python-free code
library("seasonal")
data = c(88.7, 89.0, 89.5, 89.9, 90.2, 90.5, 90.1, 90.8, 90.8, 90.9, 91.1, 91.7, 91.4, 92.0, 92.4, 93.2, 93.2, 93.0, 93.0, 93.6, 93.8, 93.9, 94.0, 94.5, 93.8, 94.3, 94.6, 95.2, 95.3, 95.0, 95.1, 95.5, 95.8, 96.4, 96.5, 96.7, 95.9, 96.4, 96.9, 97.0, 97.4, 97.2, 97.0, 97.5, 97.9, 98.1, 98.2, 98.4, 97.4, 98.1, 98.4, 99.0, 98.9, 99.2, 98.8, 99.3, 99.4, 99.6, 99.4, 99.6, 98.8, 99.3, 99.5, 99.7, 99.9, 99.9, 99.9, 100.3, 100.4, 100.7, 100.7, 101.0, 100.0, 100.4, 101.0, 100.9, 101.1, 101.3, 101.2, 101.6, 101.9, 101.9, 102.1, 102.6, 101.6, 102.4, 102.8, 103.4, 103.7, 103.8, 103.7, 104.3, 104.6, 104.6, 104.9, 105.2, 104.3, 104.9, 105.1, 105.5, 105.9, 105.7, 105.6, 106.5, 106.5, 106.5, 106.8, 107.2, 106.3, 106.9, 107.1, 107.4, 107.7, 107.6, 107.7, 108.1, 108.3, 108.4, 108.6, 108.6, 108.0, 108.6, 108.8, 108.9, 109.0, 109.2, 109.7, 109.0, 109.7, 109.9, 109.8, 110.1, 109.6, 109.6, 110.0, 110.3, 111.1, 111.7, 111.7, 112.5, 112.9, 113.7, 114.2, 114.8, 114.4, 115.3, 116.3, 117.1, 117.7, 118.2, 118.6, 119.5, 120.2, 121.0, 121.4, 122.1, 121.0, 122.4, 123.5, 125.1, 126.1, 126.3, 126.7, 126.9, 127.5, 127.9, 127.6, 128.3, 127.1, 127.9, 128.7, 129.9, 130.5, 130.8, 130.9, 131.5, 131.6, 132.1, 132.1, 132.4, 131.9, 132.4, 133.1, 134.7458499483, 135.2327015929, 135.4159773557, 135.6323765742, 136.1550422742, 136.3911489199, 136.8179029858, 136.8813759958, 137.5241597399, 136.433086938, 137.1452096555, 137.8572796109)
z <- ts(data, frequency=12, start = c(2010,1))
seas(z)
This fails with R 4.2.2 / Debian Bookworm
Error: X-13 run failed
Errors:
- The covariance matrix of the ARMA parameters is singular;
cannot compute t-statistics for the ARMA parameters. Program
error(s) halt execution for
/tmp/RtmpCk2llq/x13393485b3fa137/iofile.spc
However works correctly (or at least does not crash) with R 3.4.4 / Ubuntu 18.04
Call:
seas(x = z)
Coefficients:
Easter[8] AO2020.Jul AR-Seasonal-12 MA-Nonseasonal-01
0.001628 0.008127 0.292051 0.876366
MA-Seasonal-12
0.999203
This data example however works correctly in both places:
data2 = c(92.77, 93.18, 94.22, 94.42, 94.52, 94.54, 93.98, 94.3, 94.69, 94.97, 94.88, 95.27, 93.77, 94.1, 95.45, 95.94, 95.92, 96.0, 95.11, 95.43, 96.23, 96.49, 96.39, 96.82, 95.19, 95.53, 96.98, 97.44, 97.43, 97.49, 96.73, 96.89, 97.67, 97.9, 97.76, 98.26, 96.46, 96.76, 98.42, 98.39, 98.58, 98.63, 97.78, 97.95, 98.67, 98.72, 98.69, 98.96, 97.25, 97.71, 99.13, 99.38, 99.25, 99.38, 98.55, 98.87, 99.42, 99.42, 99.35, 99.7, 97.87, 98.38, 99.77, 100.3, 100.52, 100.57, 99.93, 100.24, 100.71, 100.87, 100.25, 100.61, 98.84, 99.24, 100.8, 101.02, 101.32, 101.37, 100.8, 101.04, 101.51, 101.62, 101.04, 101.47, 99.7, 100.07, 101.5, 102.29, 102.25, 102.57, 102.02, 102.28, 102.68, 102.51, 101.97, 102.4, 100.67, 101.07, 102.63, 103.04, 103.51, 103.56, 103.18, 103.34, 103.66, 103.72, 102.92, 103.35, 101.8, 102.07, 103.42, 104.37, 104.32, 104.72, 104.08, 104.32, 104.71, 104.83, 104.27, 104.69, 102.91, 103.31, 104.49, 105.26, 105.26, 105.59, 105.31, 104.71, 104.93, 105.07, 104.53, 104.93, 104.36, 104.46, 105.47, 106.04, 106.26, 106.53, 106.06, 106.35, 106.9, 107.22, 107.26, 107.68, 106.73, 107.3, 108.59, 109.73, 110.25, 110.5, 110.33, 110.92, 111.98, 112.6, 112.6, 113.26, 112.38, 113.32, 114.74, 115.87, 116.14, 116.55, 116.38, 116.78, 117.05, 117.31, 116.61, 117.14, 116.05, 116.83, 118.12, 118.95, 119.47, 119.89, 119.7, 120.09, 120.17, 120.47, 119.78, 120.32, 119.18, 119.83, 120.99, 122.1, 122.22, 122.39, 121.95, 122.22, 122.33, 122.56, 121.87, 122.3, 121.11, 121.72, 123.06, 124.12, 124.42, 124.75, 124.5, 124.81, 124.84, 125.06, 124.3, 124.77)
z2 <- ts(data2, frequency=12, start = c(2010,1))
seas(z2)
Call:
seas(x = z2)
Coefficients:
Easter[8] LS2020.Aug LS2021.Jan LS2022.Sep
0.001862 -0.007733 0.008640 0.005531
AR-Nonseasonal-01 AR-Nonseasonal-02 AR-Nonseasonal-03 MA-Nonseasonal-01
-0.134327 0.226694 0.316049 -0.202356
MA-Seasonal-12
0.348978
I also tested this on Windows 10 / R 4.2.2 and had the same error with the first example and same answer with the second example.
Guidance and suggestions appreciated.
Not a straight answer but some additional debugging information: it is almost certainly a newer version of the X-13 executable (provided via the x13binary
R package) that is causing this.
For several versions of R (3.6.3, 4.0.5, 4.1.3) and using the most recent version of seasonal
that would install (for some older versions of R that was seasonal 1.8.4
rather than seasonal 1.10.0
) the behaviour is very consistent: x13binary 1.1.39-3
returns your "expected" result, while any more recent version (starting from x13binary 1.1.57-1
) halts with an error. This is all on Windows.
You should keep in mind that this could just as well mean that the older result was wrong though... the error indicates numerical issues (i.e. input-related) rather than an actual crash. You can still get the more recent versions to produce results if you don't log-transform your result (e.g. seas(..., transform.function="none")
), though those will not match the older version where X-13 picked the log transform as a best fit.