normalize | R Documentation |
This function centers and (optionally) scales the response vector and each column of the design matrix using the population variance. It is used to prepare data for Bayesian Lasso regression.
normalize(y, X, scale = TRUE)
y |
A numeric response vector. |
X |
A numeric matrix or data frame of covariates (design matrix). |
scale |
Logical; if |
A list with the following elements:
vy
: Normalized response vector.
mX
: Normalized design matrix.
mu.y
: Mean of the response vector.
sigma2.y
: Population variance of the response vector.
mu.x
: Vector of column means of X
.
sigma2.x
: Vector of population variances for columns of X
.
set.seed(1)
X <- matrix(rnorm(100 * 10), 100, 10)
beta <- c(2, -3, rep(0, 8))
y <- as.vector(X %*% beta + rnorm(100))
norm_result <- normalize(y, X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.