Learn R Programming

modeltests (version 0.1.6)

check_augment_data_specification: Check that augment behavior is consistent for dataframes and tibbles

Description

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

Uses augment_data_helper() to create copies of the same dataset as a tibble, data frame and dataframe with rownames. When add_missing = TRUE these datasets have missing values along the diagonal, and one row of entirely missing values. Once the datasets have been generated, tests that:

  • augment(fit, data = generated_dataset) passes check_tibble() for each generated dataset.

  • Output of augment(fit, data = generated_dataset) is the same for all three generated datasets, except the data frame with rownames should also generate a .rownames column that the tibble and nameless data frame do not.

Additional tests when test_newdata = TRUE:

  • head(aug(model, newdata = data)) equals aug(head(model, newdata = data)). This commutativity check catches issues where the output of predict changes for the same data point depending on the rest of the dataset.

Usage

check_augment_data_specification(aug, model, data, add_missing, test_newdata)

Value

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

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.

add_missing

Logical indicating whether or not missing data should be introduced into the datasets generated with augment_data_helper(). This missing data is only used to test the newdata argument, not the data argument.

test_newdata

Logical indicating whether the newdata argument behavior should be tested instead of the data argument behavior.