by_2sd rescales regression results to facilitate making dot-and-whisker plots using
A data frame including the variables
The data analyzed in the models whose results are recorded in df
by_2sd multiplies the results from regression models saved as tidy data frames for predictors that are not binary by twice the standard deviation of these variables in the dataset analyzed. Standardizing in this way yields coefficients that are directly comparable to those for untransformed binary predictors (Gelman 2008) and so facilitates plotting using
dwplot. Note that the current version of
by_2sd does not subtract the mean (in contrast to Gelman's (2008) formula). However, all estimates and standard errors of the independent variables are the same as if the mean was subtracted. The only difference to Gelman (2008) is that for all variables in the model the intercept is shifted by the coefficient times the mean of the variable.
An alternative available in some circumstances is to pass a model object to
arm::standardize before passing the results to
tidy and then on to
dwplot. The advantage of
by_2sd is that it takes as its input is a tidy data frame and so is not restricted to only those model objects that
A tidy data frame
Gelman, Andrew. 2008. "Scaling Regression Inputs by Dividing by Two Standard Deviations." Statistics in Medicine, 27:2865-2873.
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.