View source: R/triangle.like.R
| triangle.like | R Documentation |
Compute likelihood function for a mixture of a triangle and uniform distributions.
triangle.like(a, dist, covars, w.hi = NULL)
a |
A vector or matrix of covariate
and expansion term
coefficients. If matrix, dimension is
k X p, where
k = |
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 |
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). |
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.
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).
dfuncEstim,
abundEstim,
other <likelihood>.like functions
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.