Density surface modelling of line transect data. A Generalized Additive Model-based approach is used to calculate spatially-explicit estimates of animal abundance from distance sampling (also presence/absence and strip transect) data. Several utility functions are provided for model checking, plotting and variance estimation.

`dsm`

- Density surface modelling`dsm`

provides a Generalized Additive Model (GAM)-based approach to calculate spatially-explicit estimates of animal abundance from distance sampling (also presence/absence and strip transect) data. Several utility functions are provided for model checking, plotting and variance estimation.

`dsm`

A quick introduction to how to use the package can be found on the distance sampling website.

dsm news!

- Now Suggests package "sp" (needed for some parts of the mexdolphin example data)

- check that any Sample.Labels match up, if none do then throw an error. Thanks to Madhura Davate for bringing this issue to my attention.
- gamma option removed, since it now is not ignored by gam(). If using method="GCV.Cp" then gamma=1.4 should still be used (but generally we advise using REML rather than GCV for smoothing parameter selection)
- dsm now requires mgcv version 1.8-23 or higher.
- dsm.var.prop (and dsm_varprop) now throw an error when there are no covariates in the detection function as it can't do anything useful
- new function obs_exp is a diagnostic function to compare observed and expected counts at different covariate aggregations

- when mexdolphins is loaded using data(), the data no longer need to be attach()ed
- dsm.var.prop throws an error when count or N are not used as the response.
- dsm.var.prop now calls dsm_varprop, which keeps the scale parameter constant when refitting models for variance propagation. dsm_varprop provides a lower-level interface to variance propagation and is probably faster and more flexible.
- add vis.concurvity to visually assess concurvity (colinearity extended to smooth terms) in the model
- new model diagnostic function: plot_pred_by_term -- plots the effect of each smooth in the model spatially.
- remove "abundance" option for the response, use "count"
- dsm.var.prop and dsm_varprop have better diagnostics for checking the variance model hasn't done something weird
- dsm.var.movblk discards replicates where the model didn't converge
- fix potential issue with negative binomial response is used with variance propagation (due to scale parameterisations). dsm_varprop now refits nb() models as negbin() but we advise users to look into this more deeply. Thanks to Eric Rexstad for spotting this.
- fix bug in predict.dsm() where predictions for "density" response were not including the offset. Thanks to Len Thomas for spotting this.

- nasty bug in predict.dsm fixed: was logging the offset twice when newdata was not provided, leading to very odd checking plots. This also effected the results of predict() when newdata= was not specified. Thanks to Megan Ferguson for alerting us to this.
- add support for point transects(!)
- rqgam.check() now produced ONLY the linear predictor vs. randomised quantile residuals plot to avoid confusion in interpreting the other plots
- REML is now default method for smoothing parameter selection

- dsm.var.gam now has an example
- dsm.var.prop now checks that the detection function model does not have covariates

- The alpha argument now works for analytical variance reported using dsm.var.prop and dsm.var.gam print.summary and summary methods. Thanks to Jason Roberts and Eric Rexstad for spotting this issue.
- dsm now uses numDeriv::grad to calculate derivatives for variance estimation -- this should be much faster. Thanks to Jason Roberts for this fix.
- dsm now requires mrds version 2.1.15 or higher, due to internal changes
- fixed issue where Effort column was required even when segment.area was specified. Thanks to Greg Lollback for spotting this issue.
- ensured that ordering of segments matched the ordering of the observations so that aggregation of observations are correct. Thanks to Dave Fifield for reporting this bug and suggesting a fix.
- check.cols no longer checks to see if there is a column called "distance" when strip transects are being used

- dsm.var.prop uses update() rather than messing around with eval()
- print.summary.dsm.var didn't work for GAM variance when no detection function was specified, now fixed (thanks to Natalia Dellabianca for spotting this)
- Removed non-working plot() code in variance examples -- see the Mexico pantropical spotted dolphins for a proper treatment of plotting using projections (http://distancesampling.org/R/vignettes/mexico-analysis.html)
- plot.var.gam no longer crashes by default when distance data doesn't have columns "x" and "y"

- corrected offsets in examples in dsm, dsm.var.prop, dsm.var.movblk
- updated mexdolphins data with lat/long reversal in prediction data and non-list storage
- stopped use of rqgam.check from being used with non-negbin/Tweedie responses (thanks to Phil Bouchet for highlighting this issue).

- Moving block bootstrap now works when there is no detection function (suggested by Laura Williamson)
- Mexico dolphin data has had the areas of the prediction grids and segments re-projected. Thanks to Phil Bouchet for pointing out this error. Context: https://groups.google.com/d/msg/distance-sampling/oj1j8mSmnTc/3cOAAJgBw9MJ

- Speed up and reduced memory usage in variance calculations, thanks to Filipe Dias for asking about this.
- Better error when no observations are matched to the detection function. Thanks to Ricardo Lima for highlighting this.
- Check for missing columns had incorrect logic, now corrected and with tests. Thanks to Julia Migné for spotting this.

- Plotting check plots using random quantile residuals (rqgam.check) didn't work for Tweedie or tw family models, now fixed. Thanks to Laura Mannocci and Jason Roberts for pointing this out.
- Plotting CV used matrix() to coerce data into a data.frame -- thus converting all elements to the simplest type. Errors ensued. Thanks to Adrian Schiavini for finding this bug!

- dsm.var.prop and dsm.var.gam now allow you to supply a single number as an offset, then copy it as many times as you need. Thanks to Filipe Dias for suggesting this.

- dsm.var.prop will now throw an error if there is no detection function in the dsm that it's trying to calculate the variance for (thanks to Adrián Schiavini for finding this)
- variance/CV plotting threw an error when no detection function was supplied but observation=TRUE. Now error is sidestepped (again, thanks to Adrián Schiavini for finding this).

- changed stop() to warning() when data not in the detection function are included in the observation data frame, as they are automatically excluded later, bug found by Eric Rexstad and Anna Cucknell

- moving block boostrap was using observed abundances as the residuals and therefore gave wrong answers (Eric Rexstad found this bug)

- version number reporting now works (Len Thomas found this bug)
- more documentation
- by default density and presence models are now weighted by area of each segment

- switch over to new testthat spec
- added new response variables (Dhat, density.est, count, n), suggestion from Len Thomas

- check that all observed distances are within width will now throw an error

- CRAN-compatibility fixes

- updates to dsm.cor
- more unified plotting
- variance estimation tweaks for non-dsm models

- removed warning about if() comparison length in make.soapgrid need to pass bnd as a list()
- dsm.cor now handles gamm objects
- dsm.cor allows one to check residual autocorrelation in your models
- presence/absence data now no longer needs a dummy detection function object

- started NEWS file
- fixed bug where dsm.var.gam() didn't return predictions so plotting the result would fail
- silly typo in docs
- check if we're using mgcv version >= 1.7-24 for GAMM fitting and warn if not