Get estimates, inquiries, assignment vectors, or samples from a design given data

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.94562943  0.94562943  1.94562943 1 0  0.94562943
#> 2  002 -0.56851580 -0.56851580  0.43148420 1 1  0.43148420
#> 3  003 -0.12330626 -0.12330626  0.87669374 1 1  0.87669374
#> 4  004 -0.12814218 -0.12814218  0.87185782 1 1  0.87185782
#> 5  005 -0.28093671 -0.28093671  0.71906329 1 1  0.71906329
#> 6  006  0.87587350  0.87587350  1.87587350 1 0  0.87587350
#> 7  007  0.12999647  0.12999647  1.12999647 1 1  1.12999647
#> 8  008  0.30948733  0.30948733  1.30948733 1 1  1.30948733
#> 9  010 -0.44583190 -0.44583190  0.55416810 1 1  0.55416810
#> 10 011 -0.14106492 -0.14106492  0.85893508 1 0 -0.14106492
#> 11 012 -2.28125698 -2.28125698 -1.28125698 1 1 -1.28125698
#> 12 013  0.38642423  0.38642423  1.38642423 1 1  1.38642423
#> 13 015 -1.93806411 -1.93806411 -0.93806411 1 1 -0.93806411
#> 14 016 -0.69870050 -0.69870050  0.30129950 1 1  0.30129950
#> 15 018 -0.04906215 -0.04906215  0.95093785 1 0 -0.04906215
#> 16 019  1.53137897  1.53137897  2.53137897 1 1  2.53137897
#> 17 021 -0.58363743 -0.58363743  0.41636257 1 1  0.41636257
#> 18 023  1.06646542  1.06646542  2.06646542 1 1  2.06646542
#> 19 024 -0.97577660 -0.97577660  0.02422340 1 1  0.02422340
#> 20 025 -1.01083183 -1.01083183 -0.01083183 1 1 -0.01083183
#> 21 026 -1.29972186 -1.29972186 -0.29972186 1 1 -0.29972186
#> 22 028 -1.19740664 -1.19740664 -0.19740664 1 0 -1.19740664
#> 23 030 -1.43753589 -1.43753589 -0.43753589 1 0 -1.43753589
#> 24 032  0.01364331  0.01364331  1.01364331 1 1  1.01364331
#> 25 033 -1.91067022 -1.91067022 -0.91067022 1 0 -1.91067022
#> 26 035 -0.48985099 -0.48985099  0.51014901 1 1  0.51014901
#> 27 036  0.44234093  0.44234093  1.44234093 1 1  1.44234093
#> 28 038 -1.68633028 -1.68633028 -0.68633028 1 0 -1.68633028
#> 29 039 -2.16358581 -2.16358581 -1.16358581 1 0 -2.16358581
#> 30 041  0.26241323  0.26241323  1.26241323 1 1  1.26241323
#> 31 042  1.84437511  1.84437511  2.84437511 1 1  2.84437511
#> 32 043 -2.47534728 -2.47534728 -1.47534728 1 0 -2.47534728
#> 33 044 -0.68735283 -0.68735283  0.31264717 1 0 -0.68735283
#> 34 045 -0.44285711 -0.44285711  0.55714289 1 1  0.55714289
#> 35 046  2.45387378  2.45387378  3.45387378 1 1  3.45387378
#> 36 047 -1.48795178 -1.48795178 -0.48795178 1 1 -0.48795178
#> 37 048 -0.78527243 -0.78527243  0.21472757 1 1  0.21472757
#> 38 049  0.05395408  0.05395408  1.05395408 1 0  0.05395408
#> 39 051  0.95892093  0.95892093  1.95892093 1 0  0.95892093
#> 40 054 -0.86143675 -0.86143675  0.13856325 1 1  0.13856325
#> 41 055  0.47508450  0.47508450  1.47508450 1 1  1.47508450
#> 42 057 -1.18066157 -1.18066157 -0.18066157 1 1 -0.18066157
#> 43 058 -0.58613612 -0.58613612  0.41386388 1 1  0.41386388
#> 44 059  0.08472062  0.08472062  1.08472062 1 1  1.08472062
#> 45 060  1.05731264  1.05731264  2.05731264 1 1  2.05731264
#> 46 061 -0.81324435 -0.81324435  0.18675565 1 0 -0.81324435
#> 47 063  1.43409212  1.43409212  2.43409212 1 1  2.43409212
#> 48 065  0.47050078  0.47050078  1.47050078 1 1  1.47050078
#> 49 066  1.10809924  1.10809924  2.10809924 1 1  2.10809924
#> 50 068 -0.55411463 -0.55411463  0.44588537 1 1  0.44588537
#> 51 069 -0.90599266 -0.90599266  0.09400734 1 0 -0.90599266
#> 52 070  0.27220105  0.27220105  1.27220105 1 1  1.27220105
#> 53 071 -0.53867014 -0.53867014  0.46132986 1 1  0.46132986
#> 54 072  0.01809364  0.01809364  1.01809364 1 1  1.01809364
#> 55 073 -0.68065585 -0.68065585  0.31934415 1 1  0.31934415
#> 56 074 -0.88351718 -0.88351718  0.11648282 1 1  0.11648282
#> 57 075  1.41977248  1.41977248  2.41977248 1 1  2.41977248
#> 58 077  0.90638178  0.90638178  1.90638178 1 1  1.90638178
#> 59 078  1.33567074  1.33567074  2.33567074 1 0  1.33567074
#> 60 079 -0.28253191 -0.28253191  0.71746809 1 1  0.71746809
#> 61 080  0.83229523  0.83229523  1.83229523 1 0  0.83229523
#> 62 081  1.05937523  1.05937523  2.05937523 1 1  2.05937523
#> 63 082  0.30755516  0.30755516  1.30755516 1 1  1.30755516
#> 64 083  1.57401786  1.57401786  2.57401786 1 1  2.57401786
#> 65 084 -0.71774125 -0.71774125  0.28225875 1 1  0.28225875
#> 66 085 -0.09386292 -0.09386292  0.90613708 1 0 -0.09386292
#> 67 086  0.84433451  0.84433451  1.84433451 1 0  0.84433451
#> 68 087  1.94287858  1.94287858  2.94287858 1 0  1.94287858
#> 69 090 -2.34526633 -2.34526633 -1.34526633 1 0 -2.34526633
#> 70 091  0.72967957  0.72967957  1.72967957 1 0  0.72967957
#> 71 092 -1.78544053 -1.78544053 -0.78544053 1 1 -0.78544053
#> 72 093  1.75044200  1.75044200  2.75044200 1 1  2.75044200
#> 73 095  0.22435566  0.22435566  1.22435566 1 0  0.22435566
#> 74 097 -1.16753042 -1.16753042 -0.16753042 1 0 -1.16753042
#> 75 099 -1.07929394 -1.07929394 -0.07929394 1 0 -1.07929394

get_estimates(design, data = dat)
#>   estimator term estimate std.error statistic     p.value conf.low conf.high df
#> 1 estimator    Z 1.383365 0.2661538  5.197614 1.76778e-06 0.852921  1.913809 73
#>   outcome inquiry
#> 1       Y     ATE