Skip to contents

Overdispersion causes AIC to select overly-complex models, so analysts should specify the number/order of adjustment terms manually when fitting distance sampling models to data from camera traps, rather than allowing automated selection using AIC. Howe et al (2019) described a two-step method for selecting among models of the detection function in the face of overdispersion.

Usage

QAIC(object, ..., chat = NULL, k = 2)

chi2_select(object, ...)

Arguments

object

a fitted detection function object

...

additional fitted model objects.

chat

a value of \(\hat{c}\) to be used in QAIC calculation

k

penalty per parameter to be used; default 2

Value

a data.frame with one row per model supplied, in the same order as given

Details

In step 1, and overdispersion factor (\(\hat{c}\)) is computed either (1) for each key function family, from the most complex model in each family, as the chi-square goodness of fit test statistic divided by its degrees of freedom (\(\hat{c}_1\)), or (2) for all models in the candidate set, from the raw data (\(\hat{c}_1\)). In camera trap surveys of solitary animals, \(\hat{c}_1\) would be the mean number of distance observations recorded during a single pass by an animal in front of a trap. In surveys of social animals employing human observers, \(\hat{c}_1\) would be the mean number of detected animals per detected group, and in camera trap surveys of social animals \(\hat{c}_1\) the mean number of distance observations recorded during an encounter between a group of animals and a CT. In step two, the chi-square goodness of fit statistic divided by its degrees of freedom is calculated for the QAIC-minimizing model within each key function, and the model with the lowest value is selected for estimation.

The QAIC() function should only be used select among models with the same key function (step 1). QAIC() uses \(\hat{c}_1\) by default, computing it from the model with the most parameters. Alternatively, \(\hat{c}_1\) can be calculated from the raw data and included in the call to QAIC(). Users must identify the QAIC-minimizing model within key functions from the resulting data.frame, and provide these models as arguments in ch2_select(). chi2_select() then computes and reports the chi-square goodness of fit statistic divided by its degrees of freedom for each of those models. The model with the lowest value is recommended for estimation.

References

Howe, E. J., Buckland, S. T., Després-Einspenner, M.-L., & Kühl, H. S. (2019). Model selection with overdispersed distance sampling data. Methods in Ecology and Evolution, 10(1), 38–47. doi:10.1111/2041-210X.13082

Author

David L Miller, based on code from Eric Rexstad and explanation from Eric Howe.

Examples

library(Distance)
data("wren_cuecount")

# fit hazard-rate key models
w3.hr0 <- ds(wren_cuecount, transect="point", key="hr", adjustment=NULL,
             truncation=92.5)
#> Fitting hazard-rate key function
#> AIC= 6621.473
#> No survey area information supplied, only estimating detection function.
w3.hr1 <- ds(wren_cuecount, transect="point", key="hr", adjustment="cos",
             order=2, truncation=92.5)
#> Fitting hazard-rate key function with cosine(2) adjustments
#> AIC= 6623.473
#> No survey area information supplied, only estimating detection function.
w3.hr2 <- ds(wren_cuecount, transect="point", key="hr", adjustment="cos",
             order=c(2, 4), truncation=92.5)
#> Fitting hazard-rate key function with cosine(2,4) adjustments
#> AIC= 6625.335
#> No survey area information supplied, only estimating detection function.

# fit unform key models
w3.u1 <- ds(wren_cuecount, transect="point", key="unif", adjustment="cos",
            order=1, truncation=92.5)
#> Fitting uniform key function with cosine(1) adjustments
#> AIC= 6667.045
#> No survey area information supplied, only estimating detection function.
w3.u2 <- ds(wren_cuecount, transect="point", key="unif", adjustment="cos",
            order=c(1,2), monotonicity="none",  truncation=92.5)
#> Fitting uniform key function with cosine(1,2) adjustments
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> AIC= 6618.005
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> No survey area information supplied, only estimating detection function.
w3.u3 <- ds(wren_cuecount, transect="point", key="unif", adjustment="cos",
            order=c(1,2,3), monotonicity="none", truncation=92.5)
#> Fitting uniform key function with cosine(1,2,3) adjustments
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> ** Warning: Maximum probability of detection is greater than one: invalid model fitted **
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> AIC= 6585.701
#> Warning: Detection function is not weakly monotonic!
#> Warning: Detection function is not strictly monotonic!
#> Warning: Detection function is greater than 1 at some distances
#> No survey area information supplied, only estimating detection function.

# fit half-normal key functions
w3.hn0 <- ds(wren_cuecount, transect="point", key="hn", adjustment=NULL,
             truncation=92.5)
#> Fitting half-normal key function
#> AIC= 6657.954
#> No survey area information supplied, only estimating detection function.
w3.hn1 <- ds(wren_cuecount, transect="point", key="hn", adjustment="herm",
             order=2, truncation=92.5)
#> Fitting half-normal key function with Hermite(2) adjustments
#> Error in adj.check.order(adj.series, adj.order, key) : 
#>   Hermite polynomial adjustment terms of order < 4 selected
#> 
#> 
#> All models failed to fit!
#> Error: No models could be fitted.

# stage 1: calculate QAIC per model set
QAIC(w3.hr0, w3.hr1, w3.hr2)  # no adjustments smallest
#>        df     QAIC
#> w3.hr0  2 241.6884
#> w3.hr1  3 243.6884
#> w3.hr2  4 245.6834
QAIC(w3.u1, w3.u2, w3.u3)     # 2 adjustment terms (by 0.07)
#>       df     QAIC
#> w3.u1  1 274.4930
#> w3.u2  2 274.4215
#> w3.u3  3 275.0294
QAIC(w3.hn0, w3.hn1)  # no adjustments smallest
#> Error: object 'w3.hn1' not found

# stage 2: select using chi^2/degrees of freedom between sets
chi2_select(w3.hr0, w3.u2, w3.hn0)
#>        criteria
#> w3.hr0 25.86191
#> w3.u2  27.08399
#> w3.hn0 27.05415

# example using a pre-calculated chat
chat <- attr(QAIC(w3.hr0, w3.hr1, w3.hr2), "chat")
QAIC(w3.hr0, chat=chat)
#>        df     QAIC
#> w3.hr0  2 241.6884