From 32faa315fea26656eea3432b1ea4f2b55474673a Mon Sep 17 00:00:00 2001 From: Len Thomas Date: Thu, 16 Oct 2025 22:36:35 +0100 Subject: [PATCH] Added conf_level argument to ds - issue 215 --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/ds.R | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 91717e8..0a8bde4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ Description: A simple way of fitting detection functions to distance sampling Horvitz-Thompson-like estimator) if survey area information is provided. See Miller et al. (2019) for more information on methods and for example analyses. -Version: 2.0.1 +Version: 2.0.1.9000 URL: https://github.com/DistanceDevelopment/Distance/ BugReports: https://github.com/DistanceDevelopment/Distance/issues Language: en-GB diff --git a/NEWS.md b/NEWS.md index 597d381..290d2d3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Distance 2.0.2 + +* Added argument conf_level to ds so users can specify level of confidence in computing confidence intervals (Issue #215) + # Distance 2.0.1 * Fixes issue with print dht2 when multipliers are a data.frame (Issue #179) diff --git a/R/ds.R b/R/ds.R index 346a8bc..a2f20d8 100644 --- a/R/ds.R +++ b/R/ds.R @@ -130,6 +130,7 @@ #' @param winebin If you are trying to use our MCDS.exe optimizer on a #' non-windows system then you may need to specify the winebin. Please #' see [`mcds_dot_exe`][mrds::mcds_dot_exe] for more details. +#' @param conf_level level of confidence used in computations of confidence interval width: default 0.95, must be between 0 and 1 #' @param dht.group deprecated, see same argument with underscore, above. #' @param region.table deprecated, see same argument with underscore, above. #' @param sample.table deprecated, see same argument with underscore, above. @@ -340,6 +341,7 @@ ds <- function(data, truncation=ifelse(is.null(data$distend), initial_values=NULL, max_adjustments=5, er_method=2, dht_se=TRUE, optimizer = "both", winebin = NULL, + conf_level = 0.95, # deprecated below here: dht.group, region.table, @@ -531,6 +533,9 @@ ds <- function(data, truncation=ifelse(is.null(data$distend), stop("Cannot supply initial values when using AIC term selection") } + # check conf_level + if(!((conf_level >= 0) | (conf_level <= 1))) stop("Option conf_level is not in the range 0-1") + ### Actually fit some models here # construct the meta data object... @@ -731,7 +736,8 @@ ds <- function(data, truncation=ifelse(is.null(data$distend), dht_options <- list(group = dht_group, ervar = er_var, varflag = er_method, - convert.units = convert_units) + convert.units = convert_units, + ci.width = conf_level) # if no obs_table if(is.null(obs_table)){