Learn R Programming

Distance (version 1.0.9)

gof_ds: Goodness of fit testing and quantile-quantile plots

Description

Goodness of fit testing for detection function models. For continuous distances Kolmogorov-Smirnov and Cramer-von Mises tests can be used, when binned or continuous distances are used a \(\chi^2\) test can be used.

Usage

gof_ds(
  model,
  plot = TRUE,
  chisq = FALSE,
  nboot = 100,
  ks = FALSE,
  nc = NULL,
  breaks = NULL,
  ...
)

Arguments

model

a fitted detection function.

plot

if TRUE the Q-Q plot is plotted

chisq

if TRUE then chi-squared statistic is calculated even for models that use exact distances. Ignored for models that use binned distances

nboot

number of replicates to use to calculate p-values for the Kolmogorov-Smirnov goodness of fit test statistics

ks

perform the Kolmogorov-Smirnov test (this involves many bootstraps so can take a while)

nc

number of evenly-spaced distance classes for chi-squared test, if chisq=TRUE

breaks

vector of cutpoints to use for binning, if chisq=TRUE

...

other arguments to be passed to ddf.gof

Details

Note that a bootstrap procedure is required for the Kolmogorov-Smirnov test to ensure that the p-values from the procedure are correct as the we are comparing the cumulative distribution function (CDF) and empirical distribution function (EDF) and we have estimated the parameters of the detection function. The nboot parameter controls the number of bootstraps to use. Set to 0 to avoid computing bootstraps (much faster but with no Kolmogorov-Smirnov results, of course).

Examples

Run this code
if (FALSE) {
# fit and test a simple model for the golf tee data
library(Distance)
data(book.tee.data)
tee.data <- subset(book.tee.data$book.tee.dataframe, observer==1)
ds.model <- ds(tee.data,4)
# don't make plot
gof_ds(ds.model, plot=FALSE)
}

Run the code above in your browser using DataLab