On 2025-01-02 11:20 a.m., Duncan Murdoch wrote:
On 2025-01-02 9:04 a.m., Norbert Kuder wrote:
Hello all,

I am running R version 4.4.2 (2024-10-31 ucrt) on Windows 10 x64, and
noticed something that might be a minor bug (or at least inconsistent code)
in the stats/arima.R package.
I have found:
1. A missing stop() call at line 69:
      if (length(order) == 3) seasonal <- list(order = seasonal) else
("\'seasonal\' is of the wrong length")
it should be rather:
      if (length(order) == 3) seasonal <- list(order = seasonal) else
stop("\'seasonal\' is of the wrong length")

I think you're right about this one.


2. An unused 'mod' variable assignment at line 190:

mod <- makeARIMA(trarma[[1]], trarma[[2]], Delta, kappa, SSinit)

I am trying to confirm whether this is intended behavior or possibly an
overlooked detail. Could someone please clarify if the current logic is
correct?


In the R-devel source I see mod being used in the next statement:

          mod <- makeARIMA(trarma[[1L]], trarma[[2L]], Delta, kappa, SSinit)
          val <- if(ncxreg > 0L)
              arimaSS(x - xreg %*% coef[narma + (1L:ncxreg)], mod)
          else arimaSS(x, mod)

It appears in both alternatives of the if statement.

This one is strange though:  the code in the github mirror
(https://github.com/wch/r-source/blob/4a1ed749271c52e60a85e794e6f34b0831efb1ae/src/library/stats/R/arima.R#L256-L258)
is different:

          mod <- makeARIMA(trarma[[1L]], trarma[[2L]], Delta, kappa, SSinit)
          if(ncxreg > 0) x <- x - xreg %*% coef[narma + (1L:ncxreg)]
          arimaSS(x, mod)

yet the log shows no recent changes.  I'm not sure what's going on.

Mystery solved: code like this appears several times in that file. In the occurrence here:

https://github.com/wch/r-source/blob/4a1ed749271c52e60a85e794e6f34b0831efb1ae/src/library/stats/R/arima.R#L293

it does appear that the mod value isn't being used.

Duncan Murdoch

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to