Skip to content

Instantly share code, notes, and snippets.

@jwbowers
Created April 14, 2020 21:13
Show Gist options
  • Save jwbowers/2d91fd40faa13520b29ebaa187c58e17 to your computer and use it in GitHub Desktop.
Save jwbowers/2d91fd40faa13520b29ebaa187c58e17 to your computer and use it in GitHub Desktop.
SimpleTestDeclareation.R
#' Wrap a basic one-way t-test so that it's usable by the tidy functions
#' @param data The data that we pass in. See discussion of tidy_estimator and handlers in declare_estimator
#' @returns A data frame that contains quantities useful for assessing the design and estimator
our_ttest <- function(data) {
require(coin)
res <- coin::oneway_test(
outcome ~ factor(Xclus),
data = data,
distribution = "asymptotic"
)
data.frame(p.value = pvalue(res)[[1]])
}
## This estimator wraps our_ttest so that is can be used by DeclareDesign
ttest_estimator <- declare_estimator(
handler = tidy_estimator(our_ttest),
label = "t test"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment