Explore your design
Print code to recreate a design
Arguments
- design
A design object, typically created using the + operator
- x
a design object, typically created using the + operator
- verbose
an indicator for printing a long summary of the design, defaults to
TRUE
- ...
optional arguments to be sent to summary function
- object
a design object created using the + operator
Examples
# Two-arm randomized experiment
design <-
declare_model(
N = 500,
gender = rbinom(N, 1, 0.5),
X = rep(c(0, 1), each = N / 2),
U = rnorm(N, sd = 0.25),
potential_outcomes(Y ~ 0.2 * Z + X + U)
) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_sampling(S = complete_rs(N = N, n = 200)) +
declare_assignment(Z = complete_ra(N = N, m = 100)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
# Use draw_data to create a dataset using a design
dat <- draw_data(design)
draw_data(design, data = dat, start = 2)
#> ID gender X U Y_Z_0 Y_Z_1 S Z Y
#> 1 001 0 0 -0.015204110 -0.015204110 0.184795890 1 1 0.184795890
#> 2 002 0 0 -0.009604956 -0.009604956 0.190395044 1 1 0.190395044
#> 3 004 0 0 0.338624821 0.338624821 0.538624821 1 1 0.538624821
#> 4 011 0 0 0.145978285 0.145978285 0.345978285 1 1 0.345978285
#> 5 013 1 0 0.170757132 0.170757132 0.370757132 1 0 0.170757132
#> 6 016 0 0 0.220910051 0.220910051 0.420910051 1 1 0.420910051
#> 7 018 0 0 0.075339930 0.075339930 0.275339930 1 0 0.075339930
#> 8 019 1 0 0.169490897 0.169490897 0.369490897 1 0 0.169490897
#> 9 020 0 0 0.293708196 0.293708196 0.493708196 1 0 0.293708196
#> 10 021 1 0 -0.192836120 -0.192836120 0.007163880 1 0 -0.192836120
#> 11 022 1 0 -0.130231050 -0.130231050 0.069768950 1 0 -0.130231050
#> 12 023 1 0 0.113341017 0.113341017 0.313341017 1 0 0.113341017
#> 13 028 0 0 -0.007910036 -0.007910036 0.192089964 1 0 -0.007910036
#> 14 029 0 0 0.087825452 0.087825452 0.287825452 1 0 0.087825452
#> 15 033 0 0 0.274404375 0.274404375 0.474404375 1 0 0.274404375
#> 16 034 0 0 -0.203100934 -0.203100934 -0.003100934 1 1 -0.003100934
#> 17 035 1 0 0.233853853 0.233853853 0.433853853 1 1 0.433853853
#> 18 037 1 0 -0.231715042 -0.231715042 -0.031715042 1 1 -0.031715042
#> 19 042 1 0 -0.415835953 -0.415835953 -0.215835953 1 1 -0.215835953
#> 20 044 1 0 0.383320381 0.383320381 0.583320381 1 1 0.583320381
#> 21 058 0 0 -0.307468631 -0.307468631 -0.107468631 1 0 -0.307468631
#> 22 060 0 0 -0.034468768 -0.034468768 0.165531232 1 0 -0.034468768
#> 23 062 1 0 0.127733365 0.127733365 0.327733365 1 1 0.327733365
#> 24 064 1 0 -0.094428848 -0.094428848 0.105571152 1 1 0.105571152
#> 25 065 1 0 0.165448701 0.165448701 0.365448701 1 0 0.165448701
#> 26 068 0 0 0.175044460 0.175044460 0.375044460 1 0 0.175044460
#> 27 071 0 0 -0.539485450 -0.539485450 -0.339485450 1 1 -0.339485450
#> 28 075 1 0 -0.160725177 -0.160725177 0.039274823 1 1 0.039274823
#> 29 077 1 0 -0.070897763 -0.070897763 0.129102237 1 1 0.129102237
#> 30 078 1 0 -0.186752107 -0.186752107 0.013247893 1 1 0.013247893
#> 31 080 0 0 -0.059430360 -0.059430360 0.140569640 1 1 0.140569640
#> 32 081 0 0 -0.180003284 -0.180003284 0.019996716 1 0 -0.180003284
#> 33 083 1 0 0.112784135 0.112784135 0.312784135 1 0 0.112784135
#> 34 084 1 0 0.108094464 0.108094464 0.308094464 1 0 0.108094464
#> 35 087 1 0 -0.048458023 -0.048458023 0.151541977 1 1 0.151541977
#> 36 088 0 0 -0.085763720 -0.085763720 0.114236280 1 0 -0.085763720
#> 37 094 0 0 0.378885251 0.378885251 0.578885251 1 1 0.578885251
#> 38 096 1 0 0.027221140 0.027221140 0.227221140 1 0 0.027221140
#> 39 097 1 0 -0.026035858 -0.026035858 0.173964142 1 0 -0.026035858
#> 40 098 1 0 0.293947787 0.293947787 0.493947787 1 1 0.493947787
#> 41 100 1 0 -0.008033102 -0.008033102 0.191966898 1 0 -0.008033102
#> 42 107 0 0 0.068305493 0.068305493 0.268305493 1 0 0.068305493
#> 43 114 0 0 0.087477808 0.087477808 0.287477808 1 0 0.087477808
#> 44 117 1 0 0.105075675 0.105075675 0.305075675 1 0 0.105075675
#> 45 118 1 0 0.124841207 0.124841207 0.324841207 1 1 0.324841207
#> 46 119 0 0 -0.075951187 -0.075951187 0.124048813 1 1 0.124048813
#> 47 122 1 0 -0.234364691 -0.234364691 -0.034364691 1 1 -0.034364691
#> 48 123 0 0 -0.307165677 -0.307165677 -0.107165677 1 0 -0.307165677
#> 49 125 1 0 0.273310720 0.273310720 0.473310720 1 1 0.473310720
#> 50 126 1 0 -0.390525305 -0.390525305 -0.190525305 1 1 -0.190525305
#> 51 130 0 0 -0.155325500 -0.155325500 0.044674500 1 0 -0.155325500
#> 52 132 1 0 -0.153498003 -0.153498003 0.046501997 1 0 -0.153498003
#> 53 137 0 0 -0.403273633 -0.403273633 -0.203273633 1 1 -0.203273633
#> 54 140 1 0 0.206454692 0.206454692 0.406454692 1 1 0.406454692
#> 55 141 0 0 -0.097497881 -0.097497881 0.102502119 1 0 -0.097497881
#> 56 142 1 0 -0.116145205 -0.116145205 0.083854795 1 1 0.083854795
#> 57 150 1 0 0.074376374 0.074376374 0.274376374 1 1 0.274376374
#> 58 151 0 0 -0.179989639 -0.179989639 0.020010361 1 0 -0.179989639
#> 59 154 1 0 0.058102563 0.058102563 0.258102563 1 0 0.058102563
#> 60 161 1 0 0.397881872 0.397881872 0.597881872 1 0 0.397881872
#> 61 163 0 0 -0.227041980 -0.227041980 -0.027041980 1 1 -0.027041980
#> 62 165 1 0 0.340062082 0.340062082 0.540062082 1 0 0.340062082
#> 63 169 1 0 0.120870989 0.120870989 0.320870989 1 1 0.320870989
#> 64 171 0 0 0.024331540 0.024331540 0.224331540 1 0 0.024331540
#> 65 177 0 0 0.004610404 0.004610404 0.204610404 1 1 0.204610404
#> 66 178 1 0 -0.183143410 -0.183143410 0.016856590 1 0 -0.183143410
#> 67 180 0 0 0.135106515 0.135106515 0.335106515 1 0 0.135106515
#> 68 181 1 0 0.415116145 0.415116145 0.615116145 1 0 0.415116145
#> 69 186 1 0 0.189016913 0.189016913 0.389016913 1 1 0.389016913
#> 70 187 1 0 0.168675703 0.168675703 0.368675703 1 1 0.368675703
#> 71 189 1 0 0.133958424 0.133958424 0.333958424 1 0 0.133958424
#> 72 190 0 0 0.109004700 0.109004700 0.309004700 1 0 0.109004700
#> 73 191 0 0 0.053462375 0.053462375 0.253462375 1 0 0.053462375
#> 74 192 0 0 -0.139066229 -0.139066229 0.060933771 1 1 0.060933771
#> 75 196 0 0 0.013155462 0.013155462 0.213155462 1 1 0.213155462
#> 76 197 0 0 0.167844307 0.167844307 0.367844307 1 0 0.167844307
#> 77 198 1 0 -0.174915504 -0.174915504 0.025084496 1 0 -0.174915504
#> 78 199 0 0 -0.111109553 -0.111109553 0.088890447 1 1 0.088890447
#> 79 204 0 0 0.083261420 0.083261420 0.283261420 1 0 0.083261420
#> 80 212 1 0 -0.254406673 -0.254406673 -0.054406673 1 0 -0.254406673
#> 81 214 1 0 -0.482293791 -0.482293791 -0.282293791 1 0 -0.482293791
#> 82 216 0 0 -0.186419602 -0.186419602 0.013580398 1 1 0.013580398
#> 83 218 0 0 0.129926679 0.129926679 0.329926679 1 0 0.129926679
#> 84 220 1 0 -0.065574915 -0.065574915 0.134425085 1 1 0.134425085
#> 85 221 1 0 -0.239200209 -0.239200209 -0.039200209 1 0 -0.239200209
#> 86 222 0 0 0.387260388 0.387260388 0.587260388 1 0 0.387260388
#> 87 229 0 0 -0.290195315 -0.290195315 -0.090195315 1 0 -0.290195315
#> 88 230 0 0 0.141733819 0.141733819 0.341733819 1 1 0.341733819
#> 89 233 0 0 -0.051944010 -0.051944010 0.148055990 1 1 0.148055990
#> 90 237 0 0 0.003961876 0.003961876 0.203961876 1 1 0.203961876
#> 91 243 1 0 -0.133484014 -0.133484014 0.066515986 1 1 0.066515986
#> 92 250 1 0 -0.036251762 -0.036251762 0.163748238 1 1 0.163748238
#> 93 253 0 1 0.071365280 1.071365280 1.271365280 1 1 1.271365280
#> 94 257 0 1 -0.018091636 0.981908364 1.181908364 1 1 1.181908364
#> 95 258 0 1 0.081308764 1.081308764 1.281308764 1 1 1.281308764
#> 96 259 1 1 0.089728642 1.089728642 1.289728642 1 0 1.089728642
#> 97 260 1 1 0.376046284 1.376046284 1.576046284 1 1 1.576046284
#> 98 263 1 1 -0.022932438 0.977067562 1.177067562 1 1 1.177067562
#> 99 268 0 1 -0.019005391 0.980994609 1.180994609 1 1 1.180994609
#> 100 269 0 1 0.077686184 1.077686184 1.277686184 1 0 1.077686184
#> 101 270 1 1 0.106927983 1.106927983 1.306927983 1 1 1.306927983
#> 102 272 0 1 -0.041550066 0.958449934 1.158449934 1 1 1.158449934
#> 103 277 0 1 -0.002125015 0.997874985 1.197874985 1 0 0.997874985
#> 104 282 0 1 -0.045978798 0.954021202 1.154021202 1 1 1.154021202
#> 105 283 1 1 -0.298495887 0.701504113 0.901504113 1 1 0.901504113
#> 106 289 0 1 -0.044484216 0.955515784 1.155515784 1 0 0.955515784
#> 107 291 1 1 -0.235837252 0.764162748 0.964162748 1 1 0.964162748
#> 108 294 0 1 -0.093943095 0.906056905 1.106056905 1 0 0.906056905
#> 109 295 1 1 -0.456467247 0.543532753 0.743532753 1 0 0.543532753
#> 110 296 1 1 -0.298306451 0.701693549 0.901693549 1 1 0.901693549
#> 111 300 1 1 -0.207379810 0.792620190 0.992620190 1 0 0.792620190
#> 112 302 1 1 0.133413248 1.133413248 1.333413248 1 0 1.133413248
#> 113 303 0 1 -0.304079861 0.695920139 0.895920139 1 1 0.895920139
#> 114 304 1 1 -0.200727555 0.799272445 0.999272445 1 1 0.999272445
#> 115 305 0 1 0.045999757 1.045999757 1.245999757 1 0 1.045999757
#> 116 306 0 1 0.108631801 1.108631801 1.308631801 1 1 1.308631801
#> 117 308 1 1 -0.043026828 0.956973172 1.156973172 1 0 0.956973172
#> 118 310 0 1 -0.054530439 0.945469561 1.145469561 1 1 1.145469561
#> 119 311 0 1 0.160799616 1.160799616 1.360799616 1 0 1.160799616
#> 120 314 0 1 0.083677866 1.083677866 1.283677866 1 1 1.283677866
#> 121 317 0 1 0.074223571 1.074223571 1.274223571 1 1 1.274223571
#> 122 320 0 1 0.075062563 1.075062563 1.275062563 1 1 1.275062563
#> 123 324 1 1 0.403516161 1.403516161 1.603516161 1 0 1.403516161
#> 124 327 0 1 0.320563444 1.320563444 1.520563444 1 1 1.520563444
#> 125 331 0 1 0.031584092 1.031584092 1.231584092 1 0 1.031584092
#> 126 332 1 1 -0.027003206 0.972996794 1.172996794 1 1 1.172996794
#> 127 335 1 1 -0.168875028 0.831124972 1.031124972 1 1 1.031124972
#> 128 336 1 1 0.037538949 1.037538949 1.237538949 1 0 1.037538949
#> 129 337 0 1 -0.180239782 0.819760218 1.019760218 1 1 1.019760218
#> 130 339 1 1 -0.070609404 0.929390596 1.129390596 1 1 1.129390596
#> 131 340 0 1 -0.008203933 0.991796067 1.191796067 1 1 1.191796067
#> 132 342 0 1 0.089942220 1.089942220 1.289942220 1 0 1.089942220
#> 133 344 1 1 -0.141015722 0.858984278 1.058984278 1 0 0.858984278
#> 134 348 1 1 0.496876708 1.496876708 1.696876708 1 0 1.496876708
#> 135 352 1 1 -0.344694227 0.655305773 0.855305773 1 0 0.655305773
#> 136 353 0 1 -0.385581003 0.614418997 0.814418997 1 0 0.614418997
#> 137 354 0 1 -0.351473777 0.648526223 0.848526223 1 0 0.648526223
#> 138 355 0 1 0.084123843 1.084123843 1.284123843 1 0 1.084123843
#> 139 356 1 1 0.059414009 1.059414009 1.259414009 1 1 1.259414009
#> 140 359 1 1 -0.074434835 0.925565165 1.125565165 1 0 0.925565165
#> 141 371 0 1 -0.293356592 0.706643408 0.906643408 1 0 0.706643408
#> 142 374 0 1 0.137693920 1.137693920 1.337693920 1 1 1.337693920
#> 143 375 0 1 0.430618072 1.430618072 1.630618072 1 1 1.630618072
#> 144 376 0 1 0.020279467 1.020279467 1.220279467 1 1 1.220279467
#> 145 377 1 1 -0.440559868 0.559440132 0.759440132 1 1 0.759440132
#> 146 378 0 1 -0.471364958 0.528635042 0.728635042 1 0 0.528635042
#> 147 379 0 1 0.268487497 1.268487497 1.468487497 1 0 1.268487497
#> 148 385 1 1 -0.090573832 0.909426168 1.109426168 1 1 1.109426168
#> 149 387 0 1 -0.472261752 0.527738248 0.727738248 1 0 0.527738248
#> 150 391 1 1 0.234171030 1.234171030 1.434171030 1 0 1.234171030
#> 151 392 1 1 0.128360843 1.128360843 1.328360843 1 1 1.328360843
#> 152 393 1 1 0.076937070 1.076937070 1.276937070 1 0 1.076937070
#> 153 394 0 1 -0.184544815 0.815455185 1.015455185 1 0 0.815455185
#> 154 399 1 1 0.174645808 1.174645808 1.374645808 1 0 1.174645808
#> 155 401 0 1 -0.252454710 0.747545290 0.947545290 1 1 0.947545290
#> 156 402 1 1 -0.134670426 0.865329574 1.065329574 1 0 0.865329574
#> 157 403 1 1 0.093899120 1.093899120 1.293899120 1 1 1.293899120
#> 158 406 1 1 -0.039437162 0.960562838 1.160562838 1 1 1.160562838
#> 159 410 1 1 0.236091143 1.236091143 1.436091143 1 0 1.236091143
#> 160 411 0 1 0.032375147 1.032375147 1.232375147 1 0 1.032375147
#> 161 414 1 1 0.343106513 1.343106513 1.543106513 1 1 1.543106513
#> 162 415 0 1 0.053210475 1.053210475 1.253210475 1 1 1.253210475
#> 163 419 1 1 0.352700139 1.352700139 1.552700139 1 0 1.352700139
#> 164 422 1 1 -0.273380845 0.726619155 0.926619155 1 1 0.926619155
#> 165 423 1 1 0.133230105 1.133230105 1.333230105 1 0 1.133230105
#> 166 429 0 1 -0.609689049 0.390310951 0.590310951 1 0 0.390310951
#> 167 430 1 1 -0.225211095 0.774788905 0.974788905 1 1 0.974788905
#> 168 431 0 1 -0.005091469 0.994908531 1.194908531 1 1 1.194908531
#> 169 432 0 1 0.346073685 1.346073685 1.546073685 1 0 1.346073685
#> 170 433 0 1 -0.075251758 0.924748242 1.124748242 1 1 1.124748242
#> 171 434 0 1 0.129377940 1.129377940 1.329377940 1 0 1.129377940
#> 172 436 1 1 0.392074705 1.392074705 1.592074705 1 1 1.592074705
#> 173 437 0 1 -0.035444745 0.964555255 1.164555255 1 0 0.964555255
#> 174 443 0 1 0.352448872 1.352448872 1.552448872 1 1 1.552448872
#> 175 447 1 1 -0.101018807 0.898981193 1.098981193 1 1 1.098981193
#> 176 449 0 1 0.116699550 1.116699550 1.316699550 1 1 1.316699550
#> 177 450 1 1 0.069595700 1.069595700 1.269595700 1 0 1.069595700
#> 178 452 1 1 0.152790622 1.152790622 1.352790622 1 0 1.152790622
#> 179 454 0 1 -0.391294143 0.608705857 0.808705857 1 0 0.608705857
#> 180 455 1 1 0.459467894 1.459467894 1.659467894 1 1 1.659467894
#> 181 457 1 1 0.293128190 1.293128190 1.493128190 1 1 1.493128190
#> 182 458 1 1 0.089446140 1.089446140 1.289446140 1 1 1.289446140
#> 183 463 1 1 -0.062500862 0.937499138 1.137499138 1 0 0.937499138
#> 184 464 1 1 -0.420636878 0.579363122 0.779363122 1 1 0.779363122
#> 185 466 0 1 -0.559295906 0.440704094 0.640704094 1 0 0.440704094
#> 186 467 0 1 0.160423712 1.160423712 1.360423712 1 0 1.160423712
#> 187 470 0 1 -0.070158469 0.929841531 1.129841531 1 1 1.129841531
#> 188 471 1 1 0.144622279 1.144622279 1.344622279 1 1 1.344622279
#> 189 473 0 1 0.232168507 1.232168507 1.432168507 1 1 1.432168507
#> 190 476 0 1 0.352286941 1.352286941 1.552286941 1 0 1.352286941
#> 191 478 0 1 0.115932543 1.115932543 1.315932543 1 1 1.315932543
#> 192 479 1 1 -0.207320463 0.792679537 0.992679537 1 1 0.992679537
#> 193 482 0 1 -0.052143565 0.947856435 1.147856435 1 0 0.947856435
#> 194 483 1 1 -0.126100563 0.873899437 1.073899437 1 0 0.873899437
#> 195 489 1 1 -0.172773077 0.827226923 1.027226923 1 0 0.827226923
#> 196 490 0 1 -0.290126233 0.709873767 0.909873767 1 0 0.709873767
#> 197 491 0 1 -0.272129124 0.727870876 0.927870876 1 1 0.927870876
#> 198 492 1 1 -0.091540939 0.908459061 1.108459061 1 0 0.908459061
#> 199 498 1 1 0.266822160 1.266822160 1.466822160 1 1 1.466822160
#> 200 499 0 1 -0.274671809 0.725328191 0.925328191 1 0 0.725328191
# Apply get_estimates
get_estimates(design, data = dat)
#> estimator term estimate std.error statistic p.value conf.low
#> 1 estimator Z 0.1556289 0.07656664 2.032595 0.04342876 0.004638196
#> conf.high df outcome inquiry
#> 1 0.3066197 198 Y ATE
# Two-arm randomized experiment
design <-
declare_model(
N = 500,
gender = rbinom(N, 1, 0.5),
X = rep(c(0, 1), each = N / 2),
U = rnorm(N, sd = 0.25),
potential_outcomes(Y ~ 0.2 * Z + X + U)
) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_sampling(S = complete_rs(N = N, n = 200)) +
declare_assignment(Z = complete_ra(N = N, m = 100)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
print_code(design)
#> model <- declare_model(N = 500, gender = rbinom(N, 1, 0.5), X = rep(c(0, 1), each = N/2), U = rnorm(N, sd = 0.25), potential_outcomes(Y ~ 0.2 * Z + X + U))
#>
#> ATE <- declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0))
#>
#> sampling <- declare_sampling(S = complete_rs(N = N, n = 200))
#>
#> assignment <- declare_assignment(Z = complete_ra(N = N, m = 100))
#>
#> measurement <- declare_measurement(Y = reveal_outcomes(Y ~ Z))
#>
#> estimator <- declare_estimator(Y ~ Z, inquiry = "ATE")
#>
#> my_design <- construct_design(steps = steps)
#>
summary(design)
#>
#> Research design declaration summary
#>
#> Step 1 (model): declare_model(N = 500, gender = rbinom(N, 1, 0.5), X = rep(c(0, 1), each = N/2), U = rnorm(N, sd = 0.25), potential_outcomes(Y ~ 0.2 * Z + X + U))
#>
#> N = 500
#>
#> Added variable: ID
#> N_missing N_unique class
#> 0 500 character
#>
#> Added variable: gender
#> 0 1
#> 239 261
#> 0.48 0.52
#>
#> Added variable: X
#> 0 1
#> 250 250
#> 0.50 0.50
#>
#> Added variable: U
#> min median mean max sd N_missing N_unique
#> -0.71 0.04 0.01 0.79 0.27 0 500
#>
#> Added variable: Y_Z_0
#> min median mean max sd N_missing N_unique
#> -0.71 0.5 0.51 1.71 0.58 0 500
#>
#> Added variable: Y_Z_1
#> min median mean max sd N_missing N_unique
#> -0.51 0.7 0.71 1.91 0.58 0 500
#>
#> Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------
#>
#> A single draw of the inquiry:
#> inquiry estimand
#> ATE 0.2
#>
#> Step 3 (sampling): declare_sampling(S = complete_rs(N = N, n = 200)) -----------
#>
#> N = 200 (300 subtracted)
#>
#> Added variable: S
#> 1
#> 200
#> 1.00
#>
#> Altered variable: ID
#> Before:
#> N_missing N_unique class
#> 0 500 character
#>
#> After:
#> N_missing N_unique class
#> 0 200 character
#>
#> Altered variable: gender
#> Before:
#> 0 1
#> 239 261
#> 0.48 0.52
#>
#> After:
#> 0 1
#> 101 99
#> 0.51 0.49
#>
#> Altered variable: X
#> Before:
#> 0 1
#> 250 250
#> 0.50 0.50
#>
#> After:
#> 0 1
#> 96 104
#> 0.48 0.52
#>
#> Altered variable: U
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.71 0.04 0.01 0.79 0.27 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.62 0.02 0 0.79 0.27 0 200
#>
#> Altered variable: Y_Z_0
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.71 0.5 0.51 1.71 0.58 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.62 0.57 0.52 1.64 0.58 0 200
#>
#> Altered variable: Y_Z_1
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.51 0.7 0.71 1.91 0.58 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.42 0.77 0.72 1.84 0.58 0 200
#>
#> Step 4 (assignment): declare_assignment(Z = complete_ra(N = N, m = 100)) -------
#>
#> Added variable: Z
#> 0 1
#> 100 100
#> 0.50 0.50
#>
#> Step 5 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------
#>
#> Added variable: Y
#> min median mean max sd N_missing N_unique
#> -0.59 0.68 0.62 1.84 0.6 0 200
#>
#> Step 6 (estimator): declare_estimator(Y ~ Z, inquiry = "ATE") ------------------
#>
#> Formula: Y ~ Z
#>
#> A single draw of the estimator:
#> estimator term estimate std.error statistic p.value conf.low conf.high
#> estimator Z 0.2600292 0.08248973 3.152262 0.001871891 0.09735804 0.4227004
#> df outcome inquiry
#> 198 Y ATE
#>
design <-
declare_model(
N = 500,
noise = rnorm(N),
Y_Z_0 = noise,
Y_Z_1 = noise + rnorm(N, mean = 2, sd = 2)
) +
declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
declare_sampling(S = complete_rs(N, n = 250)) +
declare_assignment(Z = complete_ra(N, m = 25)) +
declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
declare_estimator(Y ~ Z, inquiry = "ATE")
summary(design)
#>
#> Research design declaration summary
#>
#> Step 1 (model): declare_model(N = 500, noise = rnorm(N), Y_Z_0 = noise, Y_Z_1 = noise + rnorm(N, mean = 2, sd = 2))
#>
#> N = 500
#>
#> Added variable: ID
#> N_missing N_unique class
#> 0 500 character
#>
#> Added variable: noise
#> min median mean max sd N_missing N_unique
#> -2.99 0.08 0.07 3.34 1.03 0 500
#>
#> Added variable: Y_Z_0
#> min median mean max sd N_missing N_unique
#> -2.99 0.08 0.07 3.34 1.03 0 500
#>
#> Added variable: Y_Z_1
#> min median mean max sd N_missing N_unique
#> -4.53 2.17 2.09 8.64 2.33 0 500
#>
#> Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------
#>
#> A single draw of the inquiry:
#> inquiry estimand
#> ATE 2.019162
#>
#> Step 3 (sampling): declare_sampling(S = complete_rs(N, n = 250)) ---------------
#>
#> N = 250 (250 subtracted)
#>
#> Added variable: S
#> 1
#> 250
#> 1.00
#>
#> Altered variable: ID
#> Before:
#> N_missing N_unique class
#> 0 500 character
#>
#> After:
#> N_missing N_unique class
#> 0 250 character
#>
#> Altered variable: noise
#> Before:
#> min median mean max sd N_missing N_unique
#> -2.99 0.08 0.07 3.34 1.03 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -2.99 0.1 0.11 2.79 1.06 0 250
#>
#> Altered variable: Y_Z_0
#> Before:
#> min median mean max sd N_missing N_unique
#> -2.99 0.08 0.07 3.34 1.03 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -2.99 0.1 0.11 2.79 1.06 0 250
#>
#> Altered variable: Y_Z_1
#> Before:
#> min median mean max sd N_missing N_unique
#> -4.53 2.17 2.09 8.64 2.33 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -4.48 2.26 2.13 8.64 2.42 0 250
#>
#> Step 4 (assignment): declare_assignment(Z = complete_ra(N, m = 25)) ------------
#>
#> Added variable: Z
#> 0 1
#> 225 25
#> 0.90 0.10
#>
#> Step 5 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------
#>
#> Added variable: Y
#> min median mean max sd N_missing N_unique
#> -2.99 0.16 0.35 6.01 1.46 0 250
#>
#> Step 6 (estimator): declare_estimator(Y ~ Z, inquiry = "ATE") ------------------
#>
#> Formula: Y ~ Z
#>
#> A single draw of the estimator:
#> estimator term estimate std.error statistic p.value conf.low conf.high
#> estimator Z 2.872137 0.3851356 7.457469 1.477573e-12 2.113583 3.63069
#> df outcome inquiry
#> 248 Y ATE
#>