expansionTerms function

expansionTerms - Distance function expansion terms

expansionTerms - Distance function expansion terms

Compute "expansion" terms that modify the shape of a base distance function.

expansionTerms(a, d, series, nexp, w)

Arguments

  • a: A vector or matrix of (estimated) coefficients. a has length pp + nexp (if a vector) or dimension (kk, pp + nexp), where pp is the number of canonical parameters in the likelihood and kk is the number of coefficient vectors to evaluate. The first pp

    elements of a, or the first pp columns if a

    is a matrix, are ignored. I.e., Expansion term coefficients are the last nexp elements or columns of a.

  • d: A vector or 1-column matrix of distances at which to evaluate the expansion terms. d should be distances above w.lo, i.e., distances - w.lo. Parameters d and w

    must have compatible measurement units.

  • series: If expansions > 0, this string specifies the type of expansion to use. Valid values at present are 'simple', 'hermite', and 'cosine'.

  • nexp: Number of expansion terms. Integer from 0 to 5.

  • w: Strip width, i.e., w.hi - w.low = range of d. Parameters d and w must have compatible measurement units.

Returns

If nexp equals 0, 1 is returned. If nexp is greater than 0, a matrix of size nnXkk containing expansion terms, where nn = length(d) and kk = nrow(a). The expansion series associated with row jj of a

are in column jj of the return. i.e., element (ii,jj) of the return is

1+k=1majkhk(xi/w).(1+a(j1)h1(x(i)/w)+...+a(jm)hm(x(i)/w)) 1 + \sum_{k=1}^{m} a_{jk} h_{k}(x_{i}/w).(1 + a(j1) h_1(x(i)/w) + ... + a(jm) h_m(x(i)/w))

(see Details).

Details

Expansion terms modify the "key" function of the likelihood manipulatively. The modified distance function is, key * expTerms where key is a vector of values in the base likelihood function (e.g., halfnorm.like()$L.unscaled

or hazrate.like()$L.unscaled) and expTerms is the matrix returned by this routine.

Let the number of expansions (nexp) be mm (mm > 0), assume the raw cyclic expansion terms of series

are hj(x)h_j(x) for the jthj-th expansion of distance xx, and that a(1),a(2),...,a(m)a(1), a(2), ..., a(m) are (estimated) coefficients for the expansion terms, then the likelihood contribution for the ithi-th distance x(i)x(i) is,

f(xiβ,a1,a2,,am)=f(xiβ)(1+k=1makhk(xi/w)).f(x(i)beta,a1,a2,...,ak)=f(x(i)beta)(1+a(1)h1(x(i)/w)+a(2)h2(x(i)/w)+...+a(m)hm(x(i)/w)). f(x_i|\beta,a_1,a_2,\dots,a_m) =f(x_i|\beta)(1 + \sum_{k=1}^{m} a_k h_{k}(x_i/w)).f(x(i)|beta,a_1,a_2,...,a_k) =f(x(i)|beta)(1 + a(1) h_1(x(i)/w) + a(2) h_2(x(i)/w) + ... + a(m) h_m(x(i)/w)).

Examples

a1 <- c(log(40), 0.5, -.5) a2 <- c(log(40), 0.25, -.5) dists <- units::set_units(seq(0, 100, length = 100), "m") w = units::set_units(100, "m") expTerms1 <- expansionTerms(a1, dists, "cosine", 2, w) expTerms2 <- expansionTerms(a2, dists, "cosine", 2, w) plot(dists, expTerms2, ylim = c(0,2.5)) points(dists, expTerms1, pch = 16) # Same as above a <- rbind(a1, a2) expTerms <- expansionTerms(a, dists, "cosine", 2, w) matlines(dists, expTerms, lwd=2, col=c("red", "blue"), lty=1) # Showing key and expansions key <- halfnorm.like(log(40), dists, 1)$L.unscaled plot(dists, key, type = "l", col = "blue", ylim=c(0,1.5)) lines(dists, key * expTerms1, col = "red") lines(dists, key * expTerms2, col = "purple")
  • Maintainer: Trent McDonald
  • License: GNU General Public License
  • Last published: 2025-04-10