View source: R/integrateGammaLines.R
| integrateGammaLines | R Documentation |
Compute integral of the Gamma distance function for line-transect surveys.
integrateGammaLines(
object,
newdata = NULL,
w.lo = NULL,
w.hi = NULL,
Units = NULL
)
object |
Either an Rdistance fitted distance function
(an object that inherits from class "dfunc"; usually produced
by a call to |
newdata |
A data frame containing new values for
the distance function covariates. If NULL and
|
w.lo |
Minimum sighting distance or left-truncation value
if |
w.hi |
Maximum sighting distance or right-truncation value
if |
Units |
Physical units of sighting distances if
|
#' Returned integrals are
\int_0^{w} \left(\frac{x}{m}\right)^{\alpha -1} e^{-(x - m)/\sigma_i}dx,
where w = w.hi - w.lo, \sigma_i is the i-th estimated scale
parameter for the Gamma distance function, and m is the mode of Gamma
(i.e., (\alpha - 1)\sigma_i.
Rdistance computes the integral using R's base function
pgamma(), which for all intents and purposes is exact.
See also Gamma.like.
A vector of areas under the distance functions represented in
object.
If object is a distance function and
newdata is specified, the returned vector's length is
nrow(newdata). If object is a distance function and
newdata is NULL,
returned vector's length is length(distances(object)). If
object is a matrix, return's length is
nrow(object).
Users will not normally call this function. It is called
internally by nLL and effectiveDistance.
integrateNumeric; integrateNegexpLines;
integrateOneStepLines
# Fake distance function object w/ minimum inputs for integration
d <- rep(1,4) %m%. # Only units needed, not values
obs <- factor(rep(c("obs1", "obs2"), 2))
beta <- c(4.0, -0.5, 1.5) # {'Intercept', b_1, shape}
w.hi <- 125
w.lo <- 20
ml <- list(
mf = model.frame(d ~ obs)
, par = beta
, likelihood = "Gamma"
, w.lo = w.lo %#% "m"
, w.hi = w.hi %#% "m"
, expansions = 0
)
class(ml) <- "dfunc"
integrateGammaLines(ml)
# Check: Integral of Gamma density from 0 to w.hi-w.lo
b <- exp(c(beta[1], beta[1] + beta[2]))
B <- Rdistance::GammaReparam(shp = beta[3], scl = b)
m <- (B$shp - 1)*B$scl
f.at.m <- dgamma(m, shape = B$shp, scale = B$scl)
intgral <- pgamma(q = w.hi - w.lo, shape = B$shp, scale = B$scl) / f.at.m
intgral
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.