View source: R/integration.constant.R
integration.constant | R Documentation |
Using numerical integration, this function computes
the area under a distance function between two limits (w.lo
and w.hi
).
integration.constant(
dist,
density,
a,
covars,
w.lo,
w.hi,
series,
expansions,
pointSurvey
)
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
|
a |
Vector of parameters to pass to |
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 |
Number of expansions in |
pointSurvey |
Boolean. TRUE if point transect data, FALSE if line transect data. |
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.
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
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.