Extended `dfuncEstim` examples"

knitr::opts_chunk$set(echo = TRUE)

Following is a series of dfuncEstim calls that show the calling parameters for popular distance sampling options.

library(Rdistance)
data("sparrowDetectionData")
data("sparrowSiteData")

Half-normal function with right truncation

dfunc <- dfuncEstim(formula = dist ~ 1
                  , detectionData = sparrowDetectionData
                  , w.hi = units::set_units(100, "m"))
dfunc
plot(dfunc, col="grey")

Half-normal function, truncation, group sizes

dfunc <- dfuncEstim(formula = dist ~ groupsize(groupsize)
                  , detectionData = sparrowDetectionData
                  , w.hi = units::set_units(100, "m"))
dfunc
plot(dfunc, col="grey")

Half-normal function with factor covariate

Increase the maximum number of iterations if distance function convergence is an issue. The observer covariate is constant within transects and appears in the site data frame (sparrowSiteData), so the site data frame must be included in the call to dfuncEstim. Otherwise, the site data frame is not needed until abundance is estimated (in abundEstim).

dfuncObs <- dfuncEstim(formula = dist ~ observer
                     , detectionData = sparrowDetectionData
                     , siteData = sparrowSiteData
                     , w.hi = units::set_units(100, "m")
                     , control=RdistanceControls(maxIter=1000))
dfunc
plot(dfunc, col="grey")

Hazard-rate function with covariate, truncation, and variable group sizes

Group sizes do not influence the estimated distance function. Only distance to the group is used. But, group sizes are associated with individual detections and are used to estimate abundance in function abundEstim. If abundance will be estimate and group sizes vary, Rdistance requires specification of a group size variable in the call to dfuncEstim. Here, groupsize is a column in the detection data frame and group sizes are specified using groupsize() in the formula.

dfuncObs <- dfuncEstim(formula = dist ~ observer + groupsize(groupsize)
                     , likelihood = "hazrate"
                     , detectionData = sparrowDetectionData
                     , siteData = sparrowSiteData
                     , w.hi = units::set_units(100, "m"))
dfunc
plot(dfunc, col="grey")

Hazard rate, covariate, group sizes, left and right truncation

Right truncation at 100 meters, left truncation at 20 meters. If x.scl is not specified as greater than w.lo, a warning is issued.

dfunc <- dfuncEstim(formula = dist ~ observer + groupsize(groupsize)
                     , likelihood = "hazrate"
                     , detectionData = sparrowDetectionData
                     , siteData = sparrowSiteData
                     , w.lo = units::set_units(20, "m")
                     , x.scl = units::set_units(20, "m")
                     , w.hi = units::set_units(100, "m"))
dfunc
plot(dfunc, col="grey")

Hazard rate, covariate, group sizes, specify g(0)

Specify $g(0)$ at the intercept by setting g.x.scl. This scales the entire distance function. Here, probability of detection on the transect is known to be 0.8.

dfunc <- dfuncEstim(formula = dist ~ observer + groupsize(groupsize)
                     , likelihood = "hazrate"
                     , detectionData = sparrowDetectionData
                     , siteData = sparrowSiteData
                     , g.x.scl = 0.8)
dfunc
plot(dfunc, col="grey")


Try the Rdistance package in your browser

Any scripts or data that you put into this service are public.

Rdistance documentation built on July 9, 2023, 6:46 p.m.