Question about GLM: NaNs produced in global model

93 views
Skip to first unread message

Brent P

unread,
Sep 22, 2016, 9:32:15 AM9/22/16
to hmecology: Hierarchical Modeling in Ecology

Hi all,

 

I suppose this question best fits in chapter 3 of AHM but uses ch. 10. I am fitting a model set of single-season occ. models across several species, a set which includes a global model (a model including all explanatory variables - which, btw, are all continuous). I have two species with very similar detection histories:

 

Species 1: detected at 40 / 150 sites, 481 zeros, 54 ones

Species 2: detected at 51/150 sites, 462 zeros, 73 ones

 

The global model for species 1 fit with no fusses:

 

Call:

occu(formula = ~det1 ~ var1 + var2 + VAR3 + var4 + var5 + var6 +

    var7 + var13 + var8 + var9 + var10 +

    var11 + var12, data = umf)

 

Occupancy:

             Estimate    SE       z P(>|z|)

(Intercept)   -0.1550 0.414 -0.3748   0.708

var1          -0.0297 0.342 -0.0869   0.931

var2          -0.4312 0.315 -1.3699   0.171

VAR3           0.1128 0.327  0.3445   0.730

var4          -0.2006 0.318 -0.6305   0.528

var5          -0.1519 0.233 -0.6509   0.515

var6           0.5961 0.379  1.5745   0.115

var7           0.2753 0.381  0.7224   0.470

var13         -0.2396 0.323 -0.7408   0.459

var8           0.1796 0.500  0.3595   0.719

var9           0.5406 0.432  1.2525   0.210

var10         -0.2779 0.383 -0.7254   0.468

var11          0.6595 0.748  0.8819   0.378

var12          0.4991 0.586  0.8512   0.395

 

Detection:

            Estimate    SE     z  P(>|z|)

(Intercept)   -1.302 0.268 -4.85 1.24e-06

det1          -0.407 0.176 -2.32 2.06e-02

 

AIC: 352.9489

 

 

However, NaNs were produced in the global model for species 2 (the species with a greater number of detections and a higher naïve occupancy).

 

Call:
occu(formula = ~det2 ~ var1 + var2 + VAR3 + var4 + var5 + var6 + 
    var7 + var13 + var8 + var9 + var10 + 
    var11 + var12, data = umf)
 
Occupancy:
             Estimate   SE         z P(>|z|)
(Intercept)   122.975  NaN       NaN     NaN
var1           -0.538 2669 -0.000202   1.000
var2           40.897 6957  0.005879   0.995
VAR3         -117.846 2693 -0.043768   0.965
var4           17.093 6595  0.002592   0.998
var5            13.977 2363  0.005916   0.995
var6            -7.164  NaN       NaN     NaN
var7            15.911  NaN       NaN     NaN
var13           98.123  NaN       NaN     NaN
var8          -145.494  877 -0.165915   0.868
var9          -181.482  NaN       NaN     NaN
var10          -17.550 5493 -0.003195   0.997
var11         -114.546  NaN       NaN     NaN
var12          -80.370 1706 -0.047121   0.962
 
Detection:
            Estimate    SE      z  P(>|z|)
(Intercept)   -1.526 0.133 -11.46 1.99e-30
det2          -0.328 0.131  -2.51 1.22e-02
 
AIC: 405.0236 

 

I’ve tried reducing the number of covariates to pinpoint where the wacky output starts, and, out of desperation, I ran the model again but this time holding the intercept at 0. When I held the intercept at 0, the global model for species 2 ran with no problem:

 

Call:
occu(formula = ~det2 ~ var1 + var2 + VAR3 + var4 + var5 + var6 + 
    var7 + var13 + var8 + var9 + var10 + 
    var11 + var12 - 1, data = umf)
 
Occupancy (logit-scale):
             Estimate    SE       z P(>|z|)
var1          0.06263 0.320  0.1958 0.84475
var2          0.68789 0.379  1.8134 0.06977
VAR3         -0.38993 0.343 -1.1381 0.25507
var4          0.30458 0.325  0.9379 0.34829
var5          0.51705 0.430  1.2026 0.22913
var6         -0.00634 0.375 -0.0169 0.98652
var7          0.21567 0.307  0.7020 0.48269
var13         0.34075 0.332  1.0257 0.30503
var8         -1.49152 0.648 -2.3004 0.02142
var9         -1.60966 0.570 -2.8259 0.00472
var10        -0.45697 0.471 -0.9705 0.33180
var11        -1.92808 0.926 -2.0811 0.03742
var12        -1.41571 0.683 -2.0721 0.03826
 
Detection (logit-scale):
            Estimate    SE     z  P(>|z|)
(Intercept)   -1.179 0.158 -7.46 8.53e-14
det2          -0.403 0.144 -2.79 5.27e-03
 
AIC: 422.7991 

 

 

WHY did this happen? Why was everything okay without an intercept? And why did this happen with the species which had a greater number of detections and a higher naïve occupancy? (Dr. Kéry, if you are seeing this, I saw your reply on a thread in the unmarked group stating we should never hold the intercept to 0 when dealing with continuous explanatory variables. Can you elaborate?)

 

I was also curious how holding the intercept at 0 would change the estimates produced in the global model of species 1…the output is almost identical to that of species 1 with an intercept.

Species 1’s global model WITHOUT an intercept:

 

Call:
occu(formula = ~det1 ~ var1 + var2 + VAR3 + var4 + var5 + var6 + 
    var7 + var13 + var8 + var9 + var10 + 
    var11 + var12 - 1, data = umf)
 
Occupancy (logit-scale):
             Estimate    SE       z P(>|z|)
var1          -0.0297 0.375 -0.0793  0.9368
var2          -0.4493 0.336 -1.3360  0.1816
VAR3           0.1143 0.352  0.3245  0.7455
var4          -0.1809 0.345 -0.5238  0.6004
var5          -0.1709 0.237 -0.7225  0.4700
var6           0.6414 0.384  1.6688  0.0951
var7           0.3245 0.444  0.7315  0.4645
var13         -0.2534 0.348 -0.7288  0.4661
var8           0.1963 0.545  0.3602  0.7187
var9           0.5640 0.479  1.1780  0.2388
var10         -0.3136 0.407 -0.7699  0.4413
var11          0.6703 0.823  0.8143  0.4155
var12          0.5144 0.664  0.7743  0.4387
 
Detection (logit-scale):
            Estimate    SE     z  P(>|z|)
(Intercept)    -1.37 0.185 -7.44 1.00e-13
det1           -0.40 0.173 -2.31 2.07e-02
 
AIC: 351.0696 

 

Thank you very much for your time and input.

Best,

Brent

Brent P

unread,
Sep 22, 2016, 11:13:52 AM9/22/16
to hmecology: Hierarchical Modeling in Ecology
I forgot to mention that the covariates have all been standardized to have their means centered on zero.

Hugh Robinson

unread,
Sep 22, 2016, 11:21:42 AM9/22/16
to Brent P, hmecology: Hierarchical Modeling in Ecology

Hi Brent,

I don’t know that this is the answer but I would be curious to know how correlated you covariates are.

HR

--
*** Three hierarchical modeling email lists ***
(1) unmarked: for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology (this list): for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2015)
---
You received this message because you are subscribed to the Google Groups "hmecology: Hierarchical Modeling in Ecology" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/b6ef3582-056f-46da-85ef-54d13bb99fcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Schuster

unread,
Sep 22, 2016, 11:31:52 AM9/22/16
to Hugh Robinson, Brent P, hmecology: Hierarchical Modeling in Ecology

My thoughts as well looking at the huge estimate values, both positive and negative.

In my experience that's usually related to highly correlated covariates.

Cheers,
Richard

Sent from TypeApp

Brent P

unread,
Sep 22, 2016, 5:31:01 PM9/22/16
to hmecology: Hierarchical Modeling in Ecology
Thanks for the replies, all. I'm curious: if correlated explanatory variables were causing the wacky output for species 2's global model, then why didn't that happen for species 1 as well? The two species are being offered the exact same variables, model set, etc...

Richard Schuster

unread,
Sep 22, 2016, 5:42:47 PM9/22/16
to hmec...@googlegroups.com
Hi Brent,

That can have something to do with the detection histories of species 1 and 2. In some cases the correlation between variables and detection histories is such, that correlations between variables don't have an effect on the models.

In my work I sometimes had the case that species with a high number of detections (generalists) were harder to fit with a large number of variables. For species with less detections, many variables didn't have any effect on psi, largely due to the fact that when a species would have a detection at a location X, other locations with a detection would have fairly similar e.g. landcover characteristics, i.e. similar variables values.

That's just one possible explanation and really just anecdotal from working with 'messy' data before. There is probably other, more analytical explanations, that others might be able to offer.

Cheers,
Richard

Brent P

unread,
Sep 22, 2016, 5:49:18 PM9/22/16
to hmecology: Hierarchical Modeling in Ecology
Richard,

Thank you for the response - I really appreciate it!
Brent

Richard Schuster

unread,
Sep 22, 2016, 6:03:46 PM9/22/16
to hmec...@googlegroups.com
You are welcome. I struggled with this quite a bit too when I started
using occu. The way how I dealt with this sometimes was to create lists
of occu models and remove the ones that were nonsensical or did not
converge. I wrote a function for this (f.AICc.occu.sig) and am attaching
the function source script as well as a really simple example R script
in case you are interested.

I have used this here:
http://onlinelibrary.wiley.com/doi/10.1111/j.1600-0587.2012.07681.x/full
and here:
http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0099292
although the technical information is a bit limited in both.

Cheers,
Richard
OSFL_example.r
f.AIC_cut.occu.sig.used.12.10.08.r

Kery Marc

unread,
Sep 23, 2016, 3:02:01 AM9/23/16
to Brent P, hmecology: Hierarchical Modeling in Ecology
Dear Brent,

From the intercept estimate in the 2nd species, it seems that it occurs everywhere:

Occupancy:
Estimate SE z P(>|z|)
(Intercept) 122.975 NaN NaN NaN
var1 -0.538 2669 -0.000202 1.000
var2 40.897 6957 0.005879 0.995

Note that plogis(122) is equal to 1 for practical purposes. What's the observed (naive) occupancy in this species ?

Marc




-----Ursprüngliche Nachricht-----
Von: hmec...@googlegroups.com [mailto:hmec...@googlegroups.com] Im Auftrag von Brent P
Gesendet: Donnerstag, 22. September 2016 23:31
An: hmecology: Hierarchical Modeling in Ecology
Betreff: RE: Question about GLM: NaNs produced in global model

Thanks for the replies, all. I'm curious: if correlated explanatory variables were causing the wacky output for species 2's global model, then why didn't that happen for species 1 as well? The two species are being offered the exact same variables, model set, etc...

--
*** Three hierarchical modeling email lists ***
(1) unmarked: for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology (this list): for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2015)
---
You received this message because you are subscribed to the Google Groups "hmecology: Hierarchical Modeling in Ecology" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.
To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/b5d3185a-78a3-4af5-9c40-d0b5c33c482d%40googlegroups.com.

Brent P

unread,
Sep 23, 2016, 8:05:48 AM9/23/16
to hmecology: Hierarchical Modeling in Ecology
Marc,

Thanks for the response. Species 2's observed occupancy is 0.34 (51 / 150)

Kery Marc

unread,
Sep 23, 2016, 12:47:42 PM9/23/16
to Brent P, hmecology: Hierarchical Modeling in Ecology
well, that's not a lot I have to say

________________________________________
From: hmec...@googlegroups.com [hmec...@googlegroups.com] on behalf of Brent P [bpe...@siu.edu]
Sent: 23 September 2016 14:05
To: hmecology: Hierarchical Modeling in Ecology
Subject: AW: Question about GLM: NaNs produced in global model

Marc,

Thanks for the response. Species 2's observed occupancy is 0.34 (51 / 150)

--


*** Three hierarchical modeling email lists ***
(1) unmarked: for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology (this list): for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2015)
---
You received this message because you are subscribed to the Google Groups "hmecology: Hierarchical Modeling in Ecology" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hmecology+...@googlegroups.com.
To post to this group, send email to hmec...@googlegroups.com.
Visit this group at https://groups.google.com/group/hmecology.

To view this discussion on the web visit https://groups.google.com/d/msgid/hmecology/cc8d4646-97ff-4db1-aafa-5ad1e3376d94%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages