This function prepares a data frame for modeling by standardizing all continuous numeric predictors specified in a formula. It intelligently parses the formula to identify the outcome variable (which is never scaled) and all predictors. Each numeric predictor is then scaled to have a mean of 0 and a standard deviation of 1 (Z-scoring).

scale_predictors_from_formula(data, formula)

Arguments

data

A data frame containing all the variables mentioned in the formula.

formula

A model formula object (e.g., Outcome ~ Predictor1 + (1 | Group)). The function will scale all numeric variables on the right-hand side of the ~.

Value

A data frame with the same dimensions as the input, but with the continuous numeric predictors scaled and centered.