R/p.constrain.R

Defines functions p.unconstrain p.constrain

Documented in p.constrain p.unconstrain

p.unconstrain <- function(p, lower = -Inf, upper = Inf, f = 1) {
  if (!(min(lower) == -Inf | max(upper) == Inf)) {
    p <- tan(pi/2 * (2 * p - upper - lower) / (upper - lower)) / f
  }
  p
}

p.constrain <- function(p, lower = -Inf, upper = Inf, f = 1) {
  if (!(min(lower) == -Inf | max(upper) == Inf)) {
    p <- 1/2 * (upper + lower) + (upper - lower) * atan(f * p)/pi
  }
  p
}

Try the simecol package in your browser

Any scripts or data that you put into this service are public.

simecol documentation built on July 16, 2019, 3:01 a.m.