View source: R/dplyr_wrappers.R
run_lm | R Documentation |
Within a dplyr-pipe, running lm() is often complicated be the placing of the data argument. This wrapper places data first and allows to run standardized models.
run_lm(df, formula, std = FALSE, rename_std = FALSE, ...)
df |
Data for modeling |
formula |
an object of class |
std |
Logical. Should variables be standardised? This is only applied to numeric variables, factors are left unchanged so that their coefficients remain interpretable. |
rename_std |
Logical. Should standardised variables be indicated by _sd suffix |
... |
Arguments passed on to
|
Note that the model call in the lm-object is replaced by the call to this
function - that means that update()
cannot be used.
After experiencing an issue with passing weights, I rewrote this based on the code suggested by "Vandenman" here https://stackoverflow.com/questions/38683076/ellipsis-trouble-passing-to-lm
See (Fox, 2015) for an argument why dummy variables should never be standardised. If you want to run a model with all variables standardised, one option is 'QuantPsyc::lm.beta()'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.