Error package V.1.0.3 - More parameters than distance bins

93 views
Skip to first unread message

ducros....@gmail.com

unread,
Sep 29, 2021, 5:15:21 AM9/29/21
to distance-sampling

Hello to all,

I believe I am having a little trouble with the new version of the package Distance.

I wish to estimate bird abundances based on aerial distance sampling data (obtained from transects). 

I tried running models with different distributions and adjustement terms, without any covariates. For some models, I receive the following error message :

Fitting uniform key function with cosine(1,2,3) adjustments

Error in ddf.ds(model = dsmodel, data, meta.data = meta.data, control = control,  :

  More parameters to estimate than distance bins

Error in model fitting, returning: uniform key function with cosine(1,2) adjustments

  Error: Error in ddf.ds(model = dsmodel, data, meta.data = meta.data, control = control,  :

  More parameters to estimate than distance bins

Warning in mrds::check.mono(model, n.pts = 20) :

  Detection function is not strictly monotonic!

Warning in mrds::check.mono(model, n.pts = 20) :

  Detection function is less than 0 at some distances

I tried looking at my variable types and their content, but I cannot find where this error is coming from. I find it especially weird as it only occurs on a few combinations of the distributions and adjustement terms I am trying to run.

Would anyone have an idea where this error could come from ?

I can send my data and script off-the-list if it can help to better understand the problem.

Many thanks in advance if you can help me deal with this error message, and I wish you all a very nice day !

Delphine

Eric Rexstad

unread,
Sep 29, 2021, 5:38:21 AM9/29/21
to ducros....@gmail.com, distance-sampling
Delphine

The number of points of support for a detection function is the number of bins you have used (either at the time of collection or in subsequent binning of exact distance data).  Hence, you can only fit models to such data where the number of parameters is less than or equal to the number of bins.

The first message you report is fitting a uniform with three adjustment terms; hence a three parameter model. If the message reports "more parameters to estimate than distance bins", this suggests you have only two distance bins in your data.  Is this correct?  Into how many bins have you categorised your data? 

It is correct that the message only occurs in circumstances when the number of requested parameters exceed the number of bins.  Fitting a half normal key function without adjustments requires just a single parameter;  hence no error is issued in this situation.

From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of ducros....@gmail.com <ducros....@gmail.com>
Sent: 29 September 2021 10:15
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} [distance-sampling] Error package V.1.0.3 - More parameters than distance bins
 
--
You received this message because you are subscribed to the Google Groups "distance-sampling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to distance-sampl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/bc6dd765-7f90-4cd6-9500-5b733e21fb6bn%40googlegroups.com.

ducros....@gmail.com

unread,
Sep 29, 2021, 7:20:05 AM9/29/21
to distance-sampling
Hello Eric, 

Thank you very much for your really quick answer ! I understand what you mean. 

No, I have actually used five distance bins in my model (I have got four intervals of distance in my data. I wrote those in the cutpoints object, and added 0 as the first element in the cutpoints, which makes five bins). 

Delphine

ducros....@gmail.com

unread,
Oct 12, 2021, 4:40:07 AM10/12/21
to distance-sampling

Dear Eric and all Distance sampling users,

Following my previous emails, I am writing you again as I cannot find any reason why some of my models are not working. I get the message ‘More parameters to estimate than distance bins’ for three of my models :

-        Hn with no specification of adjustments nor orders

-        Unif with no specification of adjustments nor orders

-        And Hr with polynomial adjustment and order 2

All the other models are working fine, even those with a second order, so I do not get why these three return the error message.

As I mentioned in my previous message, I have used five distance bins in my model. I have got four intervals of distance in my data (0 to 0.08, 0.08 to 0.18, 0.18 to 0.38 and 0.38 to 0.78). I wrote those in the cutpoints object, and added 0 as the first element in the cutpoints, which makes five bins : 0, 0.08, 0.18, 0.38 and 0.78).

Is there anything wrong with my cutpoint object ?

Otherwise, any idea of why this problem is arising would be greatly appreciated !

Many thanks if you can help me with this problem, and I wish you all a very nice day !

Delphine

Eric Rexstad

unread,
Oct 12, 2021, 6:34:59 AM10/12/21
to ducros....@gmail.com, distance-sampling
Delphine

Let me try to untangle several issues to help you understand what models can be fitted to binned data.
  • cutpoints and bins are not the same; there is one more cutpoint than there are bins.  To create the four bins you describe, you need five cutpoints.  The relevant issue is the number of bins.
  • maximum number of parameters to be estimated from binned data.  This is one less than the number of bins (contrary to what I said in my email of 29Sep21). This is because knowing the total number of detections and the number of detections in three bins, you can deduce the number of detections in the fourth bin by subtraction. For your situation, you can fit models with no more than three parameters. 
  • model specification using ds()​:
    • if you do not specify the argument adjustments=​ the default of cosine adjustments will be used
    • if you do not specify the argument order=​, ds()​will attempt to fit several models with increasing numbers of adjustment terms.
    • it is possible that in fitting several models, the software will attempt to fit models with four parameters, which will fail.
What models can be fitted to data in four distance bins:
  • half normal key with at most two adjustment terms
  • uniform key function with at most three adjustment terms
  • hazard rate key function with at most one adjustment term
Using the ducknest​ data set that ships with the Distance package, I placed the detections into four bins:

library(Distance)
data("ducknest")
mycuts <- c(0, .6, 1.2, 1.8, 2.4)

I then fit three detection function models:

hn <- ds(ducknest, key = "hn", cutpoints = mycuts)
unif <- ds(ducknest, key="unif", cutpoints = mycuts)
hrpol <- ds(ducknest, key="hr", adjustment = "poly", cutpoints = mycuts)

Try this yourself, you will find that the half normal key requires no cosine adjustments, the uniform key requires a single cosine adjustment and the hazard rate key function requires no polynomial adjustments.

There is nothing wrong with your cutpoint object; hopefully this will help with your analysis.

Sent: 12 October 2021 09:40
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} Re: {Suspected Spam} [distance-sampling] Error package V.1.0.3 - More parameters than distance bins
 

ducros....@gmail.com

unread,
Oct 12, 2021, 7:51:45 AM10/12/21
to distance-sampling
Hello Eric, 

Thank you very much for your detailed answer ! Everything is much clearer to me now. Thank you also for the example with the ducknest dataset. 
Now, I can pursue my analysis thanks to your help ! 

I wish you a very nice day, 

Delphine

Reply all
Reply to author
Forward
0 new messages