triangle.like: Mixture of triangle and uniform likelihood

View source: R/triangle.like.R

triangle.likeR Documentation

Mixture of triangle and uniform likelihood

Description

Compute likelihood function for a mixture of a triangle and uniform distributions.

Usage

triangle.like(a, dist, covars, w.hi = NULL)

Arguments

a

A vector or matrix of covariate and expansion term coefficients. If matrix, dimension is k X p, where k = nrow(a)) is the number of coefficient vectors to evaluate (cases) and p = ncol(a)) is the number of covariate and expansion coefficients in the likelihood (i.e., rows are cases and columns are covariates). If a is a dimensionless vector, it is interpreted as a single row with k = 1. Covariate coefficients in a are the first q values (q <= p), and must be on a log scale.

dist

A numeric vector of length n or a single-column matrix (dimension nX1) containing detection distances at which to evaluate the likelihood.

covars

A numeric vector of length q or a matrix of dimension nXq containing covariate values associated with distances in argument dist.

w.hi

A numeric scalar containing maximum distance. The right-hand cutoff or upper limit. Ignored by some likelihoods (such as halfnorm, negexp, and hazrate), but is a fixed parameter in other likelihoods (such as oneStep and uniform).

Details

Rdistance's triangle likelihood is a mixture of a triangle and uniform distribution. The 'triangle' density function is

f(d|\theta, p) = (1 - \frac{1-p}{\theta}d) I(0 \leq d \leq \theta) + p I(\theta \le d \leq w),

where I(x) is the indicator function for event x, and w is the nominal strip width (i.e., w.hi - w.lo in Rdistance). The unknown parameters to be estimated are \theta and p (w is fixed - given by the user).

Covariates influence values of \theta via a log link function, i.e., \theta = e^{x'b}, where x is the vector of covariate values associated with distance d, and b is the vector of estimated coefficients.

Value

A list containing the following two components:

  • L.unscaled: A matrix of size nXk (n = length dist; k = number of cases = nrow(a)) containing likelihood values evaluated at distances in dist. Each row is associated with a single distance, and each column is associated with a single case (row of a). Values in this matrix are the distance function g(d) which generally have g(0) = 1. These values are "unscaled" likelihood values; they must be scaled (divided by) with the area under g(x) between w.lo and w.hi to form proper likelihood values.

  • params: A nXbXk array of the likelihood's (canonical) parameters in link space (i.e., on log scale; b = number of canonical parameters in the likelihood; k = number of cases). Rows correspond to distances in dist. Columns correspond to parameters (columns of a), and pages correspond to cases (rows of a).

See Also

dfuncEstim, abundEstim, other <likelihood>.like functions

Examples


w <- 250
Theta <- 160
p <- 0.4
d <- seq(0,w,length = w+1)
y <- (1 - ((1-p)/Theta)*d)*(d <= Theta) + p*(d > Theta)
plot(d, y, type="l", ylim = c(0,1), xlab = "Distance", ylab = "Probability")
points(Theta, p, pch=16, col = "red")
lines(c(-10,Theta), c(p,p), lty = 2, col = "grey")
axis(2, at=p, label = "p", line = 1, srt = 0, tick = FALSE)
lines(c(Theta,Theta), c(-1,p), lty = 2, col = "grey")
axis(1, at=Theta, label = "Theta", line = 2, tick = FALSE)

Theta <- 25
p <- 0.2
y <- (1 - ((1-p)/Theta)*d)*(d <= Theta) + p*(d > Theta)
lines(d, y)
points(Theta, p, pch=16, col = "red")
lines(c(-10,Theta), c(p,p), lty = 2, col = "grey")
axis(2, at=p, label = "p", line = 1, srt = 0, tick = FALSE)
lines(c(Theta,Theta), c(-1,p), lty = 2, col = "grey")
axis(1, at=Theta, label = "Theta", line = 2, tick = FALSE)

# same as above
y <- triangle.like(a = c(log(Theta), p)
                 , dist = d
                 , covars = matrix(1, length(d))
                 , w.hi = 250)
lines(d, y$L.unscaled, col = "green")


Rdistance documentation built on April 23, 2026, 1:06 a.m.