error message when using bootdht

62 views
Skip to first unread message

vaughn...@gmail.com

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

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

in fix.by(by.x, 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,
VB

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

unread,
Oct 19, 2021, 2:36:33 AM10/19/21
to vaughn...@gmail.com, distance-sampling
Vaughn

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: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of vaughn...@gmail.com <vaughn...@gmail.com>
Sent: 18 October 2021 22:04
To: distance-sampling <distance...@googlegroups.com>
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 distance-sampl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/2f028873-4702-433e-913c-2230000886dfn%40googlegroups.com.

vaughn...@gmail.com

unread,
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. 

remotes::install_github("DistanceDevelopment/Distance")

VB 

Esperanza Iranzo

unread,
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,
                    summary_fun=bootdht_Nhat_summarize,
                    convert.units=0.001, nboot=99)
Error: in fix.by(by.x, x) : 'by' must specify a uniquely valid column.

Many thanks in advance for any help.

Kind regards,

E.I.

Eric Rexstad

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

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:

install.package("remotes")
remotes::install_github("DistanceDevelopment/Distance")

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


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

Esperanza Iranzo

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