dot-logFloor: Log-transformed values, with a floor (> 0)

Description Usage Arguments Examples

Description

Avoid -Inf problems when x == 0 by setting a non-zero floor value for x. This is preferred over using some log(x + d) transformation, as the choice of d is arbitrary, and will affect model fit.

Usage

1
.logFloor(x, floor = 0.3)

Arguments

x

Numeric.

floor

Minimum age value boundary. Default 0.3.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
  x <- sample(0:400, 1e7, replace = TRUE)
  floor <- 0.3
  logFloor <- log(floor)
  microbenchmark::microbenchmark(
    log(pmax(floor, x)),
    pmax(log(floor), log(x)),
    {x[x < floor] <- floor; log(x)},
    {y <- log(x); y[is.infinite(y)] <- logFloor} ## fastest; TODO: implement? not a bottleneck
  )

## End(Not run)

PredictiveEcology/LandR documentation built on Jan. 24, 2021, 12:52 a.m.