Get estimates, inquiries, assignment vectors, or samples from a design given data
Source:R/get_functions.R
get_functions.Rd
Get estimates, inquiries, assignment vectors, or samples from a design given data
Usage
get_estimates(design, data = NULL, start = 1, end = length(design))
Arguments
- design
A design object, typically created using the + operator
- data
A data.frame object with sufficient information to get the data, estimates, inquiries, an assignment vector, or a sample.
- start
(Defaults to 1) a scalar indicating which step in the design to begin with. By default all data steps are drawn, from step 1 to the last step of the design.
- end
(Defaults to
length(design)
) a scalar indicating which step in the design to finish with.
Examples
design <-
declare_model(
N = 100,
U = rnorm(N),
potential_outcomes(Y ~ Z + U)
) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_sampling(S = complete_rs(N, n = 75)) +
declare_assignment(Z = complete_ra(N, m = 50)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
dat <- draw_data(design)
draw_data(design, data = dat, start = 2)
#> ID U Y_Z_0 Y_Z_1 S Z Y
#> 1 001 0.67033735 0.67033735 1.67033735 1 1 1.67033735
#> 2 002 1.01731683 1.01731683 2.01731683 1 0 1.01731683
#> 3 003 0.08793546 0.08793546 1.08793546 1 0 0.08793546
#> 4 004 -0.27601149 -0.27601149 0.72398851 1 0 -0.27601149
#> 5 005 -0.83322655 -0.83322655 0.16677345 1 1 0.16677345
#> 6 006 -0.50491973 -0.50491973 0.49508027 1 1 0.49508027
#> 7 007 -1.79710805 -1.79710805 -0.79710805 1 1 -0.79710805
#> 8 008 -0.82787857 -0.82787857 0.17212143 1 1 0.17212143
#> 9 009 0.74771881 0.74771881 1.74771881 1 0 0.74771881
#> 10 012 0.60094252 0.60094252 1.60094252 1 1 1.60094252
#> 11 013 2.46234388 2.46234388 3.46234388 1 1 3.46234388
#> 12 014 -0.13645424 -0.13645424 0.86354576 1 1 0.86354576
#> 13 015 -0.81537736 -0.81537736 0.18462264 1 1 0.18462264
#> 14 016 0.64036276 0.64036276 1.64036276 1 0 0.64036276
#> 15 018 0.51070713 0.51070713 1.51070713 1 1 1.51070713
#> 16 021 -1.17875822 -1.17875822 -0.17875822 1 0 -1.17875822
#> 17 023 0.32653886 0.32653886 1.32653886 1 0 0.32653886
#> 18 024 -1.06011600 -1.06011600 -0.06011600 1 1 -0.06011600
#> 19 025 0.88580210 0.88580210 1.88580210 1 1 1.88580210
#> 20 026 -1.10715956 -1.10715956 -0.10715956 1 0 -1.10715956
#> 21 029 -2.37315928 -2.37315928 -1.37315928 1 1 -1.37315928
#> 22 030 0.15957162 0.15957162 1.15957162 1 0 0.15957162
#> 23 032 -1.04832492 -1.04832492 -0.04832492 1 1 -0.04832492
#> 24 033 -1.07909560 -1.07909560 -0.07909560 1 0 -1.07909560
#> 25 035 -0.79381971 -0.79381971 0.20618029 1 1 0.20618029
#> 26 037 -0.03271025 -0.03271025 0.96728975 1 1 0.96728975
#> 27 038 0.09970543 0.09970543 1.09970543 1 1 1.09970543
#> 28 039 0.70075440 0.70075440 1.70075440 1 0 0.70075440
#> 29 040 -0.96503062 -0.96503062 0.03496938 1 0 -0.96503062
#> 30 041 -1.17862736 -1.17862736 -0.17862736 1 0 -1.17862736
#> 31 043 1.69189785 1.69189785 2.69189785 1 1 2.69189785
#> 32 044 -0.53331351 -0.53331351 0.46668649 1 1 0.46668649
#> 33 045 0.47301486 0.47301486 1.47301486 1 1 1.47301486
#> 34 046 0.58247997 0.58247997 1.58247997 1 0 0.58247997
#> 35 047 1.33049012 1.33049012 2.33049012 1 1 2.33049012
#> 36 048 0.31226340 0.31226340 1.31226340 1 1 1.31226340
#> 37 049 0.92385184 0.92385184 1.92385184 1 1 1.92385184
#> 38 052 0.85737818 0.85737818 1.85737818 1 0 0.85737818
#> 39 053 0.61031138 0.61031138 1.61031138 1 0 0.61031138
#> 40 054 -1.88221603 -1.88221603 -0.88221603 1 1 -0.88221603
#> 41 055 0.26341142 0.26341142 1.26341142 1 1 1.26341142
#> 42 056 0.46509957 0.46509957 1.46509957 1 1 1.46509957
#> 43 057 -0.63323200 -0.63323200 0.36676800 1 1 0.36676800
#> 44 058 0.08867908 0.08867908 1.08867908 1 0 0.08867908
#> 45 060 0.58619256 0.58619256 1.58619256 1 1 1.58619256
#> 46 061 -0.71312727 -0.71312727 0.28687273 1 1 0.28687273
#> 47 063 1.61571678 1.61571678 2.61571678 1 1 2.61571678
#> 48 064 -1.99193744 -1.99193744 -0.99193744 1 1 -0.99193744
#> 49 066 0.06486975 0.06486975 1.06486975 1 0 0.06486975
#> 50 067 -0.62197749 -0.62197749 0.37802251 1 0 -0.62197749
#> 51 068 0.46169039 0.46169039 1.46169039 1 1 1.46169039
#> 52 070 0.03062108 0.03062108 1.03062108 1 0 0.03062108
#> 53 073 -0.69586801 -0.69586801 0.30413199 1 0 -0.69586801
#> 54 074 -0.81781782 -0.81781782 0.18218218 1 1 0.18218218
#> 55 077 0.60848328 0.60848328 1.60848328 1 0 0.60848328
#> 56 078 -0.80747180 -0.80747180 0.19252820 1 1 0.19252820
#> 57 079 0.50982608 0.50982608 1.50982608 1 1 1.50982608
#> 58 080 0.78167699 0.78167699 1.78167699 1 1 1.78167699
#> 59 081 1.45460854 1.45460854 2.45460854 1 1 2.45460854
#> 60 082 -0.51655873 -0.51655873 0.48344127 1 1 0.48344127
#> 61 083 0.21142519 0.21142519 1.21142519 1 1 1.21142519
#> 62 084 1.24699610 1.24699610 2.24699610 1 1 2.24699610
#> 63 085 -0.72571466 -0.72571466 0.27428534 1 1 0.27428534
#> 64 086 -0.95462530 -0.95462530 0.04537470 1 1 0.04537470
#> 65 087 -0.69128681 -0.69128681 0.30871319 1 1 0.30871319
#> 66 089 -0.60342589 -0.60342589 0.39657411 1 1 0.39657411
#> 67 091 -3.15729308 -3.15729308 -2.15729308 1 1 -2.15729308
#> 68 092 1.82644050 1.82644050 2.82644050 1 1 2.82644050
#> 69 093 -2.16882046 -2.16882046 -1.16882046 1 0 -2.16882046
#> 70 094 -1.00999874 -1.00999874 -0.00999874 1 1 -0.00999874
#> 71 095 -0.26104840 -0.26104840 0.73895160 1 1 0.73895160
#> 72 096 0.79876922 0.79876922 1.79876922 1 0 0.79876922
#> 73 097 1.32881677 1.32881677 2.32881677 1 1 2.32881677
#> 74 099 0.82571476 0.82571476 1.82571476 1 1 1.82571476
#> 75 100 -0.61598390 -0.61598390 0.38401610 1 0 -0.61598390
get_estimates(design, data = dat)
#> estimator term estimate std.error statistic p.value conf.low conf.high
#> 1 estimator Z 1.124539 0.2730184 4.118913 9.918114e-05 0.5804143 1.668664
#> df outcome inquiry
#> 1 73 Y ATE