check_augment_function: Check an augment method

View source: R/check_augment_function.R

check_augment_functionR Documentation

Check an augment method

Description

Call this function to perform tests. If a tests fails, an informative error will be thrown. Otherwise silent.

Test when strict = FALSE:

  • aug(model, data = data) passes check_tibble()

  • aug(model, newdata = newdata) passes check_tibble()

Additional tests when strict = TRUE:

  • aug(model, data = data) passes check_augment_data_specification().

  • aug(model, newdata = newdata) passes check_augment_data_specification().

  • aug(model, newdata = newdata) passes check_augment_data_specification() with add_missing = TRUE.

  • If aug has a newdata argument, the newdata argument takes precedence over a data argument, i.e. calls check_augment_newdata_precedence().

  • aug either gives an informative error or produces a reasonable tibble, i.e. calls check_augment_no_data().

Note that it doesn't make sense to test that aug(model, data = data) passes check_augment_data_specification() with add_missing = TRUE. This is because the user is already guaranteeing that data is the original dataset used to create model.

Usage

check_augment_function(aug, model, data = NULL, newdata = NULL, strict = TRUE)

Arguments

aug

An augment method. For example, augment.betareg.

model

A fit model object to call the augment method on.

data

A data frame or tibble to use when testing aug.

newdata

A dataset to use to check the newdata behavior, ideally distinct for the dataset used to check the data behavior.

strict

Logical indicating whether the strict version of tests should be used. Defaults to TRUE.

Value

An invisible NULL. This function should be called for side effects, not return values.


alexpghayes/modeltests documentation built on March 7, 2024, 11 p.m.