declare_diagnosands: Declare diagnosands

Description Usage Arguments Details Value Examples

Description

Declare diagnosands

Usage

1
2
3
diagnosand_handler(data, ..., subset = NULL, alpha = 0.05, label)

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

Arguments

data

A data.frame.

...

A set of new diagnosands.

subset

A subset of the simulations data frame within which to calculate diagnosands e.g. subset = p.value < .05.

alpha

Alpha significance level. Defaults to .05.

label

Label for the set of diagnosands.

handler

a tidy-in, tidy-out function

Details

If term is TRUE, the names of ... will be returned in a term column, and inquiry_label will contain the step label. This can be used as an additional dimension for use in diagnosis.

Diagnosands summarize the simulations generated by diagnose_design or simulate_design. Typically, the columns of the resulting simulations data.frame include the following variables: estimate, std.error, p.value, conf.low, conf.high, and inquiry. Many diagnosands will be a function of these variables.

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
design <- 
  declare_model(
    N = 500, 
    U = rnorm(N),
    Y_Z_0 = U, 
    Y_Z_1 = U + rnorm(N, mean = 2, sd = 2)
  ) + 
  declare_assignment(Z = complete_ra(N), legacy = FALSE) + 
  declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) + 
  declare_estimator(Y ~ Z, inquiry = my_inquiry) + 
  declare_measurement(Y = reveal_outcomes(Y ~ Z))

## Not run: 
# using built-in defaults:
diagnosis <- diagnose_design(design)
diagnosis

## End(Not run)

# You can choose your own diagnosands instead of the defaults e.g.,

my_diagnosands <-
  declare_diagnosands(median_bias = median(estimate - inquiry))
## Not run: 
diagnosis <- diagnose_design(design, diagnosands = my_diagnosands)
diagnosis

## End(Not run)
## Not run: 
design <- set_diagnosands(design, diagnosands = my_diagnosands)
diagnosis <- diagnose_design(design)
diagnosis

## End(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_inquiry = mean(estimand)
)

DeclareDesign documentation built on Feb. 15, 2021, 1:07 a.m.