From norbert@kuder @end|ng |rom gm@||@com  Fri Jan  3 18:02:16 2025
From: norbert@kuder @end|ng |rom gm@||@com (Norbert Kuder)
Date: Fri, 3 Jan 2025 18:02:16 +0100
Subject: [Rd] stats/ar.R issue - else branch never used
Message-ID: <CAMUMQUSHKprCOdv9RsmhtwHb9YmUm9L=cbiFqE5mFy2u-cYZZQ@mail.gmail.com>

Hello,

There is another issue in stats/ar.R:

https://github.com/wch/r-source/blob/4a1ed749271c52e60a85e794e6f34b0831efb1ae/src/library/stats/R/ar.R#L142
https://github.com/wch/r-source/blob/4a1ed749271c52e60a85e794e6f34b0831efb1ae/src/library/stats/R/ar.R#L429
https://github.com/wch/r-source/blob/4a1ed749271c52e60a85e794e6f34b0831efb1ae/src/library/stats/R/ar.R#L570

When aic is passed as a boolean (T/F), the code does the following:

maic <- min(aic)      # 0 if F, 1 if T
xaic <- setNames(if(is.finite(maic)) xaic - min(xaic) else
                                                    ifelse(xaic == maic, 0,
Inf), 0L:order.max)

Because maic is always 0 or 1, is.finite(maic) is always T, so the else
branch (ifelse(xaic == maic, 0, Inf)) never executes.

Please check if my finding is valid.

Best regards,
Norbert Kuder

	[[alternative HTML version deleted]]



[Rd] stats/ar.R issue - else branch never used
Norbert Kuder