View source: R/foehnix_functions.R
standardize | R Documentation |
Function to standardize the columns of a matrix, used to
standardize the model matrix before estimating the regression
coefficients of a generalized linear model (iwls_logit
).
Destandardize coefficients. Brings coefficients back to the "real" scale if standardized coefficients are used when estimating the logistic regression model (concomitant model).
standardize(x, ...)
## S3 method for class 'matrix'
standardize(x, ...)
## S3 method for class 'standardized'
scale(x, ...)
## S3 method for class 'standardized'
destandardize(x, ...)
destandardize_coefficients(beta, X)
x |
matrix of dimension |
... |
additional arguments, ignored. |
beta |
regression coefficients estimated on standardized data. |
X |
object of class |
Returns a matrix of the same dimension as input x
but with standardized data. The return object is of class
c("standardized", "matrix")
which comes with some handy
S3 methods.
Returns 'scaled:scale' used for standardization
Returns destandardized regression coefficients, same object
as input beta
.
Reto Stauffer
standardize
. Used in foehnix
and iwls_logit
.
# Example data set
data("airquality")
airquality <- na.omit(airquality)
# Create model matrix
X <- model.matrix(Ozone ~ ., data = airquality)
print(head(X))
# Standardize
S <- standardize(X)
print(head(S))
is.standardized(X)
is.standardized(S)
# Get parameters used for standardization
center(S)
scale(S)
# Destandardize
D <- destandardize(S)
# Check
all.equal(D, X, check.attributes = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.