Skip to contents

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.0882089238  0.0882089238  1.08820892 1 1  1.0882089238
#> 2  002 -1.0292766857 -1.0292766857 -0.02927669 1 0 -1.0292766857
#> 3  003  1.2779934244  1.2779934244  2.27799342 1 1  2.2779934244
#> 4  004  0.7105235432  0.7105235432  1.71052354 1 0  0.7105235432
#> 5  005  0.7914846285  0.7914846285  1.79148463 1 1  1.7914846285
#> 6  007  1.6603131711  1.6603131711  2.66031317 1 1  2.6603131711
#> 7  008  0.3047936432  0.3047936432  1.30479364 1 1  1.3047936432
#> 8  009 -0.5500670345 -0.5500670345  0.44993297 1 0 -0.5500670345
#> 9  010  1.3277120533  1.3277120533  2.32771205 1 1  2.3277120533
#> 10 013 -1.7236784285 -1.7236784285 -0.72367843 1 0 -1.7236784285
#> 11 014 -0.1503354177 -0.1503354177  0.84966458 1 0 -0.1503354177
#> 12 015  1.8756216335  1.8756216335  2.87562163 1 0  1.8756216335
#> 13 016 -0.0541494824 -0.0541494824  0.94585052 1 1  0.9458505176
#> 14 017  1.0358508443  1.0358508443  2.03585084 1 0  1.0358508443
#> 15 020  1.1596702795  1.1596702795  2.15967028 1 1  2.1596702795
#> 16 023  0.4234695792  0.4234695792  1.42346958 1 1  1.4234695792
#> 17 026  0.3215289594  0.3215289594  1.32152896 1 0  0.3215289594
#> 18 027 -0.5407272392 -0.5407272392  0.45927276 1 1  0.4592727608
#> 19 028  0.3747787693  0.3747787693  1.37477877 1 0  0.3747787693
#> 20 029  0.9089614553  0.9089614553  1.90896146 1 1  1.9089614553
#> 21 032 -0.2657090705 -0.2657090705  0.73429093 1 1  0.7342909295
#> 22 034  1.5162468592  1.5162468592  2.51624686 1 1  2.5162468592
#> 23 035  0.4324264148  0.4324264148  1.43242641 1 1  1.4324264148
#> 24 037  1.1543223901  1.1543223901  2.15432239 1 0  1.1543223901
#> 25 038 -0.3519515680 -0.3519515680  0.64804843 1 1  0.6480484320
#> 26 039  0.0904071634  0.0904071634  1.09040716 1 0  0.0904071634
#> 27 041 -0.4797596627 -0.4797596627  0.52024034 1 0 -0.4797596627
#> 28 042 -0.6064035999 -0.6064035999  0.39359640 1 1  0.3935964001
#> 29 043  1.4200548842  1.4200548842  2.42005488 1 0  1.4200548842
#> 30 044 -0.4343053081 -0.4343053081  0.56569469 1 1  0.5656946919
#> 31 045  0.2083944993  0.2083944993  1.20839450 1 1  1.2083944993
#> 32 046 -0.6046266729 -0.6046266729  0.39537333 1 0 -0.6046266729
#> 33 047 -0.5251420547 -0.5251420547  0.47485795 1 1  0.4748579453
#> 34 048 -1.7963713260 -1.7963713260 -0.79637133 1 1 -0.7963713260
#> 35 050 -0.7929924917 -0.7929924917  0.20700751 1 1  0.2070075083
#> 36 051  1.3886685138  1.3886685138  2.38866851 1 0  1.3886685138
#> 37 052 -0.5736266555 -0.5736266555  0.42637334 1 1  0.4263733445
#> 38 053  0.9699459434  0.9699459434  1.96994594 1 1  1.9699459434
#> 39 054  0.3289058652  0.3289058652  1.32890587 1 1  1.3289058652
#> 40 055  0.1484392313  0.1484392313  1.14843923 1 1  1.1484392313
#> 41 056  0.2829642480  0.2829642480  1.28296425 1 1  1.2829642480
#> 42 057  0.3647237515  0.3647237515  1.36472375 1 0  0.3647237515
#> 43 058 -0.0061179292 -0.0061179292  0.99388207 1 1  0.9938820708
#> 44 060 -0.8674028300 -0.8674028300  0.13259717 1 1  0.1325971700
#> 45 062 -1.1129214590 -1.1129214590 -0.11292146 1 0 -1.1129214590
#> 46 063 -2.5013238759 -2.5013238759 -1.50132388 1 1 -1.5013238759
#> 47 064  0.6974536625  0.6974536625  1.69745366 1 1  1.6974536625
#> 48 065  0.7607386805  0.7607386805  1.76073868 1 1  1.7607386805
#> 49 066 -1.3474703481 -1.3474703481 -0.34747035 1 1 -0.3474703481
#> 50 067  0.0558961754  0.0558961754  1.05589618 1 1  1.0558961754
#> 51 068  1.7986213913  1.7986213913  2.79862139 1 0  1.7986213913
#> 52 070  0.8221474598  0.8221474598  1.82214746 1 0  0.8221474598
#> 53 073 -0.0347925819 -0.0347925819  0.96520742 1 0 -0.0347925819
#> 54 074 -0.1676471288 -0.1676471288  0.83235287 1 1  0.8323528712
#> 55 075  0.5451575935  0.5451575935  1.54515759 1 0  0.5451575935
#> 56 077 -0.4246700888 -0.4246700888  0.57532991 1 1  0.5753299112
#> 57 078 -2.1414031275 -2.1414031275 -1.14140313 1 1 -1.1414031275
#> 58 079 -0.0008089723 -0.0008089723  0.99919103 1 0 -0.0008089723
#> 59 080  0.5878388495  0.5878388495  1.58783885 1 1  1.5878388495
#> 60 081  0.5804638019  0.5804638019  1.58046380 1 0  0.5804638019
#> 61 082 -0.2474545353 -0.2474545353  0.75254546 1 1  0.7525454647
#> 62 083 -0.8051049410 -0.8051049410  0.19489506 1 1  0.1948950590
#> 63 086 -0.5907518497 -0.5907518497  0.40924815 1 1  0.4092481503
#> 64 087  0.1248311383  0.1248311383  1.12483114 1 1  1.1248311383
#> 65 088  0.7860616174  0.7860616174  1.78606162 1 0  0.7860616174
#> 66 090  0.0636519345  0.0636519345  1.06365193 1 1  1.0636519345
#> 67 091  0.5927793409  0.5927793409  1.59277934 1 0  0.5927793409
#> 68 092 -1.2490324652 -1.2490324652 -0.24903247 1 1 -0.2490324652
#> 69 094 -0.0877122098 -0.0877122098  0.91228779 1 1  0.9122877902
#> 70 095 -0.5420908691 -0.5420908691  0.45790913 1 1  0.4579091309
#> 71 096 -0.6760862950 -0.6760862950  0.32391371 1 1  0.3239137050
#> 72 097 -0.4438990479 -0.4438990479  0.55610095 1 1  0.5561009521
#> 73 098 -0.2305011819 -0.2305011819  0.76949882 1 1  0.7694988181
#> 74 099 -1.3615372386 -1.3615372386 -0.36153724 1 1 -0.3615372386
#> 75 100  0.9221624282  0.9221624282  1.92216243 1 1  1.9221624282

get_estimates(design, data = dat)
#>   estimator term estimate std.error statistic      p.value  conf.low conf.high
#> 1 estimator    Z 1.113085 0.2146903  5.184607 1.860258e-06 0.6852075  1.540962
#>   df outcome inquiry
#> 1 73       Y     ATE