Problem with secr.fit

513 views
Skip to first unread message

Roshan Guharajan

unread,
Apr 2, 2015, 7:24:56 PM4/2/15
to secr...@googlegroups.com
Hi,

I have run into some problems with my model. It's a data set of American black bears hair snagged over a summer using baited detectors. This was divided into 4 occasions. Each occasion lasted 12 days except the 4th, which ran 22 days. I specified that in the Detection location text file as:

#Detector X Y Effort
5 497786 5379253 12 12 12 22
6 500922 5379112 12 12 12 22
#

We are interested in obtain density estimates for male and female bears, so we divided the capture histories as such.
Our study area was also a peninsula, so bears could walk off our trapping area on only 1 narrow stretch. The rest of the study area was bounded by lakes. 
We built a habitat mask using the following code:
#
female.mask=make.mask(femaletrap,type="polygon",poly=Voya[],check.poly=T)
#
where femaletrap was the female traps object (using code: traps(femalecapthist)) and Voya is our shapefile (read in using readShapePoly)

Earlier we were specifying a buffer in the make.mask object, but now realize that we don't need this. 

When we plotted the mask it seemed like all the mask points were nicely distributed over the land area excluding the water.

We then tried to run a null model with the following code:
#
null.f=secr.fit(females,mask=female.mask,CL=F)
#
But got the following warnings:
1: In secr.fit(females, mask = female.mask, CL = F) :
  possible maximization error: nlm returned code 3. See ?nlm
2: In secr.fit(females, mask = female.mask, CL = F) :
  at least one variance calculation failed

We also attempted detection as a function of time with the following code:
#
t.f=secr.fit(females,g0~t,mask=female.mask,CL=F)
#
But the following warning was given:
In secr.fit(females, g0 ~ t, mask = female.mask, CL = F) :
  possible maximization error: nlm returned code 3. See ?nlm
 
We have run our data for males using the same code and mask and seem to have no issues. 

I would be grateful for any information/help/material you could provide.
Roshan.

Murray Efford

unread,
Apr 2, 2015, 7:44:47 PM4/2/15
to secr...@googlegroups.com
Hi Roshan
The error messages are fairly general, so it's hard to know what to suggest. Often the nlm code 3 message can be ignored, but in this case you are missing at least one variance, so it's worth pressing on.  It's worth double checking the data entry with plot(females, tracks = TRUE) and summary(females). Otherwise all I can suggest is trying some variations in the call to secr.fit: method = 'Nelder-Mead' is a good start. Also try overriding the usage data with details = list(ignoreusage = TRUE). I suspect you don't really need to allow for varying usage.
Murray

Christopher Sutherland

unread,
Apr 2, 2015, 8:17:34 PM4/2/15
to Roshan Guharajan, secr...@googlegroups.com

HI Roshan,

 

Murray is right, it difficult to diagnose the cause of the nlm code error.

 

Couple of questions that may or may not help:

How many males and females are there, and how many recaps and spatial recaps? (e.g. what does summary(females) and summary(males) look like).

Also, it is possible to model the males and females together.

 

Chris

 

Chris Sutherland PhD

Postdoctoral Research Associate

Department of Natural Resources

New York Cooperative Fish and Wildlife Research Unit

Cornell University

W: webpage

E:  cs...@cornell.edu

T:  (607) 255 – 4654

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

Roshan Guharajan

unread,
Apr 2, 2015, 10:47:46 PM4/2/15
to Christopher Sutherland, secr...@googlegroups.com
Hi Chris and Murray,

Thank you for your replies.

This is what plot(females) returns

Inline images 2
I should also note that some of our detectors near the edge of the peninsula actually lie outside our mask. The reason for this being the error in GPS locations in the field and our habitat layers not matching up completely. Will this affect our g0 and sigma?

The Nelder-Mead seemed to do the trick! I have just run the null and g0~t models for females and haven't got any warnings. Would you be able to point me to some lit on what the Nelder-Mead method is doing?

We had initially discussed running both sexes combined, but chose to attempt to run different models for each. It would definitely be possible (and easy for us) to combine both sexes.

summary(females) returns:                                                       
#  output trimmed                                                                                           
Detector number   54 
Average spacing   1830.436 m 
Counts by occasion 
                   1  2  3  4 Total
n                 33 27 21 22   103
u                 33 16  4  7    60
f                 35 11 10  4    60
M(t+1)            33 49 53 60    60
losses             0  0  0  0     0
detections        44 35 25 24   128
detectors visited 31 26 22 21   100
detectors used    54 54 54 54   216

summary(males) returns:
# output trimmed
Detector number   54 
Average spacing   1830.436 m 
Counts by occasion 
                   1  2  3  4 Total
n                 33 27 21 22   103
u                 33 16  4  7    60
f                 35 11 10  4    60
M(t+1)            33 49 53 60    60
losses             0  0  0  0     0
detections        44 35 25 24   128
detectors visited 31 26 22 21   100
detectors used    54 54 54 54   216


Thank you very much for the help and guidance! Hopefully this should be able to keep us going.
Roshan.

Christopher Sutherland

unread,
Apr 2, 2015, 10:50:26 PM4/2/15
to Roshan Guharajan, secr...@googlegroups.com

Hi Roshan,

Glad you got it going!

Murray Efford

unread,
Apr 3, 2015, 12:37:14 AM4/3/15
to secr...@googlegroups.com, rosh...@gmail.com, cs...@cornell.edu
Yes, and nice to feel it yielded to a collective effort!

Follow-up points:

I think Roshan accidentally pasted the same output twice for males and females, but at least the numbers look healthy. The female plot, I'm not so sure. That large return movement to the west has me worried, and is definitely worth checking in the raw data. Even if correct, it is an outlier that has the potential to trip up the analysis (with a halfnormal detection function the probability of such an extreme is very small; an exponential function may be more accommodating).

In 'secr' we use a numerical algorithm to find the combination of parameter values that maximizes the likelihood. The default algorithm (Newton-Raphson in nlm) repeatedly approximates the gradient of the multidimensional surface and heads 'uphill'. Nelder-Mead is another algorithm widely liked for its robustness, although it is somewhat slower and requires an extra step at the end to estimate the variances. The Wikipedia entry is somewhat negative, but it generally works. See also ?optim, where it is the default method. When everything goes well, both methods give essentially the same answer.

Murray
Reply all
Reply to author
Forward
0 new messages