NA in likelihood calculations

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

NA in likelihood calculations

Postby jheiniger » Tue Nov 28, 2017 1:01 am

Hello,

I have a multi-year, multi-season northern quoll trapping data set. Each year includes three trapping sessions and around 22 occasions for each session (however this does vary slightly).

To begin with, I am running simple single session SCR models for one year. The model runs fine for one session but for the other two I am getting NAs. The output is:

> fmaskpre<-make.mask(traps(fpre), buffer= 4 * initialsigmaqfpre, spacing=10, type= "trapbuffer", poly= quollarea)
> fit.HNpref<-secr.fit(fpre, detectfn = "HN", mask=fmaskpre)
Checking data
Preparing detection design matrices
Preparing density design matrix
Finding initial parameter values...
Initial values D = 0.29225, g0 = 0.13642, sigma = 110.3693
Maximizing likelihood...
Eval Loglik D g0 sigma
1 NA -1.2301 -1.8454 4.7038
2 NA -1.2301 -1.8454 4.7038
3 NA -1.2301 -1.8454 4.7038
4 NA -1.2301 -1.8454 4.7038
5 NA -1.2301 -1.8454 4.7038
6 NA -1.2300 -1.8454 4.7038
7 NA -1.2301 -1.8453 4.7038
8 NA -1.2301 -1.8454 4.7043
9 NA -1.2299 -1.8454 4.7038
10 NA -1.2300 -1.8453 4.7038
11 NA -1.2300 -1.8454 4.7043
12 NA -1.2301 -1.8452 4.7038
13 NA -1.2301 -1.8453 4.7043
14 NA -1.2301 -1.8454 4.7048
Completed in 395.47 seconds at 14:15:13 28 Nov 2017

Detector type single
Detector number 200
Average spacing 59.77485 m
x-range 652481.6 654025.7 m
y-range 8468958 8470848 m
N animals : 40
N detections : 187
N occasions : 23
Mask area : 370.37 ha

As suggested in another post I tried included starting values for density, g0 and sigma but I got the same result. I have a mask and have tried variations to buffer width, starting values and detection functions but no success. All my data is formatted the same way and I have had success for all three sessions using the following year. I have double checked my data many many times so I am hoping it is not a silly human error. I am completely stumped and any help or guidance would be very much appreciated.

Thank-you!
Jaime
jheiniger
 
Posts: 2
Joined: Sun Nov 26, 2017 9:05 pm

Re: NA in likelihood calculations

Postby murray.efford » Tue Nov 28, 2017 3:27 am

Hello Jaime
I can't spot anything wrong with the code so I guess it is something odd about the data. I'll look at it if you want to send me a copy offline. I assume you have plotted each session's data over the mask, and that are using the current version of 'secr'.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: NA in likelihood calculations

Postby jheiniger » Tue Nov 28, 2017 7:10 pm

Hi Murray,

Thank-you so much for your quick reply! You are correct, I have plotted the session over the mask and cannot find any issues, and I am using the latest version of 'secr'. Thank-you for offering to look over the data, I will send a copy now.

Cheers,
Jaime
jheiniger
 
Posts: 2
Joined: Sun Nov 26, 2017 9:05 pm

Re: NA in likelihood calculations

Postby murray.efford » Tue Nov 28, 2017 10:52 pm

For the record - we found some bugs in Jaime's data (captures at 'unused' detectors) and a bug in the verify function that meant these errors were not noticed sooner.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: NA in likelihood calculations

Postby bedford » Fri Oct 26, 2018 6:06 pm

Hello,

I'm having a very similar problem. I've hand-checked my data and as far as I can tell there are no captures at "unused detectors". I've collected two years of mark-recapture data for wild mice and am attempting to run a secr analysis for each year to determine density and sigma. The secr.fit function works just fine for one year (2016), but is not generating estimates for the second year (2017). I have different trap usage information for each year and used the suggest.buffer function to determine buffers for each year:

fit16 <- secr.fit(mouse16, model = list(D~1, g0~1, sigma~1), buffer=116, biasLimit = NA, detectfn='HN', trace=TRUE) # This works!

fit17 <- secr.fit(mouse17, model = list(D~1, g0~1, sigma~1), buffer=80, biasLimit = NA, detectfn='HN', trace=TRUE) # This does not work!

It seems that whatever parameters I try for 2017, the output is always:

link estimate SE.estimate lcl ucl
D log NA NA NA NA
g0 logit NA NA NA NA
sigma log NA NA NA NA

My guess is that it’s an issue with the autoini parameters and that I can fix these using start, but I’m unsure how to do this in an unbiased manner so that my 2016 and 2017 models remain comparable. Any suggestions you might have would be very welcome.

Thanks!
Nicole
bedford
 
Posts: 4
Joined: Thu Oct 25, 2018 5:10 pm

Re: NA in likelihood calculations

Postby murray.efford » Fri Oct 26, 2018 6:23 pm

There are no clue to what's going wrong. Maybe post the results of summary(mouse17), verify(mouse17), RPSV(mouse17) and the first few likelihood evaluations.

Specifying start should not cause bias in the final estimates.

Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: NA in likelihood calculations

Postby bedford » Mon Oct 29, 2018 10:02 am

Hi Murray,

These are the outputs of the functions you mentioned:

> summary(mouse17)
Object class capthist
Detector type multi
Detector number 630
Average spacing 10 m
x-range 0 690 m
y-range 0 80 m

Usage range by occasion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
min 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
max 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Counts by occasion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Total
n 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
u 4 2 2 3 0 1 2 4 3 4 1 3 4 1 2 0 36
f 10 5 6 4 5 2 1 0 1 1 1 0 0 0 0 0 36
M(t+1) 4 6 8 11 11 12 14 18 21 25 26 29 33 34 36 36 36
losses 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 2
detections 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
detectors visited 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
detectors used 80 328 414 414 414 495 495 495 495 495 495 495 495 495 243 135 6483

> verify(mouse17)
No errors found :-)

> RPSV(mouse17)
[1] 34.02237

> suggest.buffer(mouse17)
[1] 80
There were 23 warnings (use warnings() to see them)

> fit17 <- secr.fit(mouse17, model = list(D~1, g0~1, sigma~1), buffer=80, biasLimit = NA, detectfn='HN', trace=TRUE)
Checking data
Preparing detection design matrices
Preparing density design matrix
Finding initial parameter values...
Initial values D = 3.555, g0 = 0.01713, sigma = 23.92634
Maximizing likelihood...
Eval Loglik D g0 sigma
1 NA 1.2684 -4.0496 3.1750
2 NA 1.2684 -4.0496 3.1750
3 NA 1.2684 -4.0496 3.1750
4 NA 1.2684 -4.0496 3.1750
5 NA 1.2684 -4.0496 3.1750
6 NA 1.2685 -4.0496 3.1750
7 NA 1.2684 -4.0495 3.1750
8 NA 1.2684 -4.0496 3.1753
9 NA 1.2686 -4.0496 3.1750
10 NA 1.2685 -4.0495 3.1750
11 NA 1.2685 -4.0496 3.1753
12 NA 1.2684 -4.0494 3.1750
13 NA 1.2684 -4.0495 3.1753
14 NA 1.2684 -4.0496 3.1756
Completed in 48.42 seconds at 10:01:25 29 Oct 2018

I hope that's helpful!

Best,
Nicole
bedford
 
Posts: 4
Joined: Thu Oct 25, 2018 5:10 pm

Re: NA in likelihood calculations

Postby murray.efford » Mon Oct 29, 2018 3:09 pm

The dataset looks strong and I'm still drawing a blank. Most likely your first diagnosis was correct, and the automatic initial values are inadequate. Perversely, this can be more critical with a moderate-large dataset. I suggest increasing g0 (defaults probably biased low by low usage). Also, you could try fitting with CL = TRUE (may work) and using that model as the value for 'start'.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: NA in likelihood calculations

Postby bedford » Thu Nov 01, 2018 2:18 pm

Hi Murray,

Thanks very much for the suggestions. I've tried increasing g0 to start values ranging from 0.02 to 0.5 and unfortunately these all return secr models with NA likelihoods. Fitting with CL = TRUE also does not work. Oddly, if I remove the first two and last two trap nights (i.e., use only occasions 3-14 with > 400 traps) the model runs and returns reasonable non-NA likelihood values. Any idea why that might be? Are there issues with model fitting when usage varies greatly among occasions?

Counts by occasion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Total
n 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
u 4 2 2 3 0 1 2 4 3 4 1 3 4 1 2 0 36
f 10 5 6 4 5 2 1 0 1 1 1 0 0 0 0 0 36
M(t+1) 4 6 8 11 11 12 14 18 21 25 26 29 33 34 36 36 36
losses 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 2
detections 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
detectors visited 4 4 7 8 3 7 7 6 6 10 10 14 15 16 6 5 128
detectors used 80 328 414 414 414 495 495 495 495 495 495 495 495 495 243 135 6483

Thanks!
bedford
 
Posts: 4
Joined: Thu Oct 25, 2018 5:10 pm

Re: NA in likelihood calculations

Postby murray.efford » Thu Nov 01, 2018 3:23 pm

So we have a mystery. I don't know of any particular problem with widely varying detector usage. Could you please send me the data offline (unzipped) or post a link to a site with the data?
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Next

Return to analysis help

Who is online

Users browsing this forum: No registered users and 20 guests