declare_inquiry: Declare inquiry

Description Usage Arguments Details Value Examples

Description

Declares inquiries, or the inferential target of interest. Conceptually very close to "estimand" or "quantity of interest".

Usage

1
2
3
4
5
6
7
8
9
declare_inquiry(..., handler = inquiry_handler, label = "inquiry")

declare_inquiries(..., handler = inquiry_handler, label = "inquiry")

declare_estimand(...)

declare_estimands(...)

inquiry_handler(data, ..., subset = NULL, term = FALSE, label)

Arguments

...

arguments to be captured, and later passed to the handler

handler

a tidy-in, tidy-out function

label

a string describing the step

data

a data.frame

subset

a subset expression

term

TRUE/FALSE

Details

For the default diagnosands, the return value of the handler should have inquiry_label and estimand columns.

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.

Value

a function, I(), that accepts a data.frame as an argument and returns a data.frame containing the value of the inquiry, a^m.

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
# Set up a design for use in examples:

design <-
  declare_model(N = 100,
                X = rnorm(N),
                potential_outcomes(Y ~ (.25 + X) * Z + rnorm(N))) +
  declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) +
  declare_measurement(Y = reveal_outcomes(Y ~ Z))

design + declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0))


design + declare_inquiry(ATT = mean(Y_Z_1 - Y_Z_0),
                         subset = (Z == 1))

# Add inquirys to a design along with estimators that reference them

design_1 <-
  design +
  declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
  declare_estimator(Y ~ Z, inquiry = "ATE")

run_design(design_1)

# Two inquirys, one estimator

design_2 <-
  design +
  declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
  declare_inquiry(ATT = mean(Y_Z_1 - Y_Z_0), subset = (Z == 1)) +
  declare_estimator(Y ~ Z, inquiry = c("ATE", "ATT"))

run_design(design_2)

# Two inquirys, two coefficients from one estimator

design_3 <-
  design +
  declare_inquiry(intercept = mean(Y_Z_0),
                  slope = mean(Y_Z_1 - Y_Z_0)) +
  declare_estimator(
    Y ~ Z,
    model = lm_robust,
    term = TRUE,
    inquiry = c("intercept", "slope")
  )

run_design(design_3)

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