Closed James-Thorson-NOAA closed 4 months ago
It looks like rowSums
as defined by RTMB doesn't support na.rm
as an option as shown in the manual. RTMB from my understanding runs the base R functions during the report which leads to the discrepancy. It would be nice for there to be some error message when an unsupported argument is used as this happens with a few functions in a few different ways (e.g., pnorm not supporting log.p) and it's not totally intuitive.
An example:
F <- MakeTape(function(x)colSums(matrix(c(NA,NA,NA,x),2,2), na.rm=TRUE), 1)
F(2)
returns NA
vector but should be c(0,2)
.
@jgbabyn you are right - there are many more examples of misleading error messages (including pnorm
).
In developing an R-package using RTMB, I think I found that
rowSums(M, na.rm=TRUE)
when matrixM
contains some NA values causes theobj$fn()
built byobj = MakeADFun(.)
to evaluate to NA evenobj$report()
outputs a non-NA scalar as expected for the same value.I could work on a simplified example, but does this trigger any immediate thoughts on why this might happen, or how to add an informative error message for cases such as this?