Skip to contents

format model performance metrics in APA style

Usage

apa_performance(fit, metrics = c("R2", "Sigma"), column_formats = NULL)

# S3 method for class 'lm'
apa_performance(fit, metrics = c("R2", "Sigma"), column_formats = NULL)

# S3 method for class 'glm'
apa_performance(fit, metrics = c("R2", "AIC"), column_formats = NULL)

# S3 method for class 'polr'
apa_performance(fit, metrics = c("R2", "AIC"), column_formats = NULL)

# S3 method for class 'clm'
apa_performance(fit, metrics = c("R2", "AIC"), column_formats = NULL)

# S3 method for class 'merMod'
apa_performance(
  fit,
  metrics = c("R2_marginal", "R2_conditional", "ICC"),
  column_formats = NULL
)

# S3 method for class 'list'
apa_performance(fit, metrics = NULL, column_formats = NULL)

Arguments

fit

model fit object

metrics

performance metrics. Default is R2 and Sigma

column_formats

column_formats object to format columns. If NULL, the default column_formats is used.

Value

tibble

Details

For glm objects, R2 is the pseudo-R^2^ that performance::r2() selects for the model family (e.g., Tjur's R^2^ for logistic regression and Nagelkerke's R^2^ for count models). The header names the pseudo-R^2^ that was used. Because the residual standard deviation is not meaningful for most GLMs, the default metrics are R2 and AIC.

For mixed models (lme4::lmer and lme4::glmer), the default metrics are the marginal R^2^ (variance explained by the fixed effects), the conditional R^2^ (fixed and random effects), and the intraclass correlation (ICC), as computed by performance::model_performance().

For a list of models, each model's metrics are displayed in a row, labeled in a Model column by the list's names (or "Model 1", "Model 2", ... for unnamed elements). If metrics is NULL (default), each model's default metrics are used.

Examples

lm(mpg ~ cyl + wt, data = mtcars) |>
   apa_performance() |>
   apa_flextable()

R2

σe

.83

2.57

list( `Cylinders` = lm(mpg ~ cyl, data = mtcars), `Cylinders and weight` = lm(mpg ~ cyl + wt, data = mtcars) ) |> apa_performance() #> # A tibble: 2 × 3 #> Model `*R*^2^` `&sigma;~*e*~` #> <chr> <chr> <chr> #> 1 Cylinders .73 3.21 #> 2 Cylinders and weight .83 2.57