normalize | R Documentation |
This function takes a continuous (double) column of data and converts it to have 0 as the lower bound and 1 as the upper bound.
normalize(outcome, true_bounds = NULL)
outcome |
Any non-character vector. Factors will be converted to numeric via coercion. |
true_bounds |
Specify this parameter with the lower and upper bound if the observed min/max of the outcome should not be used. Useful when an upper or lower bound exists but the observed data is less than/more than that bound. The normalization function will respect these bounds. |
Beta regression can only be done with a response that is continuous with a lower bound of 0 and an upper bound of 1. However, it is straightforward to transform any lower and upper-bounded continuous variable to the \[0,1\] interval. This function does the transformation and saves the original bounds as attributes so that the bounds can be reverse-transformed.
A numeric vector with an upper bound of 1 and a lower bound of 0. The original bounds are saved in the attributes "lower_bound" and "upper_bound".
# set up arbitrary upper and lower-bounded vector
outcome <- runif(1000, min=-33, max=445)
# normalize to \[0,1\]
trans_outcome <- normalize(outcome=outcome)
summary(trans_outcome)
# only works with numeric vectors and factors
try(normalize(outcome=c('a','b')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.