# False warning messages in R, is it possible?

I'm modeling GARCH-filtered standardized residuals via semiparametric distribution with Gaussian kernel and GPD (generalized pareto distribution) tails with thresholds at 5% and 95%. For some series I'm considering I have negative shape parameters $\xi$, which imply a finite left/right endpoint equal to $-\frac{\beta}{\xi}$.

Then, in the testing period (out-of-sample analysis) I use the quantile function to convert copula realizations into standardized residuals through the inverse CDF. I get the following warning:

Warning messages:

In log(1 + (xi * (as.vector(exceedances) - u))/beta) : Si è prodotto un NaN

NaNs are produced in the logarithm expression ($\xi$ shape parameter, $\beta$ scale parameter, $u$ threshold, $x$ value over the threshold). To check what that means, I solve $$1 + \xi \frac{(x-u)}{\beta}\leq0$$ when $\xi$ is negative $$x-u\geq-\frac{\beta}{\xi}$$ implying that somewhere in the future I have an excess over the threshold which exceeds the bound implied by negative $\xi$.

Since I manually verified that the message wasn't true (in the out-of-sample dataset I NEVER have standardized residuals which exceed the 5% and 95% thresholds by more than $-\frac{\beta}{\xi}$), I decided to verify this with R using this code:

p <- 0
for (i in 1:2){
for (j in 1:9){
for (z in 1:100){
if (is.nan(ronaldo[i,j,z])==TRUE) {p=1}
}
}
}


In ronaldo$[i,j,z]$ I've stored the results of the conditional means at day $i$ of asset $j$ obtained in simulation $z$ (obtained by: i. inverse of CDF of copula realizations; ii. insert in GARCH formula; iii. compute conditional mean). [yes, Ronaldo is my favorite player, and I mean the brazilian Fenomeno]. I should get $p=1$ if any value stored in ronaldo is NaN, right? Well, $p=0$.

Is this possible? Is it possible that R produces a message which isn't verified by the results? Already at a graphical inspection everything seemed alright (I only had numerical values stored in ronaldo), and that little trick with $p$ verifies this. Am I justified in "moving on" and ignoring the message since I don't have NaNs?

• I would recommend breaking down the logarithm calculation line by line to see where the NaN warnings are introduced (perhaps in the log, the division, the multiplication, or even some array broadcasting perhaps). Perhaps the log is trying to act on a negative value? Also, that for loop is not great, and can be replaced by the single line sum(is.nan(A)), (where A is a 3D array, e.g. A = array(c(1,NaN,3,4,5,6,7,8), dim=c(2,2,2))). Never ignore the warning messages. They are warning you for a reason and unless your expected a few NaN values then this is a code smell. – oliversm Dec 12 '18 at 10:08