Skip to content

Commit 70a9880

Browse files
authored
Merge pull request #217 from DistanceDevelopment/Issue_215
Issue 215 - added conf_level and alpha arguments to ds
2 parents 5737a74 + d022e7c commit 70a9880

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Description: A simple way of fitting detection functions to distance sampling
1616
Horvitz-Thompson-like estimator) if survey area information is provided. See
1717
Miller et al. (2019) <doi:10.18637/jss.v089.i01> for more information on
1818
methods and <https://distancesampling.org/resources/vignettes.html> for example analyses.
19-
Version: 2.0.1
19+
Version: 2.0.1.9000
2020
URL: https://github.com/DistanceDevelopment/Distance/
2121
BugReports: https://github.com/DistanceDevelopment/Distance/issues
2222
Language: en-GB

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Distance 2.0.2
2+
3+
* Added arguments conf_level and alpha to ds so users can specify level of confidence in computing confidence intervals (Issue #215)
4+
15
# Distance 2.0.1
26

37
* Fixes issue with print dht2 when multipliers are a data.frame (Issue #179)

R/ds.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@
130130
#' @param winebin If you are trying to use our MCDS.exe optimizer on a
131131
#' non-windows system then you may need to specify the winebin. Please
132132
#' see [`mcds_dot_exe`][mrds::mcds_dot_exe] for more details.
133+
#' @param conf_level level of confidence used in computations of confidence interval width:
134+
#' default 0.95, must be between 0 and 1
135+
#' @param alpha provides an alternative way to specify `conf_level`. If `alpha` is specified
136+
#' then `conf_level` is set to 1-`alpha`. (This takes precedence over whatever value is given
137+
#' to `conf_level`.)
133138
#' @param dht.group deprecated, see same argument with underscore, above.
134139
#' @param region.table deprecated, see same argument with underscore, above.
135140
#' @param sample.table deprecated, see same argument with underscore, above.
@@ -340,6 +345,8 @@ ds <- function(data, truncation=ifelse(is.null(data$distend),
340345
initial_values=NULL, max_adjustments=5, er_method=2, dht_se=TRUE,
341346
optimizer = "both",
342347
winebin = NULL,
348+
conf_level = 0.95,
349+
alpha,
343350
# deprecated below here:
344351
dht.group,
345352
region.table,
@@ -531,6 +538,14 @@ ds <- function(data, truncation=ifelse(is.null(data$distend),
531538
stop("Cannot supply initial values when using AIC term selection")
532539
}
533540

541+
# check conf_level
542+
if(!((conf_level >= 0) | (conf_level <= 1))) stop("Option conf_level is not in the range 0-1")
543+
# set conf_level if alpha specified
544+
if(!missing(alpha)){
545+
if(!((alpha >= 0) | (alpha <= 1))) stop("Option alpha is not in the range 0-1")
546+
conf_level <- 1 - alpha
547+
}
548+
534549
### Actually fit some models here
535550

536551
# construct the meta data object...
@@ -731,7 +746,8 @@ ds <- function(data, truncation=ifelse(is.null(data$distend),
731746
dht_options <- list(group = dht_group,
732747
ervar = er_var,
733748
varflag = er_method,
734-
convert.units = convert_units)
749+
convert.units = convert_units,
750+
ci.width = conf_level)
735751

736752
# if no obs_table
737753
if(is.null(obs_table)){

0 commit comments

Comments
 (0)