diagnose_design

0th

Percentile

Diagnose the design

Generates diagnosands from a design or simulations of a design.

Usage
diagnose_design(..., diagnosands = NULL, sims = 500,
  bootstrap_sims = 100, add_grouping_variables = NULL)

diagnose_designs(..., diagnosands = NULL, sims = 500, bootstrap_sims = 100, add_grouping_variables = NULL)

Arguments
...

A design or set of designs typically created using the + operator, or a data.frame of simulations, typically created by simulate_design.

diagnosands

A set of diagnosands created by declare_diagnosands. By default, these include bias, root mean-squared error, power, frequentist coverage, the mean and standard deviation of the estimate(s), the "type S" error rate (Gelman and Carlin 2014), and the mean of the estimand(s).

sims

The number of simulations, defaulting to 500. sims may also be a vector indicating the number of simulations for each step in a design, as described for simulate_design

bootstrap_sims

Number of bootstrap replicates for the diagnosands to obtain the standard errors of the diagnosands, defaulting to 100. Set to FALSE to turn off bootstrapping.

add_grouping_variables

Variables used to generate groups of simulations for diagnosis. Added to list default list: c("design_label", "estimand_label", "estimator_label", "term")

Details

If the diagnosand function contains a group_by attribute, it will be used to split-apply-combine diagnosands rather than the intersecting column names.

If sims is named, or longer than one element, a fan-out strategy is created and used instead.

If the packages future and future.apply are installed, you can set plan to run multiple simulations in parallel.

Value

a list with a data frame of simulations, a data frame of diagnosands, a vector of diagnosand names, and if calculated, a data frame of bootstrap replicates.

Aliases
  • diagnose_design
  • diagnose_designs
Examples
# 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_reveal <- declare_reveal()

my_estimator <- declare_estimator(Y ~ Z, estimand = my_estimand)

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 {
# using a user-defined diagnosand
my_diagnosand <- declare_diagnosands(absolute_error = mean(abs(estimate - estimand)))

# }
# NOT RUN {
diagnosis <- diagnose_design(design, diagnosands = my_diagnosand)
diagnosis

get_diagnosands(diagnosis)

get_simulations(diagnosis)

# }
# NOT RUN {
# Using an existing data frame of simulations
# }
# NOT RUN {
simulations <- simulate_design(designs, sims = 2)
diagnosis   <- diagnose_design(simulations_df = simulations_df)

# }
Documentation reproduced from package DeclareDesign, version 0.18.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.