Learn R Programming

Rdistance (version 1.2.2)

Gamma.like: Gamma likelihood for distance analyses

Description

Computes the gamma likelihood, scaled appropriately, for use as a likelihood in estimating a distance function.

Usage

Gamma.like(a, dist, w.lo = 0, w.hi = max(dist), series = "cosine",
expansions = 0, scale = TRUE)

Arguments

a
Vector of gamma parameter values. At present, a has length 2, where a[1] = r = shape parameter of the gamma, and a[2] = lambda = multiplier in shape parameter of the gamma. Support for the gamma di
dist
Numeric vector of observed distances.
w.lo
Scalar value of the lowest observable distance. This is the left truncation value for sighting distances in dist. Same units as dist. Values less than w.lo are allowed in dist
w.hi
Scalar value of the highest observable distance. This is the right truncation value for sighting distances in dist. Same units as dist. Values greater than w.hi are allowed in di
series
Included for compatibility with F.dfunc.estim. Currently, no series expansions are implemented for the gamma likelihood.
expansions
Included for compatibility with F.dfunc.estim. Currently, no series expansions are implemented for the gamma likelihood.
scale
Logical scalar indicating whether or not to scale the likelihood to integrate to 1. This parameter is used to stop recursion in the computations. If scale equals TRUE, a numerical integration routine (

Value

  • A numeric vector the same length and order as dist containing the likelihood contribution for distances in dist. Assuming L=gamma.like(c(r,lam),dist), the full log likelihood of all the data is -sum(log(L), na.rm=T). Note that the returned likelihood value for distances less than w.lo or greater than w.hi is NA, and thus it is prudent to use na.rm=TRUE in the sum. If scale = TRUE, the integral of the likelihood from w.lo to w.hi is 1.0. If scale = FALSE, the integral of the likelihood is an arbitrary constant.

Details

This function utilizes the built-in R function dgamma to evaluate the gamma density function. Using the parameterization of dgamma, the gamma shape parameter is a[1] while the gamma scale parameter is (a[2]/gamma(r)) * (((r - 1)/exp(1))^(r - 1)). Currently, this function implements is a non-covariate version of the gamma distance function used by Becker and Quan (citation?). In future, linear equations will relate covariate values to values of the gamma paramters. This future implementation will fully replicate the distance functions of Becker and Quan.

References

Becker and Quan (?)

See Also

F.dfunc.estim, halfnorm.like, hazrate.like, uniform.like, negexp.like

Examples

Run this code
set.seed(238642)
x <- seq( 0, 100, length=100)

#   Plots showing effects of changes in shape
plot(x, Gamma.like(c(20,20), x), type="l", col="red")
lines(x, Gamma.like(c(40,20), x), type="l", col="blue")

#   Plots showing effects of changes in scale
plot(x, Gamma.like(c(20,20), x), type="l", col="red")
lines(x, Gamma.like(c(20,40), x), type="l", col="blue")


#   Estimate 'Gamma' distance function
r <- 5
lam <- 10
b <- (1/gamma(r)) * (((r - 1)/exp(1))^(r - 1))
x <- rgamma(1000, shape=r, scale=b*lam)
dfunc <- F.dfunc.estim( x, likelihood="Gamma" )
plot(dfunc)

Run the code above in your browser using DataLab