View source: R/runUnivariate.R
runUnivariate | R Documentation |
Based on the input model, a series of models are run that predict the dependant variable using each of the independant variables, one at a time.
runUnivariate(mod, returnIntercept = TRUE)
mod |
A model object. Support types include lm, glm, polr. |
returnIntercept |
(optional) if set to |
Loops over each independent variable in the input model, predicting the dependent variable using that IV alone.
This is useful for comparing against the results of a regression with all IV's included together. The univariate results show the individual impact of each IV, while the full regression shows how they might interact. For example if two IV's are correlated, they might both come out as significant predictors in a univariate regression, but in a full regression their betas may impact each other in unpredictable ways (they may be suppressed or exagerated depending on the nature of their interaction). For lm and glm regressions you should also refer to the "tolerance" outputted by getOutput
to identify collinearity.
NB: For categorical/factor variables, each level is outputted on its own line (except the baseline), even though only one model was run for that IV. For example, consider an "Income" variable with levels "Low", "Med" and "High" predicting age as an IV. The univariate model run would be lm(age ~ Income), but there would be two betas (and p-values added to the result table), for "IncomeMed" and "IncomeHigh". If returnIntercept
is set to TRUE
, there is only one model intecept, so this would be returned on each row i.e. the same value is repeated.
See also getUnivariate
which directly copies the result to the clipboard
# Running a linear regression using the built in mtcars data set...
m1 = lm(mpg ~ gear + factor(carb) + hp, mtcars)
# to run unvariate results for each IV:
u1 = runUnivariate(m1)
# to also return the intercept for each univariate model, run:
u1 = runUnivariate(m1, returnIntercept = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.