Skip to contents

Explore your design

Print code to recreate a design

Usage

print_code(design)

# S3 method for class 'design'
print(x, verbose = FALSE, ...)

# S3 method for class 'design'
summary(object, verbose = TRUE, ...)

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   003      0 0 -0.150486326 -0.150486326  0.049513674 1 0 -0.150486326
#> 2   006      1 0 -0.084587862 -0.084587862  0.115412138 1 0 -0.084587862
#> 3   007      1 0  0.194461738  0.194461738  0.394461738 1 0  0.194461738
#> 4   009      1 0  0.213616023  0.213616023  0.413616023 1 0  0.213616023
#> 5   011      0 0 -0.013242846 -0.013242846  0.186757154 1 1  0.186757154
#> 6   012      0 0 -0.204212683 -0.204212683 -0.004212683 1 1 -0.004212683
#> 7   013      0 0  0.154427687  0.154427687  0.354427687 1 1  0.354427687
#> 8   014      0 0 -0.112189277 -0.112189277  0.087810723 1 1  0.087810723
#> 9   015      1 0 -0.259167049 -0.259167049 -0.059167049 1 0 -0.259167049
#> 10  017      0 0 -0.060665974 -0.060665974  0.139334026 1 0 -0.060665974
#> 11  021      1 0  0.038150194  0.038150194  0.238150194 1 1  0.238150194
#> 12  022      1 0  0.543230193  0.543230193  0.743230193 1 1  0.743230193
#> 13  024      0 0 -0.150472420 -0.150472420  0.049527580 1 1  0.049527580
#> 14  026      0 0 -0.125173485 -0.125173485  0.074826515 1 1  0.074826515
#> 15  028      1 0  0.158083990  0.158083990  0.358083990 1 1  0.358083990
#> 16  031      1 0 -0.037207535 -0.037207535  0.162792465 1 1  0.162792465
#> 17  033      1 0  0.216372199  0.216372199  0.416372199 1 1  0.416372199
#> 18  041      1 0 -0.302800988 -0.302800988 -0.102800988 1 0 -0.302800988
#> 19  044      1 0  0.063166772  0.063166772  0.263166772 1 1  0.263166772
#> 20  045      0 0  0.392432089  0.392432089  0.592432089 1 0  0.392432089
#> 21  047      1 0 -0.211267141 -0.211267141 -0.011267141 1 1 -0.011267141
#> 22  053      0 0  0.200910023  0.200910023  0.400910023 1 1  0.400910023
#> 23  054      1 0 -0.373313806 -0.373313806 -0.173313806 1 0 -0.373313806
#> 24  055      1 0  0.292453637  0.292453637  0.492453637 1 0  0.292453637
#> 25  062      0 0 -0.346026735 -0.346026735 -0.146026735 1 0 -0.346026735
#> 26  063      1 0  0.119288470  0.119288470  0.319288470 1 0  0.119288470
#> 27  066      1 0  0.128680071  0.128680071  0.328680071 1 1  0.328680071
#> 28  068      0 0  0.336870863  0.336870863  0.536870863 1 1  0.536870863
#> 29  074      1 0  0.335830139  0.335830139  0.535830139 1 0  0.335830139
#> 30  075      1 0  0.020228561  0.020228561  0.220228561 1 0  0.020228561
#> 31  076      0 0 -0.258645739 -0.258645739 -0.058645739 1 0 -0.258645739
#> 32  081      0 0 -0.063642148 -0.063642148  0.136357852 1 1  0.136357852
#> 33  082      1 0  0.611224653  0.611224653  0.811224653 1 1  0.811224653
#> 34  083      1 0  0.115876148  0.115876148  0.315876148 1 1  0.315876148
#> 35  087      0 0 -0.163010959 -0.163010959  0.036989041 1 0 -0.163010959
#> 36  090      0 0  0.210371064  0.210371064  0.410371064 1 1  0.410371064
#> 37  091      1 0  0.093532125  0.093532125  0.293532125 1 1  0.293532125
#> 38  092      0 0  0.309967308  0.309967308  0.509967308 1 0  0.309967308
#> 39  093      0 0  0.057506171  0.057506171  0.257506171 1 0  0.057506171
#> 40  098      0 0 -0.579069666 -0.579069666 -0.379069666 1 1 -0.379069666
#> 41  099      1 0 -0.100917158 -0.100917158  0.099082842 1 0 -0.100917158
#> 42  100      1 0 -0.323532267 -0.323532267 -0.123532267 1 0 -0.323532267
#> 43  101      0 0  0.269007461  0.269007461  0.469007461 1 1  0.469007461
#> 44  106      0 0 -0.285804918 -0.285804918 -0.085804918 1 0 -0.285804918
#> 45  108      0 0 -0.098915984 -0.098915984  0.101084016 1 0 -0.098915984
#> 46  110      0 0  0.102852340  0.102852340  0.302852340 1 0  0.102852340
#> 47  112      1 0 -0.246558941 -0.246558941 -0.046558941 1 1 -0.046558941
#> 48  120      0 0 -0.044145759 -0.044145759  0.155854241 1 1  0.155854241
#> 49  123      1 0  0.113026977  0.113026977  0.313026977 1 0  0.113026977
#> 50  124      0 0  0.554036640  0.554036640  0.754036640 1 0  0.554036640
#> 51  126      1 0 -0.110071367 -0.110071367  0.089928633 1 0 -0.110071367
#> 52  131      1 0  0.165169779  0.165169779  0.365169779 1 0  0.165169779
#> 53  133      1 0  0.235376348  0.235376348  0.435376348 1 1  0.435376348
#> 54  134      1 0 -0.154996338 -0.154996338  0.045003662 1 0 -0.154996338
#> 55  136      1 0  0.044519764  0.044519764  0.244519764 1 1  0.244519764
#> 56  137      1 0  0.376869001  0.376869001  0.576869001 1 0  0.376869001
#> 57  140      0 0 -0.024259690 -0.024259690  0.175740310 1 0 -0.024259690
#> 58  141      0 0  0.328723768  0.328723768  0.528723768 1 0  0.328723768
#> 59  143      1 0 -0.148174563 -0.148174563  0.051825437 1 0 -0.148174563
#> 60  150      1 0  0.217938047  0.217938047  0.417938047 1 1  0.417938047
#> 61  153      1 0  0.201303501  0.201303501  0.401303501 1 1  0.401303501
#> 62  157      0 0 -0.296321268 -0.296321268 -0.096321268 1 0 -0.296321268
#> 63  158      0 0  0.226451783  0.226451783  0.426451783 1 1  0.426451783
#> 64  162      1 0  0.141916145  0.141916145  0.341916145 1 1  0.341916145
#> 65  163      1 0  0.346803277  0.346803277  0.546803277 1 0  0.346803277
#> 66  169      1 0  0.452663549  0.452663549  0.652663549 1 0  0.452663549
#> 67  171      1 0  0.167137615  0.167137615  0.367137615 1 0  0.167137615
#> 68  176      0 0 -0.269437036 -0.269437036 -0.069437036 1 1 -0.069437036
#> 69  177      0 0 -0.118090636 -0.118090636  0.081909364 1 1  0.081909364
#> 70  178      0 0  0.010701505  0.010701505  0.210701505 1 0  0.010701505
#> 71  184      1 0 -0.097696388 -0.097696388  0.102303612 1 1  0.102303612
#> 72  185      1 0  0.282139647  0.282139647  0.482139647 1 1  0.482139647
#> 73  186      1 0  0.004699545  0.004699545  0.204699545 1 0  0.004699545
#> 74  188      1 0 -0.224135278 -0.224135278 -0.024135278 1 0 -0.224135278
#> 75  190      1 0 -0.003463190 -0.003463190  0.196536810 1 0 -0.003463190
#> 76  192      1 0  0.132768266  0.132768266  0.332768266 1 1  0.332768266
#> 77  200      0 0  0.326750321  0.326750321  0.526750321 1 0  0.326750321
#> 78  201      0 0 -0.369522095 -0.369522095 -0.169522095 1 0 -0.369522095
#> 79  202      1 0 -0.054320190 -0.054320190  0.145679810 1 0 -0.054320190
#> 80  204      0 0  0.452766465  0.452766465  0.652766465 1 1  0.652766465
#> 81  207      0 0 -0.087613663 -0.087613663  0.112386337 1 1  0.112386337
#> 82  208      0 0  0.157238360  0.157238360  0.357238360 1 0  0.157238360
#> 83  209      0 0  0.156817605  0.156817605  0.356817605 1 1  0.356817605
#> 84  210      0 0  0.106786788  0.106786788  0.306786788 1 0  0.106786788
#> 85  211      1 0  0.285225442  0.285225442  0.485225442 1 0  0.285225442
#> 86  219      0 0  0.231139552  0.231139552  0.431139552 1 1  0.431139552
#> 87  223      0 0  0.107620599  0.107620599  0.307620599 1 1  0.307620599
#> 88  225      0 0  0.225982875  0.225982875  0.425982875 1 1  0.425982875
#> 89  228      1 0 -0.067940607 -0.067940607  0.132059393 1 1  0.132059393
#> 90  238      0 0 -0.116158295 -0.116158295  0.083841705 1 1  0.083841705
#> 91  245      1 0 -0.140797314 -0.140797314  0.059202686 1 1  0.059202686
#> 92  247      0 0  0.118085070  0.118085070  0.318085070 1 1  0.318085070
#> 93  249      0 0  0.298908778  0.298908778  0.498908778 1 0  0.298908778
#> 94  251      1 1  0.382034269  1.382034269  1.582034269 1 1  1.582034269
#> 95  252      1 1 -0.036625508  0.963374492  1.163374492 1 0  0.963374492
#> 96  254      0 1  0.031560388  1.031560388  1.231560388 1 0  1.031560388
#> 97  255      1 1 -0.011660201  0.988339799  1.188339799 1 0  0.988339799
#> 98  257      0 1  0.333300076  1.333300076  1.533300076 1 1  1.533300076
#> 99  259      0 1 -0.088735418  0.911264582  1.111264582 1 0  0.911264582
#> 100 260      1 1 -0.335594465  0.664405535  0.864405535 1 0  0.664405535
#> 101 261      1 1  0.107553015  1.107553015  1.307553015 1 1  1.307553015
#> 102 263      0 1 -0.088524742  0.911475258  1.111475258 1 1  1.111475258
#> 103 266      0 1 -0.131663434  0.868336566  1.068336566 1 0  0.868336566
#> 104 277      1 1  0.198441226  1.198441226  1.398441226 1 0  1.198441226
#> 105 279      0 1 -0.010962140  0.989037860  1.189037860 1 1  1.189037860
#> 106 285      0 1  0.204915458  1.204915458  1.404915458 1 1  1.404915458
#> 107 289      1 1 -0.147299106  0.852700894  1.052700894 1 1  1.052700894
#> 108 299      0 1  0.193049598  1.193049598  1.393049598 1 0  1.193049598
#> 109 300      0 1 -0.173685832  0.826314168  1.026314168 1 0  0.826314168
#> 110 301      1 1 -0.049088480  0.950911520  1.150911520 1 0  0.950911520
#> 111 305      0 1 -0.054268542  0.945731458  1.145731458 1 0  0.945731458
#> 112 308      0 1  0.089151498  1.089151498  1.289151498 1 0  1.089151498
#> 113 310      1 1 -0.199640749  0.800359251  1.000359251 1 0  0.800359251
#> 114 312      0 1  0.060769489  1.060769489  1.260769489 1 0  1.060769489
#> 115 313      1 1  0.249679839  1.249679839  1.449679839 1 1  1.449679839
#> 116 314      0 1 -0.172034822  0.827965178  1.027965178 1 0  0.827965178
#> 117 316      1 1  0.191559560  1.191559560  1.391559560 1 1  1.391559560
#> 118 317      0 1  0.018177846  1.018177846  1.218177846 1 0  1.018177846
#> 119 318      0 1  0.279421615  1.279421615  1.479421615 1 0  1.279421615
#> 120 319      1 1 -0.025904472  0.974095528  1.174095528 1 1  1.174095528
#> 121 320      1 1 -0.088512977  0.911487023  1.111487023 1 1  1.111487023
#> 122 322      1 1  0.295311208  1.295311208  1.495311208 1 0  1.295311208
#> 123 323      1 1 -0.373858268  0.626141732  0.826141732 1 0  0.626141732
#> 124 324      1 1  0.344402375  1.344402375  1.544402375 1 1  1.544402375
#> 125 325      1 1  0.080625130  1.080625130  1.280625130 1 1  1.280625130
#> 126 327      1 1 -0.420480699  0.579519301  0.779519301 1 1  0.779519301
#> 127 329      1 1 -0.065528790  0.934471210  1.134471210 1 0  0.934471210
#> 128 330      0 1 -0.355408336  0.644591664  0.844591664 1 0  0.644591664
#> 129 337      1 1  0.348752098  1.348752098  1.548752098 1 0  1.348752098
#> 130 339      0 1  0.802114799  1.802114799  2.002114799 1 0  1.802114799
#> 131 340      1 1  0.214709232  1.214709232  1.414709232 1 0  1.214709232
#> 132 343      1 1  0.123516542  1.123516542  1.323516542 1 0  1.123516542
#> 133 348      1 1  0.177905769  1.177905769  1.377905769 1 1  1.377905769
#> 134 349      0 1 -0.226189796  0.773810204  0.973810204 1 0  0.773810204
#> 135 352      0 1  0.254914563  1.254914563  1.454914563 1 1  1.454914563
#> 136 357      1 1  0.219878968  1.219878968  1.419878968 1 1  1.419878968
#> 137 359      0 1 -0.217274487  0.782725513  0.982725513 1 1  0.982725513
#> 138 360      0 1  0.063897195  1.063897195  1.263897195 1 1  1.263897195
#> 139 361      1 1 -0.155604632  0.844395368  1.044395368 1 1  1.044395368
#> 140 363      1 1  0.522092460  1.522092460  1.722092460 1 0  1.522092460
#> 141 365      0 1  0.462182937  1.462182937  1.662182937 1 1  1.662182937
#> 142 368      1 1 -0.182284498  0.817715502  1.017715502 1 1  1.017715502
#> 143 369      1 1 -0.007262023  0.992737977  1.192737977 1 0  0.992737977
#> 144 370      1 1 -0.378084781  0.621915219  0.821915219 1 0  0.621915219
#> 145 371      1 1 -0.097472486  0.902527514  1.102527514 1 1  1.102527514
#> 146 372      1 1  0.029283442  1.029283442  1.229283442 1 1  1.229283442
#> 147 374      1 1  0.113630761  1.113630761  1.313630761 1 1  1.313630761
#> 148 375      1 1  0.117549924  1.117549924  1.317549924 1 1  1.317549924
#> 149 376      1 1 -0.108800123  0.891199877  1.091199877 1 0  0.891199877
#> 150 378      1 1 -0.089510414  0.910489586  1.110489586 1 0  0.910489586
#> 151 379      0 1 -0.022366564  0.977633436  1.177633436 1 1  1.177633436
#> 152 380      0 1 -0.013718727  0.986281273  1.186281273 1 1  1.186281273
#> 153 381      0 1  0.044950358  1.044950358  1.244950358 1 0  1.044950358
#> 154 382      1 1 -0.072541396  0.927458604  1.127458604 1 0  0.927458604
#> 155 383      1 1  0.266584853  1.266584853  1.466584853 1 1  1.466584853
#> 156 384      0 1 -0.410995252  0.589004748  0.789004748 1 0  0.589004748
#> 157 386      1 1 -0.100336198  0.899663802  1.099663802 1 1  1.099663802
#> 158 388      1 1  0.107647345  1.107647345  1.307647345 1 0  1.107647345
#> 159 389      1 1 -0.191118720  0.808881280  1.008881280 1 1  1.008881280
#> 160 398      1 1 -0.088252092  0.911747908  1.111747908 1 1  1.111747908
#> 161 399      1 1  0.228924189  1.228924189  1.428924189 1 1  1.428924189
#> 162 402      0 1  0.091484675  1.091484675  1.291484675 1 1  1.291484675
#> 163 404      1 1  0.104674353  1.104674353  1.304674353 1 1  1.304674353
#> 164 407      1 1 -0.148037522  0.851962478  1.051962478 1 0  0.851962478
#> 165 409      1 1  0.128628920  1.128628920  1.328628920 1 1  1.328628920
#> 166 410      1 1  0.044772815  1.044772815  1.244772815 1 1  1.244772815
#> 167 416      1 1  0.284272578  1.284272578  1.484272578 1 1  1.484272578
#> 168 417      0 1 -0.071230379  0.928769621  1.128769621 1 1  1.128769621
#> 169 418      1 1 -0.392666836  0.607333164  0.807333164 1 1  0.807333164
#> 170 419      1 1 -0.077320762  0.922679238  1.122679238 1 0  0.922679238
#> 171 427      1 1 -0.186389955  0.813610045  1.013610045 1 1  1.013610045
#> 172 428      0 1  0.298598646  1.298598646  1.498598646 1 0  1.298598646
#> 173 429      1 1 -0.447442309  0.552557691  0.752557691 1 0  0.552557691
#> 174 434      0 1  0.013670679  1.013670679  1.213670679 1 1  1.213670679
#> 175 441      0 1 -0.334447267  0.665552733  0.865552733 1 0  0.665552733
#> 176 443      1 1  0.275227849  1.275227849  1.475227849 1 1  1.475227849
#> 177 444      1 1  0.184667521  1.184667521  1.384667521 1 0  1.184667521
#> 178 446      0 1 -0.804189930  0.195810070  0.395810070 1 0  0.195810070
#> 179 447      0 1  0.084371395  1.084371395  1.284371395 1 1  1.284371395
#> 180 452      1 1 -0.685242321  0.314757679  0.514757679 1 1  0.514757679
#> 181 453      0 1 -0.214819259  0.785180741  0.985180741 1 1  0.985180741
#> 182 454      0 1  0.237461514  1.237461514  1.437461514 1 1  1.437461514
#> 183 457      1 1 -0.009345136  0.990654864  1.190654864 1 0  0.990654864
#> 184 458      1 1 -0.222411044  0.777588956  0.977588956 1 1  0.977588956
#> 185 461      1 1  0.183847586  1.183847586  1.383847586 1 0  1.183847586
#> 186 464      0 1 -0.291251800  0.708748200  0.908748200 1 1  0.908748200
#> 187 465      1 1  0.290636602  1.290636602  1.490636602 1 0  1.290636602
#> 188 466      1 1 -0.076736671  0.923263329  1.123263329 1 0  0.923263329
#> 189 467      0 1 -0.010250540  0.989749460  1.189749460 1 0  0.989749460
#> 190 470      0 1 -0.144326399  0.855673601  1.055673601 1 0  0.855673601
#> 191 471      1 1 -0.037118876  0.962881124  1.162881124 1 0  0.962881124
#> 192 477      1 1 -0.116227059  0.883772941  1.083772941 1 0  0.883772941
#> 193 478      0 1 -0.359779206  0.640220794  0.840220794 1 1  0.840220794
#> 194 482      0 1 -0.005264136  0.994735864  1.194735864 1 1  1.194735864
#> 195 483      0 1 -0.013593800  0.986406200  1.186406200 1 0  0.986406200
#> 196 485      1 1  0.062635383  1.062635383  1.262635383 1 1  1.262635383
#> 197 489      0 1  0.268376067  1.268376067  1.468376067 1 0  1.268376067
#> 198 493      1 1  0.124730950  1.124730950  1.324730950 1 1  1.324730950
#> 199 494      1 1  0.101322387  1.101322387  1.301322387 1 0  1.101322387
#> 200 497      1 1  0.208214183  1.208214183  1.408214183 1 1  1.408214183

# Apply get_estimates
get_estimates(design, data = dat)
#>   estimator term   estimate  std.error statistic   p.value    conf.low
#> 1 estimator    Z 0.05570193 0.07484884 0.7441923 0.4576424 -0.09190129
#>   conf.high  df outcome inquiry
#> 1 0.2033051 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
#>   237  263
#>  0.47 0.53
#> 
#> Added variable: X 
#>     0    1
#>   250  250
#>  0.50 0.50
#> 
#> Added variable: U 
#>   min median mean  max   sd N_missing N_unique
#>  -0.7      0    0 0.75 0.25         0      500
#> 
#> Added variable: Y_Z_0 
#>   min median mean  max   sd N_missing N_unique
#>  -0.7   0.46  0.5 1.66 0.55         0      500
#> 
#> Added variable: Y_Z_1 
#>   min median mean  max   sd N_missing N_unique
#>  -0.5   0.66  0.7 1.86 0.55         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
#>   237  263
#>  0.47 0.53
#> 
#>   After:
#>     0    1
#>    95  105
#>  0.47 0.53
#> 
#> Altered variable: X 
#>   Before: 
#>     0    1
#>   250  250
#>  0.50 0.50
#> 
#>   After:
#>     0    1
#>   100  100
#>  0.50 0.50
#> 
#> Altered variable: U 
#>   Before: 
#>   min median mean  max   sd N_missing N_unique
#>  -0.7      0    0 0.75 0.25         0      500
#> 
#>   After:
#>   min median  mean  max   sd N_missing N_unique
#>  -0.7  -0.02 -0.01 0.59 0.25         0      200
#> 
#> Altered variable: Y_Z_0 
#>   Before: 
#>   min median mean  max   sd N_missing N_unique
#>  -0.7   0.46  0.5 1.66 0.55         0      500
#> 
#>   After:
#>   min median mean  max   sd N_missing N_unique
#>  -0.7    0.5 0.49 1.53 0.54         0      200
#> 
#> Altered variable: Y_Z_1 
#>   Before: 
#>   min median mean  max   sd N_missing N_unique
#>  -0.5   0.66  0.7 1.86 0.55         0      500
#> 
#>   After:
#>   min median mean  max   sd N_missing N_unique
#>  -0.5    0.7 0.69 1.73 0.54         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.69    0.6 0.59 1.57 0.55         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.187191 0.07652242  2.446224 0.01530916 0.03628743 0.3380945
#>   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
#>  -3.85  -0.11 -0.04 3.08 0.98         0      500
#> 
#> Added variable: Y_Z_0 
#>    min median  mean  max   sd N_missing N_unique
#>  -3.85  -0.11 -0.04 3.08 0.98         0      500
#> 
#> Added variable: Y_Z_1 
#>    min median mean  max   sd N_missing N_unique
#>  -4.26   1.93    2 7.81 2.21         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.040887
#> 
#> 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
#>  -3.85  -0.11 -0.04 3.08 0.98         0      500
#> 
#>   After:
#>    min median  mean  max   sd N_missing N_unique
#>  -2.43   0.03 -0.01 2.79 0.98         0      250
#> 
#> Altered variable: Y_Z_0 
#>   Before: 
#>    min median  mean  max   sd N_missing N_unique
#>  -3.85  -0.11 -0.04 3.08 0.98         0      500
#> 
#>   After:
#>    min median  mean  max   sd N_missing N_unique
#>  -2.43   0.03 -0.01 2.79 0.98         0      250
#> 
#> Altered variable: Y_Z_1 
#>   Before: 
#>    min median mean  max   sd N_missing N_unique
#>  -4.26   1.93    2 7.81 2.21         0      500
#> 
#>   After:
#>    min median mean  max   sd N_missing N_unique
#>  -2.87   1.98 2.09 7.81 2.18         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.46   0.16 0.27 7.81 1.41         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.829667  0.420559  6.728346 1.179393e-10 2.001344  3.657989
#>   df outcome inquiry
#>  248       Y     ATE
#>