NaNs produced when using pcount ... Warning: sqrt(diag(vcov(obj))): NaNs produced

1,108 views
Skip to first unread message

Melissa Groleau

unread,
Jan 31, 2020, 1:46:34 PM1/31/20
to unmarked
I am new to using unmarked and I'm hoping this group can help me with this problem! I am running the pcount function to find a best fit model for count data. I am using forward step wise regression by running models with each covariate, selecting the one with the lowest AIC, then running another set of models with the addition of each covariate, and continuing this process until I find the model with the covariates that produce the lowest AIC. However, I am running into an issue where I get the following warning message:


Call:
pcount(formula = ~camdays ~ V1* V2 + V3 + V4, data = UMF, 
    K = 2816)

Abundance:
                      Estimate      SE      z  P(>|z|)
(Intercept)   6.86397 0.01978 347.01 0.00e+00
V1               0.03792 0.01101   3.45 5.71e-04
V2               0.03009 0.00442   6.81 9.54e-12
V3               0.00135     NaN    NaN      NaN
V4              -0.01238 0.00149  -8.32 8.64e-17
V1:V2        -0.01126 0.00149  -7.54 4.88e-14

Detection:
            Estimate       SE     z  P(>|z|)
(Intercept) -3.89031 0.054731 -71.1 0.00e+00
camdays      0.00416 0.000206  20.2 2.47e-90

AIC: 29303.11 

Warning message:
In sqrt(diag(vcov(obj))) : NaNs produced


I believe it has something to do with the vcov() 

The data have no missing values, and the variable that NaNs are produced for is context dependent. For example, sometimes NaNs are only produced for the 3rd covariate while other times, unmarked successfully models the influence of the 3rd covariate. Incorporating an interaction term into the equation also increases the frequency that NaNs are produced.

Jim Baldwin

unread,
Jan 31, 2020, 2:53:03 PM1/31/20
to unma...@googlegroups.com
You didn't mention if you've standardized the predictor variables.  (If you did, then it might require looking at the data for more clues.)

The intercept is much, much larger than all of the other coefficients which is why I bring that up.  Taking the antilog of the intercept gets one a number near 1,000 which is what would be predicted if all of the other predictors were zero.  Do you get counts that high?

Jim

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/47a5ac11-9a0c-4c34-add0-66c536334658%40googlegroups.com.

Melissa Groleau

unread,
Feb 4, 2020, 10:03:09 AM2/4/20
to unmarked
I did not standardize the predictor variables but can easily do that. My counts range from 0 to 2815, average of 2.32. I will try standardizing the predictor variables and see if I have the same issue. Thanks for your help!
To unsubscribe from this group and stop receiving emails from it, send an email to unma...@googlegroups.com.

Melissa Groleau

unread,
Feb 4, 2020, 11:05:27 AM2/4/20
to unmarked
Update:
I standardized all of the predictor variables and still got NaNs in the output. I am now thinking it is something to do with our actual count data.

We have repeated samples for three years and due to equipment failure we have missing values for some locations for certain years. These NaNs are throwing off the basic math, the true average is 329. Is there a way to input the data and tell R to ignore the missing values?  Something like this: mean(boar.detects$`2018T`, na.rm=TRUE)

Tsyon Asfaw

unread,
Mar 7, 2022, 8:31:01 AM3/7/22
to unmarked
I run the syntax below in R and encounter the warning message which says Warning message: In sqrt(diag(v)) : NaNs produced

detection_history <- read.csv("sample leo detection history.csv",
                                                            row.names = "X")
dets<- detection_history[, -1]
dets
UFO<- unmarkedFrameOccu(y=dets)
summary(UFO)

CTTable<- read.csv("OMO Dataset.csv")
cove<- as.factor(CTTable$Habitat)
cov<- as.data.frame(cove)
cov
str(cov)
detect<-apply(dets, 2, function(x){as.numeric(as.character(x))})

UFO1<-unmarkedFrameOccu(y=detect, siteCovs = cov)
UFO1

M1<- occu(~1~1, data = UFO1)
M1
M1Psi<- backTransform(M1, type= "state")
M1Psi
M1P<- backTransform(M1, type = "det")
M1CIP<- confint(M1P)
M1CIPsi<- confint(M1Psi)

Looking forward to hear your advise. Thank you very much for your time in advance.

Faithfully yours

Jim Baldwin

unread,
Mar 7, 2022, 2:09:54 PM3/7/22
to unma...@googlegroups.com
If you're willing to share the data (online or offline) or show 

summary(UFO1)

I think that the issue could be easily determined.

Jim


To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/80991380-7acb-4101-b2da-48320718d1een%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages