Skip to content

Commit

Permalink
Merge 5d811b6 into a37a5b8
Browse files Browse the repository at this point in the history
  • Loading branch information
nfultz committed Jan 31, 2018
2 parents a37a5b8 + 5d811b6 commit 06f3282
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
25 changes: 25 additions & 0 deletions R/declare_diagnosands.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,28 @@
#' mean_estimand = mean(estimand))
#'
declare_diagnosands <- make_declarations(estimand_function_default, "diagnosand", "diagnosands")


default_diagnosands <- function(data, alpha=.05){

est <- data$est
estimand <- data$estimand
p <- data$p
ci_lower <- data$ci_lower
ci_upper <- data$ci_upper

bias = mean(est - estimand)
rmse = sqrt(mean((est - estimand) ^ 2))
power = mean(p < alpha)
coverage = mean(estimand <= ci_upper &
estimand >= ci_lower)
mean_estimate = mean(est)
sd_estimate = sd(est)
type_s_rate = mean((sign(est) != sign(estimand)) & p < alpha)
mean_estimand = mean(estimand)


data.frame(estimand_label = c("bias", "rmse", "power", "coverage", "mean_estimate", "sd_estimate", "type_s_rate", "mean_estimand"),
estimand = c( bias , rmse , power , coverage , mean_estimate , sd_estimate , type_s_rate , mean_estimand ))
}

16 changes: 1 addition & 15 deletions R/diagnose_design.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,13 @@
#' @export
diagnose_design <-
function(...,
diagnosands = NULL,
diagnosands = default_diagnosands,
sims = 500,
bootstrap = TRUE,
bootstrap_sims = 100,
parallel = TRUE,
parallel_cores = detectCores(logical = TRUE)) {

if (is.null(diagnosands)) {
diagnosands <- declare_diagnosands(
bias = mean(est - estimand),
rmse = sqrt(mean((est - estimand) ^ 2)),
power = mean(p < .05),
coverage = mean(estimand <= ci_upper &
estimand >= ci_lower),
mean_estimate = mean(est),
sd_estimate = sd(est),
type_s_rate = mean((sign(est) != sign(estimand)) & p < .05),
mean_estimand = mean(estimand)
)
}

designs <- list(...)

inferred_names <- paste(substitute(list(...)))[-1]
Expand Down

0 comments on commit 06f3282

Please sign in to comment.