View source: R/e_lm_model_criteria.R
e_lm_model_criteria | R Documentation |
Calculates a large set of model selection criteria and returns them in a one-row tibble.
AIC and BIC criteria from the stats package:
aic
Akaike's An Information Criterion
bic
Bayesian Information Criterion (AIC with k = log(nobs(object)))
caic
Conditional Akaike Information for 'lme4' and 'lme'
nobs
number of observations used to fit lm_fit
Several criteria from the lm summary:
r2
R-squared statistic
r2adj
Adjusted R-squared statistic
f_stat
F-statistic compared to grand mean model (NA if y ~ 1 intercept-only model)
p
F-statistic numerator degrees-of-freedom (number of parameters in the model)
df
F-statistic denominator degrees-of-freedom (number of df estimating the variance)
f_stat_pval
F-statistic p-value
rse
Residual standard error.
Several criteria are defined in ?modelr::`model-quality`
:
Three summaries are immediately interpretible on the scale of the response variable:
rmse
is the root-mean-squared-error
mae
is the mean absolute error
qae
is quantiles of absolute error.
Other summaries have varying scales and interpretations:
mape
mean absolute percentage error.
rsae
is the relative sum of absolute errors.
mse
is the mean-squared-error.
rsquare
is the variance of the predictions divided by the
variance of the response.
e_lm_model_criteria(lm_fit = NULL, dat_fit = NULL, model_id = NULL)
lm_fit |
fitted model object |
dat_fit |
data used for model fit |
model_id |
label for each model that is fit, helps to match up with original model |
a tibble of model selection criteria
lm_form <- formula(mpg ~ cyl + carb + disp + hp + disp:hp + wt + vs + am + gear)
lm_fit <-
stats::lm(
formula = lm_form
, data = dat_mtcars_e
)
lm_crit <-
e_lm_model_criteria(
lm_fit = lm_fit
, dat_fit = dat_mtcars_e
, model_id = 1
)
lm_crit |> print(width = Inf)
# intercept-only model
lm_form <- formula(mpg ~ 1)
lm_fit <-
stats::lm(
formula = lm_form
, data = dat_mtcars_e
)
lm_crit <-
e_lm_model_criteria(
lm_fit = lm_fit
, dat_fit = dat_mtcars_e
, model_id = 1
)
lm_crit |> print(width = Inf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.