# integration.constant: Compute the integration constant for distance density... In Rdistance: Distance-Sampling Analyses for Density and Abundance Estimation

 integration.constant R Documentation

## Compute the integration constant for distance density functions

### Description

Using numerical integration, this function computes the area under a distance function between two limits (`w.lo` and `w.hi`).

### Usage

``````integration.constant(
dist,
density,
a,
covars,
w.lo,
w.hi,
series,
expansions,
pointSurvey
)
``````

### Arguments

 `dist` Vector of detection distance values. `density` A likelihood function for which the integration constant is sought. This function must be capable of evaluating values between `w.lo` and `w.hi` and have the following parameters: ‘⁠a⁠’ = Parameter vector. ‘⁠dist⁠’ = Vector of distances. ‘⁠covars⁠’ = If the density allows covariates, the covariate matrix. ‘⁠w.lo⁠’ = Lower limit or left truncation value. ‘⁠w.hi⁠’ = Upper limit or right truncation value. ‘⁠series⁠’ = Form of the series expansions, if any. ‘⁠expansions⁠’ = Number of expansion terms. ‘⁠scale⁠’ = Whether to scale function to integrate to 1. `a` Vector of parameters to pass to `density`. `covars` Matrix of covariate values. `w.lo` The lower limit of integration, or the left truncation value for perpendicular distances. `w.hi` The upper limit of integration, or the right truncation value for perpendicular distances. `series` The series to use for expansions. If `expansions` > 0, this string specifies the type of expansion. Valid values at present are 'simple', 'hermite', and 'cosine'. `expansions` Number of expansions in `density`. `pointSurvey` Boolean. TRUE if point transect data, FALSE if line transect data.

### Details

The trapezoid rule is used to numerically integrate `density` from `w.lo` to `w.hi`. Two-hundred (200) equal-sized trapezoids are used in the integration. The number of trapezoids to use is fixed and cannot be changed without re-writing this routine.

### Value

A scalar (or vector of scalars if covariates are present) that is the area under `density` between `w.lo` and `w.hi`. This scalar can be used as a divisor to scale density such that it integrates to 1.0. If x = density(...), then x / `integration.constant(density, ...)` will integrate to 1.0.

`dfuncEstim`, `halfnorm.like`

### Examples

``````# Can put any number for first argument (1 used here)
scl <- integration.constant(dist=units::set_units(1,"m")
, density=logistic.like
, covars = NULL
, pointSurvey = FALSE
, w.lo = units::set_units(0,"m")
, w.hi = units::set_units(100,"m")
, expansions = 0
, a=c(75,25))
print(scl) # Should be 75.1

x <- units::set_units(seq(0,100,length=200), "m")
y <- logistic.like( c(75,25), x, scale=FALSE ) / scl
int.y <- (x[2]-x[1]) * sum(y[-length(y)]+y[-1]) / 2  # the trapezoid rule, should be 1.0
print(int.y) # Should be 1

``````

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