# NOT RUN {
my_population <- declare_population(N = 500, noise = rnorm(N))
my_potential_outcomes <- declare_potential_outcomes(
Y_Z_0 = noise, Y_Z_1 = noise +
rnorm(N, mean = 2, sd = 2))
my_assignment <- declare_assignment()
my_estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
my_estimator <- declare_estimator(Y ~ Z, estimand = my_estimand)
my_reveal <- declare_reveal()
design <- my_population + my_potential_outcomes + my_estimand +
my_assignment + my_reveal + my_estimator
# }
# NOT RUN {
# using built-in defaults:
diagnosis <- diagnose_design(design)
diagnosis
# }
# NOT RUN {
# You can select a set of those diagnosands via the \code{select} argument e.g.,
my_diagnosands <- declare_diagnosands(select = c(bias, rmse))
# }
# NOT RUN {
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis
# }
# NOT RUN {
design <- set_diagnosands(design, diagnosands = my_diagnosands)
diagnosis <- diagnose_design(design)
diagnosis
# }
# NOT RUN {
# Alternatively, you can report all of the default diagnosands and subtract a subset of them e.g.,
my_diagnosands <- declare_diagnosands(subtract = type_s_rate)
# }
# NOT RUN {
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis
# }
# NOT RUN {
design <- set_diagnosands(design, diagnosands = my_diagnosands)
diagnosis <- diagnose_design(design)
diagnosis
# }
# NOT RUN {
# You can add your own diagnosands in addition to or instead of the defaults e.g.,
my_diagnosands <-
declare_diagnosands(median_bias = median(estimate - estimand))
# }
# NOT RUN {
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis
# }
# NOT RUN {
design <- set_diagnosands(design, diagnosands = my_diagnosands)
diagnosis <- diagnose_design(design)
diagnosis
# }
# NOT RUN {
# or to report only \code{median_bias}
my_diagnosands <-
declare_diagnosands(median_bias = median(estimate - estimand),
keep_defaults = FALSE)
# }
# NOT RUN {
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis
# }
# NOT RUN {
design <- set_diagnosands(design, diagnosands = my_diagnosands)
diagnosis <- diagnose_design(design)
diagnosis
# }
# NOT RUN {
# Below is the code that makes the default diagnosands.
# You can use these as a model when writing your own diagnosands.
default_diagnosands <- declare_diagnosands(
bias = mean(estimate - estimand),
rmse = sqrt(mean((estimate - estimand) ^ 2)),
power = mean(p.value < alpha),
coverage = mean(estimand <= conf.high & estimand >= conf.low),
mean_estimate = mean(estimate),
sd_estimate = sd(estimate),
mean_se = mean(std.error),
type_s_rate = mean((sign(estimate) != sign(estimand))[p.value < alpha]),
mean_estimand = mean(estimand)
)
# }
Run the code above in your browser using DataLab