stdmodel() refits a fitted lm/mlm object on standardized (mean 0, SD 1)
versions of its response variable(s) and its numeric predictors, leaving
factor-coded predictors on their original (raw 0/1 dummy) scale. This is the
engine behind stdcoef() for multivariate models, and behind
coefplot.mlm(..., std = TRUE).
Since the result is just an ordinary refit "lm"/"mlm" object, it also
works with other tools that expect one, e.g. lmtest::coeftest() and
broom::tidy.coeftest() on its result.
stdmodel(object, ...)# S3 method for lm
stdmodel(object, ...)
The refit model, of the same class as object
A fitted "lm" or "mlm" object
Additional arguments. Not used.
Michael Friendly
Only the response(s) and numeric predictors are standardized; factor
predictors are left as-is, since "one SD" isn't a meaningful unit for a
0/1 dummy variable. This still gives an interpretable, commonly-used effect
size for factor predictors: "SD units of y per unit change in the
predictor."
Interactions and main effects of raw variables (e.g. SES * (n + s)) are
handled correctly, since stats::model.frame() reduces a formula down to
its base variables before any interaction terms are built -- refitting on
the standardized base variables reconstructs the interaction terms
correctly.
Computed/transformed predictor terms (e.g. log(x), poly(x, 2)) are
not supported and raise an error, since standardizing the already
computed column would not do what a user expects once the model is
refit and the original expression is re-evaluated. Similarly, a
computed univariate response (e.g. log(y) ~ ...) is not supported.
Pre-compute these if you want to use such variables.
subset=/weights=/na.action= in the original fitting call are not
specially handled -- stdmodel() is designed for models fit directly via
lm(formula, data = ...).
stdcoef(), coefplot.mlm(), lmtest::coeftest(), broom::tidy.coeftest()
Other multivariate linear models:
coefplot(),
glance.mlm(),
stdcoef()
rohwer.mod <- lm(cbind(SAT, PPVT, Raven) ~ SES + n + s + ns + na + ss, data = Rohwer)
coef(rohwer.mod)
rohwer.std <- stdmodel(rohwer.mod)
coef(rohwer.std)
Run the code above in your browser using DataLab