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

Norbert Kuder norbert@kuder @end|ng |rom gm@||@com
Fri Jan 3 18:02:16 CET 2025


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]]



More information about the R-devel mailing list