error message when using bootdht

Skip to first unread message

Oct 18, 2021, 5:04:51 PM10/18/21
to distance-sampling

I'm attempting to use the bootdht function with a multiplier but I get error message:

in, x) : 'by' must specify a uniquely valid column

I am unsure where I can add a column to satisfy this 'merge' function error message.

Any suggestions are appreciated. 

Kind regards,

my code:

# half-normal key function, no adjustments, disturbance covariate
hn16 <- ds(grig_adults,
           truncation = truncate,
           formula = ~ weather + mangrove,
           transect = "point",
           key = "hn",
           adjustment = NULL,
           convert.units = unit_conversion, er.method = 1)

#assign multiplier
availability = data.frame(rate = 0.546, SE = 0.190)

#create list for multiplier  with appropriate names for the bootdht function
multiplier <- list(creation = availability) 

#run bootstrap on best fitting model
fm_repeats0<-bootdht(model = hn16,
                  flatfile  = grig_adults,
                  convert.units= unit_conversion,
                  nboot = 100,
                  summary_fun = bootdht_Nhat_summarize,
                  multipliers = multiplier)

Eric Rexstad

Oct 19, 2021, 2:36:33 AM10/19/21
to, distance-sampling

I suspect the problem is related to what you are estimating.  Is it the case you wish to have density estimates rather than abundance estimates (because you have not specified the size of your study area with an Area​ field?

If this is true, the problem is caused by the default bootstrap summary function bootdht_Nhat_summarize​, there is no Nhat being estimated without an area.  Therefore you'll need to create your own summary function to hand to bootdht

Dhat_summarize <- function (ests, fit)
    return(data.frame(Label = ests$individuals$D$Label, Dhat = ests$individuals$D$Estimate))

There was also a recent (29Sept21) patch to the Distance package that checked whether the Area​ field existed or was set to 0.

Does that give you the information you need?

From: <> on behalf of <>
Sent: 18 October 2021 22:04
To: distance-sampling <>
Subject: [distance-sampling] error message when using bootdht
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
To view this discussion on the web visit

Oct 21, 2021, 2:50:26 PM10/21/21
to distance-sampling

The issue was resolved by updating the Distance package to the latest version. 



Esperanza Iranzo

Oct 23, 2021, 1:22:57 PM10/23/21
to distance-sampling

Hi, I have the same problem as Vaughn with the bootdht function. I tried to update the Distance package to the latest version, but it keeps giving the error. My code is:

# hazard-rate key function, no adjustments, cluster size covariate:
hr.size <- ds(inv, key = "hr", adjustment = NULL,  order = 0,
                  convert.units = 0.001, formula = ~size, truncation = 800)
#run bootstrap on best fitting model
est.boot <- bootdht(model=hr.size, flatfile=inv,
                    convert.units=0.001, nboot=99)
Error: in, x) : 'by' must specify a uniquely valid column.

Many thanks in advance for any help.

Kind regards,


Eric Rexstad

Oct 23, 2021, 1:26:57 PM10/23/21
to Esperanza Iranzo, distance-sampling

By updating the Distance​ package, I mean updating from Github, rather than updating from CRAN.  For a Github update, use these two lines of code:


Let me know if after performing that installation the error persists.

From: <> on behalf of Esperanza Iranzo <>
Sent: 23 October 2021 18:22
To: distance-sampling <>
Subject: {Suspected Spam} Re: [distance-sampling] error message when using bootdht

Esperanza Iranzo

Oct 23, 2021, 3:53:44 PM10/23/21
to Eric Rexstad, distance-sampling
It works now, thank you!!
Reply all
Reply to author
0 new messages