declare_diagnosands: Declare Diagnosands

Description Usage Arguments Details Value Examples

Description

Declare Diagnosands

Usage

1
declare_diagnosands(..., handler = diagnosand_handler, label = NULL)

Arguments

...

arguments to be captured, and later passed to the handler

handler

a tidy-in, tidy-out function

label

a string describing the step

Details

Diagnosands summarize the simulations generated by diagnose_design. Typically, the columns of the resulting simulations data.frame include the following variables: est, se, p, ci_lower, ci_upper, and estimand. Most diagnosands will be some function of these variables.

If you do not specify a particular set of diagnosands, the following diagnosands will be reported by default:

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 < alpha])
mean_estimand = mean(estimand)

Value

a function that returns a data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 <- declare_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

## End(Not run)

# using a user-defined diagnosand
my_diagnosand <- declare_diagnosands(absolute_error = mean(abs(est - estimand)))

## Not run: 
diagnosis <- diagnose_design(design, diagnosands = my_diagnosand)
diagnosis

## End(Not run)

# this is the code that makes the default diagnsoands.
# Use these as a model when writing your own diagnosands.

default_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))

graemeblair/DeclareDesign documentation built on May 8, 2018, 1:24 p.m.