standardize: Standardize (Model) Matrix

View source: R/foehnix_functions.R

standardizeR Documentation

Standardize (Model) Matrix

Description

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).

Usage

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)

Arguments

x

matrix of dimension N x p.

...

additional arguments, ignored.

beta

regression coefficients estimated on standardized data.

X

object of class standardize.

Value

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.

Author(s)

Reto Stauffer

See Also

standardize. Used in foehnix and iwls_logit.

Examples

# 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)


retostauffer/Rfoehnix documentation built on June 5, 2023, 11:39 p.m.