bootstrap abundance estimate for only one species, when ds() model uses species as covariate

19 views
Skip to first unread message

Ben Apsley

unread,
Sep 16, 2025, 1:26:36 PM (3 days ago) Sep 16
to distance-sampling
I've been working on a project to obtain estimates for abundance of particular species at a several specific points based on point counts. The data I have includes point counts, with every species that was observed during the surveys and their corresponding distances.

I've been instructed to use the data for all species to construct a ds() model and explore different covariates, including species. So far, species is the only covariate that seems to significantly improve the model, so I've included it as a covariate. The best model is a ds() using hazard-rate with species as the one covariate:

KAEL_model.hr.sp <- ds(KAEL, transect = "point", key = "hr", truncation = "15%", formula = ~species)

Using this model, I'd like to get bootstrap abundance estimates for only certain key species. I tried to subset the original data frame into one that only has one species. The issue is that bootdht() doesn't seem to work when species only has one factor level. Here is the bootdht() I am performing and the error it yields:

KAEL_boot<-bootdht(
  KAEL_model.hr.sp,
  flatfile=KAEL_only,
  resample_strata = FALSE,
  resample_obs = FALSE,
  resample_transects = TRUE,
  nboot = 500,
  summary_fun = bootdht_Nhat_summarize,
  convert_units = 1,
  select_adjustments = FALSE,
  sample_fraction = 1,
  multipliers = NULL,
  progress_bar = "base",
  cores = 1,
)

in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

It seems that bootdht() is unable to get abundance estimates when the species covariate only has one factor level. My question is: is there an effective way to perform a bootstrap for only one, or a few select species? Would it still be accurate?

I have considered performing a bootstrap of the entire original dataset and then subsetting only the species I am interested in, but it seems that this would take an inordinate amount of time. I would like to avoid this unless it is absolutely necessary, but I'm not sure if there is another option.

Thank you for your help!

Ben


Tiago Marques

unread,
Sep 17, 2025, 3:15:30 AM (3 days ago) Sep 17
to Ben Apsley, distance-sampling
Hi Ben,

I believe there's no alternative to  bootstraping all the data. The variability you want to propagate to the estimated density precision measures is the variability in both encounter and detectability/detection function. You can only fit the detection function that you are currently using in your main analysis by using the data from all species. If you only fit the detection function with the data from your species alone, then you would not be borrowing the strength of all other species, which is what you are doing in your original model.

Cheers,

Tiago





From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Ben Apsley <bap...@gmail.com>
Sent: Tuesday, September 16, 2025 5:45:47 PM
To: distance-sampling <distance...@googlegroups.com>
Subject: [distance-sampling] bootstrap abundance estimate for only one species, when ds() model uses species as covariate
 
--
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 visit https://groups.google.com/d/msgid/distance-sampling/c9f8ed77-2d0b-4552-9ef4-6d0d59370685n%40googlegroups.com.

Eric Rexstad

unread,
Sep 17, 2025, 3:17:19 AM (3 days ago) Sep 17
to Ben Apsley, distance-sampling
Greetings Ben, welcome to the list.

When performing a bootstrap, as you know, the transects are being resampled and the detection function model is refitted to the resampled data. You can imagine how this can go wrong if you are fitting a model with a covariate for which there is only one level. That is the complaint being made by bootdht.

Another problem that could arise if you were bootstrapping with a subset of species is that some species (particularly rare species) do not occur on all transects; if you're not careful this could result in incorrect representation of sampling effort and consequently, invalid estimates.

You can see where this is leading, I come to the same conclusion you did; you'll need to bootstrap the entire dataset. Use the multiple-core argument of bootdht to speed the process.

I see Tiago has just answered, I hope his answer is similar to mine.🤷🏼

Sent: 16 September 2025 17:45
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} [distance-sampling] bootstrap abundance estimate for only one species, when ds() model uses species as covariate
 
Reply all
Reply to author
Forward
0 new messages