oneBsIter function

oneBsIter - Computations for one bootstrap iteration

oneBsIter - Computations for one bootstrap iteration

An internal (un-exported) function to perform density and abundance calculations on one iteration of the bootstrap.

oneBsIter( indexDf, key, data, formula, likelihood, w.lo, w.hi, expansions, series, x.scl, g.x.scl, outputUnits, warn, area, propUnitSurveyed, pb, plot.bs, plotCovValues )

Arguments

  • indexDf: A data frame containing row indices to use for subsetting the rows of data. The actual indices are in column rowIndex.

  • key: A data frame containing the current id of the BS iteration. This is included for compatability with dplyr::group_modify, but it is not used internally. The original non-resampled data have key == "Original".

  • data: An Rdistance nested data frame containing the data to bootstrap resample. Rows of this data frame, equating to transects, are sampled using the indicies in indexDf$rowIndex.

  • formula: A standard formula object. For example, dist ~ 1, dist ~ covar1 + covar2). The left-hand side (before ~) is the name of the vector containing off-transect or radial detection distances. The right-hand side contains the names of covariate vectors to fit in the detection function, and potentially group sizes. Covariates can be either detection level or transect level and can appear in data or exist in the global working environment. Regular R scoping rules apply.

  • likelihood: String specifying the likelihood to fit. Built-in likelihoods at present are "halfnorm", "hazrate", and "negexp".

  • w.lo: Lower or left-truncation limit of the distances in distance data. This is the minimum possible off-transect distance. Default is 0. If w.lo is greater than 0, it must be assigned measurement units using units(w.lo) <- "<units>" or w.lo <- units::set_units(w.lo, "<units>"). See examples in the help for set_units.

  • w.hi: Upper or right-truncation limit of the distances in dist. This is the maximum off-transect distance that could be observed. If unspecified (i.e., NULL), right-truncation is set to the maximum of the observed distances. If w.hi is specified, it must have associated measurement units. Assign measurement units using units(w.hi) <- "<units>" or w.hi <- units::set_units(w.hi, "<units>"). See examples in the help for set_units.

  • expansions: A scalar specifying the number of terms in series to compute. Depending on the series, this could be 0 through 5. The default of 0 equates to no expansion terms of any type. No expansion terms are allowed (i.e., expansions is forced to 0) if covariates are present in the detection function (i.e., right-hand side of formula includes something other than 1).

  • series: If expansions > 0, this string specifies the type of expansion to use. Valid values at present are 'simple', 'hermite', and 'cosine'.

  • x.scl: The x coordinate (a distance) at which the detection function will be scaled. g.x.scl can be a distance or the string "max". When x.scl is specified (i.e., not 0 or "max"), it must have measurement units assigned using either library(units);units(x.scl) <- '<units>'

    or x.scl <- units::set_units(x.scl, <units>). See units::valid_udunits() for valid symbolic units.

  • g.x.scl: Height of the distance function at coordinate x. The distance function will be scaled so that g(x.scl) = g.x.scl. If g.x.scl is not a data frame, it must be a numeric value (vector of length 1) between 0 and 1.

  • outputUnits: A string specifying the symbolic measurement units for results. Valid units are listed in units::valid_udunits(). The strings for common distance symbolic units are: "m" - meters, "ft" - feet, "cm" - centimeters, "mm" - millimeters, "mi" - miles, "nmile" - nautical miles ("nm" is nano meters), "in" - inches, "yd" - yards, "km" - kilometers, "fathom" - fathoms, "chains" - chains, and "furlong" - furlongs. If outputUnits is unspecified (NULL), output units will be the same as those on distances in data.

  • warn: A logical scalar specifying whether to issue an R warning if the estimation did not converge or if one or more parameter estimates are at their boundaries. For estimation, warn should generally be left at its default value of TRUE. When computing bootstrap confidence intervals, setting warn = FALSE

    turns off annoying warnings when an iteration does not converge. Regardless of warn, after completion all messages about convergence and boundary conditions are printed by print.dfunc, print.abund, and plot.dfunc.

  • area: A scalar containing the total area of inference. Usually, this is study area size. If area is NULL (the default), area will be set to 1 square unit of the output units and density estimates will be produced. If area is not NULL, it must have measurement units assigned by the units package. The units on area must be convertible to squared output units. Units on area must be two-dimensional. For example, if output units are "foo", units on area must be convertible to "foo^2" by the units

    package. Units of "km^2", "cm^2", "ha", "m^2", "acre", "mi^2", and several others are acceptable.

  • propUnitSurveyed: A scalar or vector of real numbers between 0 and 1. The proportion of the default sampling unit that was surveyed. If both sides of line transects were observed, propUnitSurveyed

    = 1. If only a single side of line transects were observed, set propUnitSurveyed = 0.5. For point transects, this should be set to the proportion of each circle that was observed. Length must either be 1 or the total number of transects in x.

  • pb: A progress bar created with progress::progress_bar$new().

  • plot.bs: Logical. Whether to plot bootstrap estimate of detection function. A plot must already exist because this uses lines.

  • plotCovValues: Data frame containing values of covariates to plot, if plot.bs is TRUE.

Returns

A data frame containing density and abundance and other relevant statistics for one iteration of the bootstrap.

  • Maintainer: Trent McDonald
  • License: GNU General Public License
  • Last published: 2025-04-10