Learn R Programming

Rdistance (version 1.3.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 distribution, as parameterized here, is (r > 1) and (lambda >= 0). No series or expansions are currently implemented for the gamma likelihood.

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, but are ignored and their contribution to the likelihood is set to NA in the output.

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 dist, but are ignored and their contribution to the likelihood is set to NA in the output.

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 (integration.constant) is called, which in turn calls this likelihood function again with scale = FALSE. Thus, this routine knows when its value is being used to compute the likelihood and when its value is being used to compute the constant of integration. All user defined likelihoods must have and use this parameter.

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 a non-covariate version of the gamma detection function used by Becker and Quang (2009). 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 Quang (2009).

References

Becker, E. F., and P. X. Quang, 2009. A Gamma-Shaped Detection Function for Line-Transect Surveys with Mark-Recapture and Covariate Data. Journal of Agricultural, Biological, and Environmental Statistics 14(2):207-223.

See Also

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

Examples

Run this code
# NOT RUN {
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