Model Performance and Tests"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

To start, load the package.

library(JWileymisc)

Model Performance

modelPerformance() is a generic function that can be used to calculate performance metrics for a model. JWileymisc implements methods for lm class objects. The output is a named list, with a data table containing results. For linear models, current performance metrics include:

mtcars$cyl <- factor(mtcars$cyl)
m <- stats::lm(mpg ~ hp + cyl, data = mtcars)

mp <- modelPerformance(m)
print(mp)

If only certain metrics are desired, these can be found by extracting the "Performance" list element and then the correct column from the data table.

## Cohen's f^2 effect size
mp$Performance[, F2]

Another function, modelTest() is a generic providing a comprehensive series of tests for a model. Currently methods are implemented for both lm class models and vglm class models from the VGAM package with a multinomial family.

modelTest()

mt <- modelTest(m)
print(mt)
APAStyler(mt)

The model tests can also be used with interactions.

m2 <- stats::lm(mpg ~ hp * cyl, data = mtcars)

APAStyler(modelTest(m2))


Try the JWileymisc package in your browser

Any scripts or data that you put into this service are public.

JWileymisc documentation built on Oct. 5, 2023, 5:06 p.m.