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

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

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.

Details

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

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

Examples

# 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)) + declare_measurement(Y = reveal_outcomes(Y ~ Z)) design + declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0))
#> #> Design Summary #> #> Step 1 (model): declare_model(N = 100, X = rnorm(N), potential_outcomes(Y ~ (0.25 + X) * Z + rnorm(N))) #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique class #> 0 100 character #> #> Added variable: X #> min median mean max sd N_missing N_unique #> -2.54 0.08 0.06 2.92 0.96 0 100 #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.71 -0.24 -0.14 2.22 1.03 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.92 0.41 0.33 3.73 1.31 0 100 #> #> Step 2 (assignment): declare_assignment(Z = complete_ra(N, m = 50)) ------------ #> #> Added variable: Z #> 0 1 #> 50 50 #> 0.50 0.50 #> #> Step 3 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ---------- #> #> Added variable: Y #> min median mean max sd N_missing N_unique #> -2.61 0.13 0.07 3.73 1.13 0 100 #> #> Step 4 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) ------------------- #> #> A single draw of the inquiry: #> inquiry estimand #> ATE 0.4637067 #>
design + declare_inquiry(ATT = mean(Y_Z_1 - Y_Z_0), subset = (Z == 1))
#> #> Design Summary #> #> Step 1 (model): declare_model(N = 100, X = rnorm(N), potential_outcomes(Y ~ (0.25 + X) * Z + rnorm(N))) #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique class #> 0 100 character #> #> Added variable: X #> min median mean max sd N_missing N_unique #> -2.34 0.1 0.14 2.53 0.97 0 100 #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.35 -0.1 -0.07 3.14 1.04 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -1.7 0.4 0.46 3.61 1.21 0 100 #> #> Step 2 (assignment): declare_assignment(Z = complete_ra(N, m = 50)) ------------ #> #> Added variable: Z #> 0 1 #> 50 50 #> 0.50 0.50 #> #> Step 3 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ---------- #> #> Added variable: Y #> min median mean max sd N_missing N_unique #> -2.35 0.25 0.26 3.61 1.09 0 100 #> #> Step 4 (inquiry): declare_inquiry(ATT = mean(Y_Z_1 - Y_Z_0), subset = (Z == 1)) #> #> A single draw of the inquiry: #> inquiry estimand #> ATT 0.6451069 #>
# 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)
#> inquiry estimand estimator term estimate std.error statistic p.value #> 1 ATE 0.392631 estimator Z 0.4922994 0.2550138 1.930481 0.05643784 #> conf.low conf.high df outcome #> 1 -0.01376723 0.998366 98 Y
# 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)
#> inquiry estimand estimator term estimate std.error statistic p.value #> 1 ATE 0.3955085 estimator Z 0.58013 0.2474194 2.344724 0.02105834 #> 2 ATT 0.2625157 estimator Z 0.58013 0.2474194 2.344724 0.02105834 #> conf.low conf.high df outcome #> 1 0.08913436 1.071126 98 Y #> 2 0.08913436 1.071126 98 Y
# 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)
#> inquiry estimand estimator term estimate std.error statistic #> 1 intercept -0.1088746 estimator (Intercept) -0.2518172 0.1430769 -1.760013 #> 2 slope 0.4003815 estimator Z 0.8353095 0.2514082 3.322523 #> p.value conf.low conf.high df outcome #> 1 0.081525808 -0.5357487 0.03211423 98 Y #> 2 0.001254895 0.3363981 1.33422093 98 Y