R/par_trans.R

Defines functions inv logit expit

Documented in expit inv logit

#' Expit transformation
#'
#' @param x A real number
#'
#' @return A number in the range 0 to 1
#' @export
#'
#' @examples
#' expit(-3)
expit <- function(x) 1 / (1 + exp(-x))


#' Logit transformation
#'
#' @param p A real number that represents a probability
#'
#' @return An unconstrained real number
#' @export
#'
#' @examples
#' logit(0.5)
logit <- function(p) log(p / (1 - p))


#' Inverse of a number
#'
#' @param x A real number
#'
#' @return A real number
#' @export
#'
#' @examples
#' inv(0.5) # Should return 2
inv <- function(x) 1/x

Try the readsdr package in your browser

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

readsdr documentation built on May 29, 2024, 2:45 a.m.