rnagaussian-mixture-model

Error in quantile.default(newX[, i], ...) : missing values and NaN's not allowed if 'na.rm' is FALSE


I am getting the following error:

Error in quantile.default(newX[, i], ...) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE

When I try to run

quantiles.abundance <- apply(TiticacaPrediction.ab$mu.0.samples, 2, quantile, 
                     prob = c(0.025, 0.5, 0.975))

I can see that for some reason when I ran the predict() function on the N-mixed model I have it produced 2 columns entirely of NAs, but am not sure firstly why it did so, and secondly if there is some manner to remove them? I am using the spAbundance library in R.


Solution

  • if I understood problem correctly, you get NA for your result, most probably you have some missing values in your column, and it is not possible to calculate quantile because of NA and due to by default quatile use na.rm = False, you can try to change parameter to True, and it will omit NAs

    quantiles.abundance <- apply(TiticacaPrediction.ab$mu.0.samples, 2, quantile, prob = c(0.025, 0.5, 0.975), na.rm = TRUE)