Please help! In dnbinom(x, mu = lambda, size = exp(pars[nP])) : NaNs produced

92 views
Skip to first unread message

Mark B

unread,
Jun 7, 2016, 5:44:30 PM6/7/16
to unmarked
Dear all,

I get an error when fitting a gmultmix model with nb mixture, with any combination of covariates on abundance. Here's a simple model with patch area only, but I get the same error when I include other covariates.

> Area_nb<-gmultmix(~LAREA_0000,~1,~1,data=umfGMM,mixture="NB") #area only
There were 50 or more warnings (use warnings() to see the first 50)
> warnings()
Warning messages:
1: In dnbinom(x, mu = lambda, size = exp(pars[nP])) : NaNs produced

Despite the error, the model seems to have been fit, and the estimates look reasonable:

> Area_nb

Call:
gmultmix(lambdaformula = ~LAREA_0000, phiformula = ~1, pformula = ~1, 
    data = umfGMM, mixture = "NB")

Abundance:
            Estimate     SE    z   P(>|z|)
(Intercept)     1.52 0.0641 23.8 1.05e-124
LAREA_0000      1.41 0.0535 26.4 2.02e-153

Availability:
 Estimate     SE     z   P(>|z|)
     -1.3 0.0551 -23.5 1.33e-122

Detection:
 Estimate     SE    z   P(>|z|)
     1.42 0.0496 28.6 6.48e-180

Dispersion:
 Estimate     SE     z P(>|z|)
  -0.0919 0.0791 -1.16   0.245

AIC: -4057.069

However, I don't get the same error when I fit the same models with poisson mixture.

This looks similar to questions previously asked on the group, although it's not clear if those questions were resolved.
https://groups.google.com/forum/#!msg/unmarked/riAilwgsCX0/Lm8OdM9fCUoJ
https://groups.google.com/forum/#!msg/unmarked/GuNwVDOfn38/hH1s9yccHZkJ

I've attached minimal code and data to replicate the error, and I'd really appreciate any thoughts on what I could do to fix it...

Thanks!

Mark B.
Ph.D. Candidate
University of Saskatchewan
Minimal code.R
dat.siteCovs.csv
dat.y.csv

Jeffrey Royle

unread,
Jun 7, 2016, 5:57:58 PM6/7/16
to unma...@googlegroups.com
hi Mark,
 those are not errors but warnings. The results look good. It seems like this is probably the result of the numerical optimizer getting too close to 0 or infinity for one of the parameters as it was searching the parameter space for the optimum.
regards,
andy


--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Sutherland

unread,
Jun 7, 2016, 6:55:06 PM6/7/16
to unma...@googlegroups.com

Is ‘LAREA’ scaled?

If not, I wonder if the warning would go away if it was?  

Mark B

unread,
Jun 8, 2016, 4:32:27 PM6/8/16
to unmarked
HI Andy,

Thanks for this! That gives me more confidence in the parameter estimates, which in any case look okay. Much appreciated,

Mark

Mark B

unread,
Jun 8, 2016, 4:36:25 PM6/8/16
to unmarked
Hi Chris,

Good question...I should've noted that all of the covariates were scaled before fitting models. I deleted that line from the minimal code attached to the question, but the attached data were indeed scaled. So I guess it's not that...

Cheers,

Mark
Reply all
Reply to author
Forward
0 new messages