Declares an test which generates a test statistic and associated inferential statistics.

Use of declare_test is identical to use of declare_estimator. Use declare_test for hypothesis testing with no specific inquiry in mind; use declare_estimator for hypothesis testing when you can link each estimate to an inquiry. For example, declare_test could be used for a K-S test of distributional equality and declare_estimator for a difference-in-means estimate of an average treatment effect.

See declare_estimator help for an explanation of how to use model_handler, which is used identically in both declare_estimator and declare_test. The main difference between declare_estimator and declare_test is that declare_test does not link with an explicit inquiry.

declare_test(..., handler = label_test(model_handler), label = "test")

label_test(fn)

## Arguments

... arguments to be captured, and later passed to the handler a tidy-in, tidy-out function a string describing the step A function that takes a data.frame as an argument and returns a data.frame with test statistics as columns.

## Value

A function that accepts a data.frame as an argument and returns a data.frame containing the value of the test statistic and other inferential statistics.

## Details

label_test takes a data-in-data out function to fn, and returns a data-in-data-out function that first runs the provided test function fn and then appends a label for the test.

# Balance test F test balance_test_design <- declare_model( N = 100, cov1 = rnorm(N), cov2 = rnorm(N), cov3 = rnorm(N) ) + declare_assignment(Z = complete_ra(N, prob = 0.2)) + declare_test(Z ~ cov1 + cov2 + cov3, model = lm_robust, model_summary = glance) if (FALSE) { diagnosis <- diagnose_design( design = balance_test_design, diagnosands = declare_diagnosands( false_positive_rate = mean(p.value <= 0.05)) ) } # K-S test of distributional equality ks_test <- function(data) { test <- with(data, ks.test(x = Y[Z == 1], y = Y[Z == 0])) data.frame(statistic = test$statistic, p.value = test$p.value) } distributional_equality_design <- declare_model( N = 100, Y_Z_1 = rnorm(N), Y_Z_0 = rnorm(N, sd = 1.5) ) + declare_assignment(Z = complete_ra(N, prob = 0.5)) + declare_measurement(Y = reveal_outcomes(Y ~ Z)) + declare_test(handler = label_test(ks_test), label = "ks-test") if (FALSE) { diagnosis <- diagnose_design( design = distributional_equality_design, diagnosands = declare_diagnosands(power = mean(p.value <= 0.05)) ) } # Thanks to Jake Bowers for this example library(coin)