by_2sd: Rescale regression results by multiplying by 2 standard...

Description Usage Arguments Details Value References See Also Examples

View source: R/by_2sd.R

Description

by_2sd rescales regression results to facilitate making dot-and-whisker plots using dwplot.

Usage

1
by_2sd(df, dataset)

Arguments

df

A data.frame including the variables term (names of independent variables), estimate (corresponding coefficient estimates), std.error (corresponding standard errors), and optionally model (when multiple models are desired on a single plot) such as generated those by tidy.

dataset

The data analyzed in the models whose results are recorded in df

Details

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.

An alternative available in some circumstances is to pass a model object to 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 standardize accepts.

Value

A tidy data.frame

References

Gelman, Andrew. 2008. "Scaling Regression Inputs by Dividing by Two Standard Deviations." Statistics in Medicine, 27:2865-2873.

See Also

standardize

Examples

1
2
3
4
5
6
library(broom)
library(dplyr)

data(mtcars)
m1 <- lm(mpg ~ wt + cyl + disp, data = mtcars)
m1_df <- tidy(m1) %>% by_2sd(mtcars) # create data.frame of rescaled regression results


dotwhisker documentation built on May 19, 2017, 1:04 p.m.
Search within the dotwhisker package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.