Description Usage Arguments Details Value Examples
Declare a design
1 2 3 4 5 6 7 8 |
lhs |
A step in a research design, beginning with a function that draws the population. Steps are evaluated sequentially. With the exception of the first step, all steps must be functions that take a |
rhs |
A second step in a research design |
x |
a design object, typically created using the + operator |
verbose |
an indicator for printing a long summary of the design, defaults to |
... |
optional arguments to be sent to summary function |
object |
a design object created using the + operator |
Users can supply three kinds of functions to create a design:
1. Data generating functions. These include population, assignment, and sampling functions.
2. Estimand functions.
3. Estimator functions.
The location of the estimand and estimator functions in the pipeline of functions determine *when* the values of the estimand and estimator are calculated. This allows users to, for example, differentiate between a population average treatment effect and a sample average treatment effect by placing the estimand function before or after sampling.
Design objects declared with the + operator can be investigated with a series of post-declaration commands, such as draw_data
, draw_estimands
, draw_estimates
, and diagnose_design
.
The print and summary methods for a design object return some helpful descriptions of the steps in your research design. If randomizr functions are used for any assignment or sampling steps, additional details about those steps are provided.
a list of two functions, the design_function
and the data_function
. The design_function
runs the design once, i.e. draws the data and calculates any estimates and estimands defined in ...
, returned separately as two data.frame
's. The data_function
runs the design once also, but only returns the final data.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | my_population <- declare_population(N = 500, noise = rnorm(N))
my_potential_outcomes <- declare_potential_outcomes(Y ~ Z + noise)
my_sampling <- declare_sampling(n = 250)
my_assignment <- declare_assignment(m = 25)
my_estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
my_estimator <- declare_estimator(Y ~ Z, estimand = my_estimand)
my_mutate <- declare_step(dplyr::mutate, noise_sq = noise^2)
my_reveal <- declare_reveal()
design <- my_population + my_potential_outcomes + my_sampling +
my_estimand + my_mutate +
my_assignment + my_reveal + my_estimator
design
df <- draw_data(design)
estimates <- draw_estimates(design)
estimands <- draw_estimands(design)
# You can add steps to a design
design <- my_population + my_potential_outcomes
design + my_sampling
# Special Cases
# You may wish to have a design with only one step:
design <- my_population + NULL
design
## Not run:
diagnosis <- diagnose_design(design)
summary(diagnosis)
## End(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_sampling <- declare_sampling(n = 250)
my_assignment <- declare_assignment(m = 25)
my_estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
my_estimator <- declare_estimator(Y ~ Z, estimand = my_estimand)
my_mutate <- declare_step(dplyr::mutate, noise_sq = noise ^ 2)
my_reveal <- declare_reveal()
design <- my_population +
my_potential_outcomes +
my_sampling +
my_estimand +
my_mutate +
my_assignment +
my_reveal +
my_estimator
summary(design)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.