View source: R/diagnosis_helper_functions.R
reshape_diagnosis | R Documentation |
Take a diagnosis object and returns a pretty output table. If diagnosands are bootstrapped, se's are put in parentheses on a second line and rounded to digits
.
reshape_diagnosis(diagnosis, digits = 2, select = NULL, exclude = NULL)
diagnosis |
A diagnosis object generated by |
digits |
Number of digits. |
select |
List of columns to include in output. Defaults to all. |
exclude |
Set of columns to exclude from output. Defaults to none. |
A formatted text table with bootstrapped standard errors in parentheses.
# Two-arm randomized experiment
design <-
declare_model(
N = 500,
gender = rbinom(N, 1, 0.5),
X = rep(c(0, 1), each = N / 2),
U = rnorm(N, sd = 0.25),
potential_outcomes(Y ~ 0.2 * Z + X + U)
) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_sampling(S = complete_rs(N = N, n = 200)) +
declare_assignment(Z = complete_ra(N = N, m = 100)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
## Not run:
# Diagnose design using default diagnosands
diagnosis <- diagnose_design(design)
diagnosis
# Return diagnosis output table
reshape_diagnosis(diagnosis)
# Return table with subset of diagnosands
reshape_diagnosis(diagnosis, select = c("Bias", "Power"))
# With user-defined diagnosands
my_diagnosands <-
declare_diagnosands(median_bias = median(estimate - estimand),
absolute_error = mean(abs(estimate - estimand)))
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis
reshape_diagnosis(diagnosis)
reshape_diagnosis(diagnosis, select = "Absolute Error")
# Alternative: Use tidy to produce data.frame with results of
# diagnosis including bootstrapped standard errors and
# confidence intervals for each diagnosand
diagnosis_df <- tidy(diagnosis)
diagnosis_df
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.