Linear regression summaries with optionsSource:
# S3 method for lm summ( model, scale = FALSE, confint = getOption("summ-confint", FALSE), ci.width = getOption("summ-ci.width", 0.95), robust = getOption("summ-robust", FALSE), cluster = NULL, vifs = getOption("summ-vifs", FALSE), digits = getOption("jtools-digits", 2), pvals = getOption("summ-pvals", TRUE), n.sd = 1, center = FALSE, transform.response = FALSE, scale.only = FALSE, data = NULL, part.corr = FALSE, model.info = getOption("summ-model.info", TRUE), model.fit = getOption("summ-model.fit", TRUE), model.coefs = getOption("summ-model.coefs", TRUE), which.cols = NULL, vcov = NULL, ... )
TRUE, reports standardized regression coefficients by scaling and mean-centering input data (the latter can be changed via the
scale.onlyargument). Default is
Show confidence intervals instead of standard errors? Default is
A number between 0 and 1 that signifies the width of the desired confidence interval. Default is
.95, which corresponds to a 95% confidence interval. Ignored if
confint = FALSE.
FALSE, reports heteroskedasticity-robust standard errors instead of conventional SEs. These are also known as Huber-White standard errors. There are several options provided by
This requires the
sandwichpackage to compute the standard errors.
For clustered standard errors, provide the column name of the cluster variable in the input data frame (as a string). Alternately, provide a vector of clusters. Note that you must set
robustto either "HC1", "HC2", or "HC3" in order to have clustered standard errors ("HC4" and "HC5" are not supported.
TRUE, adds a column to output with variance inflation factors (VIF). Default is
An integer specifying the number of digits past the decimal to report in the output. Default is 2. You can change the default number of digits for all jtools functions with
options("jtools-digits" = digits)where digits is the desired number.
Show p values? If
FALSE, these are not printed. Default is
scale = TRUE, how many standard deviations should predictors be divided by? Default is 1, though some suggest 2.
If you want coefficients for mean-centered variables but don't want to standardize, set this to
TRUE. Note that setting this to false does not affect whether
scalemean-centers variables. Use
Should scaling/centering apply to response variable? Default is
If you want to scale but not center, set this to
TRUE. Note that for legacy reasons, setting
scale = TRUEand
center = FALSEwill not achieve the same effect. Default is
If you provide the data used to fit the model here, that data frame is used to re-fit the model (if
TRUE) instead of the
stats::model.frame()of the model. This is particularly useful if you have variable transformations or polynomial terms specified in the formula.
Print partial (labeled "partial.r") and semipartial (labeled "part.r") correlations with the table? Default is
FALSE. See details about these quantities when robust standard errors are used.
Toggles printing of basic information on sample size, name of DV, and number of predictors.
Toggles printing of model fit statistics.
Toggles printing of model coefficents.
Developmental feature. By providing columns by name, you can add/remove/reorder requested columns in the output. Not fully supported, for now.
You may provide your own variance-covariance matrix for the regression coefficients if you want to calculate standard errors in some way not accommodated by the
If saved, users can access most of the items that are returned in the output (and without rounding).
The outputted table of variables and coefficients
The model for which statistics are displayed. This would be most useful in cases in which
scale = TRUE.
Much other information can be accessed as attributes.
By default, this function will print the following items to the console:
The sample size
The name of the outcome variable
The R-squared value plus adjusted R-squared
A table with regression coefficients, standard errors, t-values, and p values.
There are several options available for
robust. The heavy
lifting is done by
sandwich::vcovHC(), where those are better
Put simply, you may choose from
"HC5". Based on the
recommendation of the developers of sandwich, the default is set to
"HC3". Stata's default is
"HC1", so that choice may be better
if the goal is to replicate Stata's output. Any option that is understood
vcovHC() will be accepted. Cluster-robust standard errors are
cluster is set to the name of the input data's cluster
variable or is a vector of clusters.
part.corr = TRUE, then you will get these two common
effect size metrics on the far right two columns of the output table.
However, it should be noted that these do not go hand in hand with
robust standard error estimators. The standard error of the coefficient
doesn't change the point estimate, just the uncertainty. However,
this function uses t-statistics in its calculation of the
partial and semipartial correlation. This provides what amounts to a
heteroskedasticity-adjusted set of estimates, but I am unaware of any
statistical publication that validates this type of use. Please
use these as a heuristic when used alongside robust standard errors; do
not report the "robust" partial and semipartial correlations in
King, G., & Roberts, M. E. (2015). How robust standard errors expose methodological problems they do not fix, and what to do about it. Political Analysis, 23(2), 159–179. doi:10.1093/pan/mpu015
Lumley, T., Diehr, P., Emerson, S., & Chen, L. (2002). The Importance of the Normality Assumption in Large Public Health Data Sets. Annual Review of Public Health, 23, 151–169. doi:10.1146/annurev.publhealth.23.100901.140546
Jacob Long firstname.lastname@example.org
# Create lm object fit <- lm(Income ~ Frost + Illiteracy + Murder, data = as.data.frame(state.x77)) # Print the output with standardized coefficients and 3 digits summ(fit, scale = TRUE, digits = 3) #> MODEL INFO: #> Observations: 50 #> Dependent Variable: Income #> Type: OLS linear regression #> #> MODEL FIT: #> F(3,46) = 4.049, p = 0.012 #> R² = 0.209 #> Adj. R² = 0.157 #> #> Standard errors: OLS #> ------------------------------------------------------- #> Est. S.E. t val. p #> ----------------- ---------- --------- -------- ------- #> (Intercept) 4435.800 79.773 55.605 0.000 #> Frost -65.188 109.686 -0.594 0.555 #> Illiteracy -372.251 129.914 -2.865 0.006 #> Murder 85.179 114.217 0.746 0.460 #> ------------------------------------------------------- #> #> Continuous predictors are mean-centered and scaled by 1 s.d. The outcome variable remains in its original units.