Skip to contents

Standardises X and y to zero mean and unit variance before OLS via stats::lm.

Usage

standardized_coefficients(X, y)

Arguments

X

Predictor matrix or data.frame (n x p).

y

Outcome vector.

Value

A data.frame with columns variable, beta, se, t, p_value.

Examples

set.seed(1)
X <- matrix(rnorm(60), nrow = 20)
y <- X %*% c(0.5, -0.3, 0.2) + rnorm(20)
standardized_coefficients(X, drop(y))
#>   variable        beta        se           t    p_value
#> 1       x1  0.20751300 0.2203732  0.94164340 0.36037650
#> 2       x2 -0.01594632 0.2194202 -0.07267481 0.94296565
#> 3       x3  0.44984262 0.2243334  2.00524174 0.06215684