Mark-Recapture Distance Sampling

Animal abundance estimation via conventional, multiple covariate and mark-recapture distance sampling (CDS/MCDS/MRDS). Detection function fitting is performed via maximum likelihood. Also included are diagnostics and plotting for fitted detection functions. Abundance estimation is via a Horvitz-Thompson-like estimator.


mrds - Mark-Recapture Distance Sampling

![Build Status](https://travis-ci.org/DistanceDevelopment/mrds.svg? branch=master) This package for R analyzes single or double observer distance sampling data for line or point sampling. It is used in program DISTANCE as one of the analysis engines. Supported double observer configurations include independent, trial and removal. All options in mrds are not yet fully supported via DISTANCE.

Getting mrds

The easiest way to ensure you have the latest version of mrds, is to install Hadley Wickham's devtools package:

  install.packages("devtools")

then install mrds from github:

  library(devtools)
  install_github("DistanceDevelopment/mrds")

Otherwise:

  • One can download a Windows package binary using the "Releases" tab in github. To install in R, from the R menu, use "Packages\Install from Local Zip file" and browse to location of downloaded zip.
  • Or, download package source files.
  • Finally the current stable version of mrds is available on CRAN, though this may be up to a month out of date due to CRAN policy.

References

The following are references for the methods used in the package.

Buckland, S. T., J. Laake, et al. (2010). "Double observer line transect methods: levels of independence." Biometrics 66: 169-177.

Borchers, D. L., J. L. Laake, et al. (2006). "Accommodating unmodeled heterogeneity in double-observer distance sampling surveys." Biometrics 62(2): 372-378.

Buckland, S. T., D. R. Anderson, et al., Eds. (2004). Advanced distance sampling: estimating abundance of biological populations. Oxford, UK; New York, Oxford University Press. (see chapter 6).

News

  • updated initialvalues calculation for hazard-rate -- now uses Beavers & Ramsay method to scale parameters for hazard-rate
  • automatic parameter rescaling for covariate models when covariates are poorly scaled. Now default for nlminb method
  • minor speed-up to logistic code when distance is a covariate
  • link to distance sampling Google Groups in help
  • duplicate non-convergence warning/error removed
  • warning of singular Hessian is now a warning()
  • re-wrote the debug output to be easier to read
  • dht now has an option (ci.width) to specify confidence interval width in output (thanks to David Pavlacky for the suggestion)
  • monotonicity now operates over left->right truncation for models that are left truncated and will fail with an error message if many integration intervals are used. Thanks to Tiago Marques for highlighting this issue.
  • \donttest{} examples are now \dontrun{}.
  • Bug in unif+cos(1) models when using monotonicity constraints and randomised starting points. Since the model only has 1 parameter, there is a bug in selecting columns in Rsolnp starting value code that makes the result be a vector, which then doesn't work with an apply later. Workaround of not using randomised starting values in mrds for that model. Thanks to Nathalie Cavada for finding this bug.

  • Fixed bug in pdot.dsr.integrate.logistic which was giving incorrect AIC values for FI models with binned data for points or lines.

  • Fixed issue where returned optimisation obejct got accessed without being checked to see if it's result was an error, causing problems when encapsulating ddf in other functions.

  • added testing directory to .Rbuildignore, tests are now not included in built packages and are not run on CRAN. For tests use the source packages on github.

BUG FIXES

  • removed test that failed on CRAN's testing

CHANGES

  • removed doeachint/cgftab code, which used a spline approximation to the effective strip width/effective area when a half-normal detection function was used. This has been replaced with exact calculation via the error function (erf).
  • tests updated accordingly
  • monotonically constrained models now use a bunch of random start points -- uses gosolnp() from Rsolnp
  • re-fitting by jiggling parameters refined to multiply by a uniform variable with limits set as the upper and lower bounds (+/-1) so jiggling can go either way, on approximately the same scale as the parameters
  • corrected documentation for predict methods, which incorrectly stated what is returned for point transect models. Thanks to Thibault Dieuleveut for spotting this.

BUG FIXES

  • fixed 2 bugs in create.varstructure; the first was for removal method which was being treated as a trial method. The second was when obs.table was not specified (Region and sample labels in dataframe for each obs) and there was dual observers. In that case it was doubling the number of observations.
  • fixed a bug in dht.deriv which had not been setup for removal; thanks to John Boulanger for noticing and reporting both of these bugs

BUG FIXES

  • Standardisation was being applied to detection functions (such that g(0)=1) when there were no adjustments (which is uneccesary) but also caused issues when using gamma detection functions as this should be calculated at g(apex) instead. Standardisation code has been removed for when there are no adjustments and the correct scaling used for the gamma when there are. Thanks to Thomas Doniol-Valcroze for alerting us to this bug.
  • Partial name-matching in dht was fixed. Produced warning but not error.

NEW FEATURES

  • Tests for gamma detection functions
  • Observations are automatically ordered by object and observer fields (if included) in ddf as expected by double observer analysis. A erroneous error message can be created if they are not ordered correctly or worse. Thanks to Ainars Aunins for bringing this to our attention.
  • Added function create_document() which will run a shiny application interface to mrds and will create a knitr document from a template. The template currently is only for a single observer analysis and is behind on all of the features for the app which is fairly complete.

BUG FIXES

  • some key+adjustment models failed to converge due to bugs in the optimisation code (mainly unif+cosine models)

NEW FEATURES

  • optimisation tips help page at ?"mrds-opt"

CHANGES

  • models with both adjustment terms and covariates are now allowed
  • mono.check function checks that a detection function is monotonic over its range (at the observed covariate combinations if covariates are included)

CHANGES

  • new testthat changes test locations etc, this has been sorted out.
  • which= argument in plot.* now sorts the which first, so plots will always be in order
  • plot.ds is now more friendly to par() users, thanks to Jason Roberts for the pointer

BUG FIXES

  • uniform+cosine detection functions were ignored when using monotonicity constraints, now they can be used together
  • mono.strict=TRUE didn't automatically turn on mono=TRUE, extra logic to correct this
  • montonicity constraints did not use standardised (g(x)/g(0) detection functions, so if g(x)>1 monotonicity constraints were voilated. Now standardised detection functions are used. Thanks to Len Thomas for noticing this bug.

BUG FIX

  • predict.io.fi did not work for new data (thanks to Len Thomas and Phil Hammond for pointing this out)

CHANGES

  • general documentation updates
  • simplication and re-structuring of internals

CHANGES

  • internal re-structuring of summary methods
  • more tests

CHANGES

  • plot.ds now has a new argument, if TRUE (default) it will create a new window for each plot.
  • general janitorial work inside plotting methods, removing and simplifying old code; (hopefully) no new features.

CHANGES

  • Warning now issued when truncation is set to the largest distance by default.

  • updated dht documentation

CHANGES

  • modified det.tables and plot.det.tables so it does not create and plot some tables depending on observer configuration (io,trial,removal).

  • to plot functions (other than plot.ds) added argument subtitle=TRUE (default). It can be either TRUE, FALSE. If TRUE it shows sub-titles for plot type. If FALSE, no subtitles are shown. With this argument it is possible to get subtitles without main title.

  • set iterlimit=1 in call to rem.glm from ddf.rem.fi to prevent convergence issues in getting starting values.

  • created average.line.cond and it is now used in place of calcp.mrds which was computing average line for conditional detection function by weighting values by estimated population proportions for each covariate value. It is now weighted by sample proportions (mean value).

BUG FIXES

  • patched dht.se so if vc1=NA it will not fail

  • patched plot.ds to only issue dev.new when not using another graphics device so it plays nice with Distance.

BUG FIXES

  • patched bug in dht which was returning incorrect values in bysample for sample.area and Dhat.

  • patched code in dht.se so it would skip over variance component for p when key=unif and p=1.

CHANGES

  • modified code in detfct.fit.opt and io and rem functions to adapt to changes in optimx

  • removed old depends statements to optimx and Rsolnp; uses import

BUG FIXES

  • fixed usage and example lines that were too long

BUG FIXES

  • for full independence methods, the calculation for the distance sampling component was for unbinned data only. Code has been added to compute this component correctly for binned data. This required changes to each of the ddf.x.fi routines and for the logistic integration routines.

CHANGES

  • Modified flpt.lnl code to set integrals to 1E-25 if <=0

  • In integrate.pdf a vector argument for the integration range is converted to matrix if of length 2.

  • ddf.gof will now use breaks set for binned data unless others are specified.

NEW FEATURES

  • Added threshold detection functions ("th1" and "th2") which required some minor changes in other functions for summary/print.

  • Added xlab and ylab arguments to plot functions to over-ride default labels

CHANGES

  • Modified DESCRIPTION so only R 2.15 or greater is allowed. Needed for optimHess jll(12/10/2012)

NEW FEATURES

  • New option plot=TRUE/FALSE in qqplot.ddf(), for when you only want the K-S and CvM test statistics, not plotting. dlm(11/13/2012)

BUG FIXES

  • Fixed problem when obs dataframe in call to dht (which links observations to samples and regions) contained fields also in observation dataframe. Now only fields needed from obs are selected before merge. dlm(11/13/2012)
  • Unchanged version sent out with Distance in summer 2012

NEW FEATURES

  • Restructured likelihood/integration code for fitting ds models

  • Adjustment functions will now work with binned data. Code was added to assure that fields distbegin and distend are available if binned=TRUE and breaks are set as well.

  • Added argument adj.exp which if set to TRUE will use keyexp(adj) rather than keyadj to keep f(x)>0

  • Added following restrictions for adjustments: if uniform key, adj.scale must be "width"; if non-uniform key and adj.scale="width", doeachint set to TRUE because scale integration will not work.

  • Changed code in several functions so a uniform key with no adjustment functions could be used.

  • New option plot=TRUE/FALSE in qqplot.ddf(), for when you only want the K-S and CvM test statistics, not plotting.

BUG FIXES

  • Fixed inconsistencies in use and documentation of showit argument

  • Fixed a bug where groups were not recognised in dht() when the size column occurred in both model data and observation table. (Thanks to Darren Kidney for spotting this.)

NEW FEATURES

  • Example code for binned point count data added to help for ddf

  • Modified ddf.rem.fi and ddf.io.fi to use starting values from iterative offset glm to make optimization more robust

  • Added a restriction so no one attempts fitting adjustment functions with covariates.

  • Added some code to assure all of the necessary fields are available for binned data (binned=TRUE).

BUG FIXES

  • Patched create.ddfobj so that point counts with binned data would work properly

  • Patched ddf.ds such that stored data in object$data has detected=1

  • Patched ddf.io.fi to throw an error when optimx() does not converge

  • Patched ddf.io.fi and ddf.rem.fi so inclusion of factor(observer) will work in formula

  • Patched dht, dht.se and covered.region.dht so it would handle 0 observations

  • Suppress package messages from optimx

  • Patched fpt.lnl, flt.lnl, print.ddf, model.description, summary.ds, print.summary.ds and coef.io, coef.trial, coef.rem, plot.io, plot.trial, and plot.rem to handle uniform key function.

NEW FEATURES

  • First version submitted to CRAN

BUG FIXES

  • Fixed code in dht.se such that it uses sample size from detection model in Satterthwaite approximation rather than size of selected subset of observations.

  • Fixed coef functions so they would return parameter estimates for adjustment functions if any.

BUG FIXES

  • Changed flt.var to compute variance of average p correctly for point transects.

  • Numerous changes by dlm to optimization code

  • Changes to documentation to remove non-ASCII characters

NEW FEATURES

  • Major rewrite to ddf and summary functions to handle adjustment functions

BUG FIXES

  • Changes to det.tables and gof functions to use include.lowest=TRUE in calls to cut function

  • Changed all usage of T and F to TRUE and FALSE

  • For changes in 2.0.2 and earlier see ONEWS

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("mrds")

2.1.14 by David Miller, 10 months ago


Browse source code at https://github.com/cran/mrds


Authors: Jeff Laake <jeff.laake@noaa.gov>, David Borchers <dlb@st-and.ac.uk>, Len Thomas <len.thomas@st-and.ac.uk>, David Miller <dave@ninepointeightone.net> and Jon Bishop


Documentation:   PDF Manual  


Task views: Analysis of Ecological and Environmental Data


GPL (>= 2) license


Imports optimx, mgcv, numDeriv, Rsolnp

Suggests testthat


Depended on by Distance, dsm, mads.


See at CRAN