0
$\begingroup$

When so many warnings, what does it in fact means? Is there a problem with the validity of the stochastic forecasting models?

I am doing a stochastic forecasting of a small population with approx. 50.000 people. I am using one year age intervals 0-90+. Because so small dataset, I am borrowing the mortality rates from a population which is similar in life expectancy. Fertility rates with 0 are replaced with 1/10000. Net migrations are calculated with the function ”netmigration” in the ”demography” package.

Then I use the function ”pop.sim” for simulating say 1.000 sample paths of population 40 years ahead.

When doing so with set.seed(505) and N=1000, I don't get any warning. But nearly all other values in set.seed and or N=1000 give me the warning messages: NAs produced.

For example when my code is

set.seed(300)
sim300 <- pop.sim(mort=mort.fcast, fert=fert.fcast, mig=mig.fcast, 
                  firstyearpop=mort.fo,N=300, mfratio=mfratio,
                  bootstrap=FALSE)

The first ten messages looks like this:

Warning messages:

1: In rpois(rep(1, length(fert$age)), lambda) : NAs produced  
    2: In rbinom(1, B, mfratio/(1 + mfratio)) : NAs produced  
    3: In rpois(1, Ef0 * mort.sim$female[1, j, i]) : NAs produced  
4: In rpois(1, Em0 * mort.sim$male[1, j, i]) : NAs produced  
    5: In rpois(rep(1, p), Ef * mort.sim$female[, j, i]) : NAs produced  
6: In rpois(rep(1, p), Em * mort.sim$male[, j, i]) : NAs produced  
    7: In rpois(1, Ef0 * mort.sim$female[1, j, i]) : NAs produced  
8: In rpois(1, Em0 * mort.sim$male[1, j, i]) : NAs produced
    9: In rpois(rep(1, p), Ef * mort.sim$female[, j, i]) : NAs produced
10: In rpois(rep(1, p), Em * mort.sim$male[, j, i]) : NAs produced  

How shall I interpret these messages? Does this indicate that something is wrong in the data, models, forecasting or simulation procedures?

My first guess is that, in message nr. 1, a negative value is assigned to ”lambda”?, if so, is there a way to prevent that?

The most important question is whether these NAs produced is an indicator of the validity of the models and or the forecast of the population?

Is anyone out there who can say something about what is going on here?

$\endgroup$
3
  • $\begingroup$ I suspect this will attract close votes because it it too related to R and the demography package. CV is not a suitable place to post such questions. Try the Maintainer as I mention below in my Answer. $\endgroup$ Sep 17, 2013 at 17:50
  • $\begingroup$ This question appears to be off-topic because it is about a technical issue with a specific piece of software or application. $\endgroup$ Sep 17, 2013 at 17:51
  • $\begingroup$ First make sure you are using the most recent version of the package. Second, please provide a reproducible example. Third, this question is probably best sent as a bug report to github.com/robjhyndman/demography/issues $\endgroup$ Sep 27, 2013 at 4:28

1 Answer 1

1
$\begingroup$

Is the mean parameter going negative (Ef0 * mort.sim$female[1, j, i])? That will certainly generate the warning you see:

> rpois(10, -1)
 [1] NA NA NA NA NA NA NA NA NA NA
Warning message:
In rpois(10, -1) : NAs produced

This almost certainly indicates an issue (simulated values are generating NAs which could have knock on consequences); it makes no sense to have a rate parameter that is negative. This would make me question the simulations. You'll need to track down why this is happening. For starters, do you get similar warnings if you run the example at ?pop.sim. If not that would rule out a general problem with the code (That example is not run during pkg example checks) and which might point to your data as the problem.

If in doubt you could check with the maintainer, a certain Rob J Hyndman, also of this parish, who may comment here or you may need to contact directly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.