| validate_recovery | R Documentation |
Compare recovered estimates with known simulation truth
validate_recovery(
estimates,
truth,
term = "term",
estimate = "estimate",
true_value = NULL,
tolerance = 0.1
)
estimates |
Tidy base |
truth |
The generating values. A tidy base |
term |
Name of the term column in both frames, default |
estimate |
Name of the estimate column in |
true_value |
Name of the true-value column in |
tolerance |
Single non-negative absolute-error tolerance for successful
recovery, default |
A base data.frame with one row per row of estimates, in the same
order, plus one row for each term found only in truth. Every column of
estimates other than term and estimate (for example the batch_id
of apply_batch()) comes first, then the columns term, estimate,
truth, bias (estimate minus truth), absolute_error,
relative_error (NA where truth is zero) and recovered, a logical
that is TRUE when absolute_error is at most tolerance.
estimates <- data.frame(term = c("x1", "x2"), estimate = c(0.52, -0.28))
truth <- data.frame(term = c("x1", "x2"), truth = c(0.5, -0.3))
validate_recovery(estimates, truth, tolerance = 0.1)
# One data set: the fitted model against the result's own truth.
data_set <- simulate_regression(seed = 1)
validate_recovery(lm(outcome ~ x1 + x2, data = data_set), data_set)
# A batch with drawn coefficients: each data set is compared with its own.
datasets <- simulate_regression(seed = 1, batch = 20)
fit_coefficients <- function(data) {
fit <- lm(outcome ~ x1 + x2, data = data)
data.frame(term = names(coef(fit)), estimate = unname(coef(fit)))
}
estimates <- apply_batch(datasets, fit_coefficients)
head(validate_recovery(estimates, datasets))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.