NormalizeBoundedVariable: Take a variable bounded above/below/both and return an...

View source: R/NormalizeBoundedVariable.R

NormalizeBoundedVariableR Documentation

Take a variable bounded above/below/both and return an unbounded (normalized) variable.

Description

This transforms bounded variables so that they are not bounded. First variables are coerced away from the boundaries. by a distance of tol. The natural log is used for variables bounded either above or below but not both. The inverse of the standard normal cumulative distribution function (the quantile function) is used for variables bounded above and below.

Usage

NormalizeBoundedVariable(x, constraints, tol = stats::pnorm(-5), trim = TRUE)

Arguments

x

A vector, matrix, array, or dataframe with value to be coerced into a range or set.

constraints

A list of constraints. See the examples below for formatting details.

tol

Variables will be forced to be at least this far away from the boundaries.

trim

If TRUE values in x < lower and values in x > upper will be set to lower and upper, respectively, before normalizing.

Value

An object of the same class as x with the values transformed so that they spread out over any part of the real line.

A variable x that is bounded below by lower is transformed to log(x - lower).

A variable x that is bounded above by upper is transformed to log(upper - x).

A variable x that is bounded below by lower and above by upper is transformed to qnorm((x-lower)/(upper - lower)).

Author(s)

Stephen R. Haptonstahl srh@haptonstahl.org

Examples

  constraints=list(lower=5)           # lower bound when constrining to an interval
  constraints=list(upper=10)          # upper bound when constraining to an interval
  constraints=list(lower=5, upper=10) # both lower and upper bounds

FastImputation documentation built on Sept. 25, 2023, 5:06 p.m.