smu.like: Smoothed likelihood function for distance analyses

View source: R/smu.like.r

smu.likeR Documentation

Smoothed likelihood function for distance analyses

Description

Computes the likelihood of sighting distances given a kernel smooth of the histogram.

Usage

smu.like(
  a,
  dist,
  covars = NULL,
  w.lo = 0,
  w.hi,
  scale = TRUE,
  series = NULL,
  expansions = 0,
  pointSurvey = FALSE
)

Arguments

a

A data frame containing the smooth. This data frame must contain at least an $x and $y components. These components are generally the output of function density.

dist

A numeric vector containing the observed distances.

covars

Not used in smoothed distance functions. Included for compatibility with other distance likelihoods in Rdistance.

w.lo

Scalar value of the lowest observable distance. This is the left truncation of 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 largest observable distance. This is the right truncation of 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.

scale

Logical scalar indicating whether or not to scale the likelihood so it integrates to 1. This parameter is used to stop recursion in other functions. 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 values are 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.

series

Not used in smoothed distance functions. Included for compatibility with other distance likelihoods in Rdistance.

expansions

Not used in smoothed distance functions. Included for compatibility with other distance likelihoods in Rdistance.

pointSurvey

Boolean. TRUE if distances in dist are radial from point transects, FALSE if distances are perpendicular off-transect distances.

Details

The approx function is used to evaluate the smooth function at all sighting distances.

Distances outside the range w.lo to w.hi are set to NA and hence not included.

Value

A numeric vector the same length and order as dist containing the likelihood contribution (height of the smoothed function) for all distances in dist. Assuming L is the vector returned by this function, the negative log likelihood of the sighting distances 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, hence na.rm=TRUE in the sum. If scale = TRUE, the area under the smoothed curve between w.lo and w.hi is 1.0. If scale = FALSE, the integral of the smoothed curve is something else.

See Also

dfuncSmu, hazrate.like, uniform.like, negexp.like, halfnorm.like

Examples

 
set.seed(238642)
d <- units::set_units(abs(rnorm(100)), "in")
dfunc <- dfuncSmu(d~1)

L <- smu.like(a=dfunc$parameters, 
       dist=dfunc$detections$dist, 
       w.lo=dfunc$w.lo, 
       w.hi=dfunc$w.hi, 
       scale=TRUE)
-sum(log(L), na.rm=TRUE)  # the negative log likelihood


tmcd82070/Rdistance documentation built on April 10, 2024, 10:20 p.m.