Skip to content

Instantly share code, notes, and snippets.

@derekpowell
Last active March 24, 2018 06:45
Show Gist options
  • Save derekpowell/758ef0223832464b821d323974e329a6 to your computer and use it in GitHub Desktop.
Save derekpowell/758ef0223832464b821d323974e329a6 to your computer and use it in GitHub Desktop.
rescale variable on open interval (0, 1)
rescale_beta <- function(x, lower, upper) {
# rescales onto the open interval (0,1)
# rescales over theoretical bounds of measurement, specified by "upper" and "lower"
N <- length(x)
res <- (x - lower) / (upper - lower)
res <- (res * (N - 1) + .5) / N
return(as.vector(res))
}
@derekpowell
Copy link
Author

Rescale variable onto (0, 1) for beta regression. Based on Smithson & Verkuilen (2006), see http://dx.doi.org/10.1037/1082-989X.11.1.54.supp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment