[Stable]
The function will extract the relevant coefficients from the regression models (see below for supported model).

model_summary(
  model,
  digits = 3,
  assumption_plot = FALSE,
  quite = FALSE,
  streamline = FALSE,
  return_result = FALSE
)

Arguments

model

an model object. The following model are tested for accuracy: lm, glm, lme, lmer, glmer. Other model object may work if it work with parameters::model_parameters()

digits

number of digits to round to

assumption_plot

Generate an panel of plots that check major assumptions. It is usually recommended to inspect model assumption violation visually. In the background, it calls performance::check_model().

quite

suppress printing output

streamline

print streamlined output. Only print model estimate and performance.

return_result

It set to TRUE, it return the model estimates data frame.

Value

a list of model estimate data frame, model performance data frame, and the assumption plot (an ggplot object)

References

Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133–142. https://doi.org/10.1111/j.2041-210x.2012.00261.x

Examples

# I am going to show the more generic usage of this function
# You can also use this package's built in function to fit the models
# I recommend using the integrated_multilevel_model_summary to get everything

# lme example
lme_fit <- lme4::lmer("popular ~ texp  + (1 | class)",
  data = popular
)

model_summary(lme_fit)
#> 
#>  
#> Model Summary
#> Model Type = Linear Mixed Effect Model (fitted using lme4 or lmerTest)
#> Outcome = popular
#> Predictors = texp
#> 
#> Model Estimates
#> ───────────────────────────────────────────────────────────────────────────────────────────────────
#>           Parameter  Effects  Coefficient       t    df     SE          p     Group          95% CI
#> ───────────────────────────────────────────────────────────────────────────────────────────────────
#>         (Intercept)    fixed        4.197  22.552  1996  0.186  0.000 ***            [3.832, 4.562]
#>                texp    fixed        0.062   5.212  1996  0.012  0.000 ***            [0.038, 0.085]
#>      SD (Intercept)   random        0.737     NaN   NaN    NaN    NaN         class      [NaN, NaN]
#>   SD (Observations)   random        1.105     NaN   NaN    NaN    NaN      Residual      [NaN, NaN]
#> ───────────────────────────────────────────────────────────────────────────────────────────────────
#> 
#> Goodness of Fit
#> ──────────────────────────────────────────────────────────────────────
#>        AIC       BIC  R²_conditional  R²_marginal    ICC   RMSE      σ
#> ──────────────────────────────────────────────────────────────────────
#>   6321.320  6343.724           0.366        0.085  0.308  1.080  1.105
#> ──────────────────────────────────────────────────────────────────────
#> 
#> Model Assumption Check
#> OK: Model is converged
#> OK: No singularity is detected
#> Warning: Autocorrelated residuals detected (p < .001).
#> OK: residuals appear as normally distributed (p = 0.236).
#> Unable to check autocorrelation. Try changing na.action to na.omit.
#> OK: Error variance appears to be homoscedastic (p = 0.198).
#> 
#> Warning: Not enough model terms in the conditional part of the model to check for
#>   multicollinearity.
#> OK: No multicolinearity detected (VIF < 5)
#> 

# lm example

lm_fit <- lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width,
  data = iris
)

model_summary(lm_fit, assumption_plot = TRUE)
#> 
#>  
#> Model Summary
#> Model Type = Linear regression
#> Outcome = Sepal.Length
#> Predictors = Sepal.Width, Petal.Length, Petal.Width
#> 
#> Model Estimates
#> ────────────────────────────────────────────────────────────────────────────
#>      Parameter  Coefficient       t   df     SE          p            95% CI
#> ────────────────────────────────────────────────────────────────────────────
#>    (Intercept)        1.856   7.401  146  0.251  0.000 ***  [ 1.360,  2.352]
#>    Sepal.Width        0.651   9.765  146  0.067  0.000 ***  [ 0.519,  0.783]
#>   Petal.Length        0.709  12.502  146  0.057  0.000 ***  [ 0.597,  0.821]
#>    Petal.Width       -0.556  -4.363  146  0.128  0.000 ***  [-0.809, -0.304]
#> ────────────────────────────────────────────────────────────────────────────
#> 
#> Goodness of Fit
#> ──────────────────────────────────────────────────
#>      AIC     BIC     R²  R²_adjusted   RMSE      σ
#> ──────────────────────────────────────────────────
#>   84.643  99.696  0.859        0.856  0.310  0.315
#> ──────────────────────────────────────────────────
#> 
#> Model Assumption Check
#> OK: Residuals appear to be independent and not autocorrelated (p = 0.808).
#> OK: residuals appear as normally distributed (p = 0.943).
#> Unable to check autocorrelation. Try changing na.action to na.omit.
#> Warning: Heteroscedasticity (non-constant error variance) detected (p = 0.035).
#> Warning: Severe multicolinearity detected (VIF > 10). Please inspect the following table to identify high correlation factors.
#> Multicollinearity Table 
#> ─────────────────────────────────
#>           Term     VIF  SE_factor
#> ─────────────────────────────────
#>    Sepal.Width   1.271      1.127
#>   Petal.Length  15.098      3.886
#>    Petal.Width  14.234      3.773
#> ─────────────────────────────────

#>