Skip to contents

Formats output of lm model object for a publication-ready format.

Note: this function uses the modelEffectSizes function from the lmSupport package to get the sr2 effect sizes.

Usage

nice_lm(model, b.label = "b", mod.id = TRUE, ...)

Arguments

model

The model to be formatted.

b.label

What to rename the default "b" column (e.g., to capital B if using standardized data for it to be converted to the Greek beta symbol in the nice_table function).

mod.id

Logical. Whether to display the model number, when there is more than one model.

...

Further arguments to be passed to the lm function for the models.

See also

Checking simple slopes after testing for moderation: nice_lm_slopes, nice_mod, nice_slopes. Tutorial: https://rempsyc.remi-theriault.com/articles/moderation

Examples

# Make and format model
model <- lm(mpg ~ cyl + wt * hp, mtcars)
nice_lm(model)
#>   Dependent Variable Predictor df           b          t            p
#> 1                mpg       cyl 27 -0.36523909 -0.7180977 4.788652e-01
#> 2                mpg        wt 27 -7.62748929 -5.0146028 2.928375e-05
#> 3                mpg        hp 27 -0.10839427 -3.6404181 1.136403e-03
#> 4                mpg     wt:hp 27  0.02583659  3.2329593 3.221753e-03
#>           sr2
#> 1 0.002159615
#> 2 0.105313085
#> 3 0.055502405
#> 4 0.043773344

# Make and format multiple models
model2 <- lm(qsec ~ disp + drat * carb, mtcars)
my.models <- list(model, model2)
nice_lm(my.models)
#>   Model Number Dependent Variable Predictor df            b          t
#> 1            1                mpg       cyl 27 -0.365239089 -0.7180977
#> 2            1                mpg        wt 27 -7.627489287 -5.0146028
#> 3            1                mpg        hp 27 -0.108394273 -3.6404181
#> 4            1                mpg     wt:hp 27  0.025836594  3.2329593
#> 5            2               qsec      disp 27 -0.006222635 -1.9746464
#> 6            2               qsec      drat 27  0.227692395  0.1968842
#> 7            2               qsec      carb 27  1.154106215  0.7179431
#> 8            2               qsec drat:carb 27 -0.477539959 -1.0825727
#>              p          sr2
#> 1 4.788652e-01 0.0021596150
#> 2 2.928375e-05 0.1053130854
#> 3 1.136403e-03 0.0555024045
#> 4 3.221753e-03 0.0437733438
#> 5 5.861684e-02 0.0702566891
#> 6 8.453927e-01 0.0006984424
#> 7 4.789590e-01 0.0092872897
#> 8 2.885720e-01 0.0211165564