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.035540982 -0.035540982 0.164459018 1 1 0.164459018
#> 2 005 0 0 -0.040743995 -0.040743995 0.159256005 1 1 0.159256005
#> 3 013 1 0 -0.267478419 -0.267478419 -0.067478419 1 0 -0.267478419
#> 4 017 0 0 -0.380339098 -0.380339098 -0.180339098 1 1 -0.180339098
#> 5 018 1 0 -0.231951976 -0.231951976 -0.031951976 1 1 -0.031951976
#> 6 020 0 0 -0.026185608 -0.026185608 0.173814392 1 1 0.173814392
#> 7 024 1 0 0.168391361 0.168391361 0.368391361 1 0 0.168391361
#> 8 025 0 0 0.168127331 0.168127331 0.368127331 1 0 0.168127331
#> 9 029 1 0 -0.078741213 -0.078741213 0.121258787 1 1 0.121258787
#> 10 036 1 0 0.130206691 0.130206691 0.330206691 1 1 0.330206691
#> 11 038 1 0 -0.133633979 -0.133633979 0.066366021 1 1 0.066366021
#> 12 042 0 0 -0.011210487 -0.011210487 0.188789513 1 0 -0.011210487
#> 13 046 0 0 -0.080949302 -0.080949302 0.119050698 1 1 0.119050698
#> 14 048 0 0 0.007191852 0.007191852 0.207191852 1 1 0.207191852
#> 15 050 1 0 -0.202109272 -0.202109272 -0.002109272 1 1 -0.002109272
#> 16 054 0 0 0.199341017 0.199341017 0.399341017 1 1 0.399341017
#> 17 056 1 0 -0.074037665 -0.074037665 0.125962335 1 0 -0.074037665
#> 18 059 1 0 -0.104368122 -0.104368122 0.095631878 1 1 0.095631878
#> 19 060 1 0 -0.109447945 -0.109447945 0.090552055 1 1 0.090552055
#> 20 061 1 0 0.208332241 0.208332241 0.408332241 1 0 0.208332241
#> 21 062 0 0 0.040745020 0.040745020 0.240745020 1 1 0.240745020
#> 22 063 1 0 0.194621181 0.194621181 0.394621181 1 0 0.194621181
#> 23 065 1 0 -0.236654365 -0.236654365 -0.036654365 1 1 -0.036654365
#> 24 066 0 0 0.168439690 0.168439690 0.368439690 1 1 0.368439690
#> 25 069 0 0 -0.005639019 -0.005639019 0.194360981 1 0 -0.005639019
#> 26 074 0 0 0.074997238 0.074997238 0.274997238 1 1 0.274997238
#> 27 078 1 0 -0.198934552 -0.198934552 0.001065448 1 0 -0.198934552
#> 28 079 1 0 -0.322042100 -0.322042100 -0.122042100 1 1 -0.122042100
#> 29 080 0 0 0.258175828 0.258175828 0.458175828 1 0 0.258175828
#> 30 081 1 0 0.161219012 0.161219012 0.361219012 1 1 0.361219012
#> 31 085 1 0 -0.414383264 -0.414383264 -0.214383264 1 0 -0.414383264
#> 32 086 1 0 -0.068792834 -0.068792834 0.131207166 1 0 -0.068792834
#> 33 088 0 0 -0.442535005 -0.442535005 -0.242535005 1 1 -0.242535005
#> 34 089 0 0 -0.112613847 -0.112613847 0.087386153 1 0 -0.112613847
#> 35 090 1 0 0.218326861 0.218326861 0.418326861 1 1 0.418326861
#> 36 092 1 0 -0.009247993 -0.009247993 0.190752007 1 1 0.190752007
#> 37 094 1 0 0.109479935 0.109479935 0.309479935 1 1 0.309479935
#> 38 095 0 0 0.056522115 0.056522115 0.256522115 1 0 0.056522115
#> 39 097 1 0 -0.106931812 -0.106931812 0.093068188 1 0 -0.106931812
#> 40 098 1 0 -0.398932921 -0.398932921 -0.198932921 1 1 -0.198932921
#> 41 100 0 0 -0.096924794 -0.096924794 0.103075206 1 1 0.103075206
#> 42 102 0 0 0.486742390 0.486742390 0.686742390 1 1 0.686742390
#> 43 103 0 0 -0.356188169 -0.356188169 -0.156188169 1 0 -0.356188169
#> 44 104 1 0 0.054920561 0.054920561 0.254920561 1 0 0.054920561
#> 45 105 1 0 0.171114947 0.171114947 0.371114947 1 0 0.171114947
#> 46 109 0 0 -0.114750906 -0.114750906 0.085249094 1 1 0.085249094
#> 47 110 0 0 0.014135975 0.014135975 0.214135975 1 1 0.214135975
#> 48 118 1 0 -0.364950949 -0.364950949 -0.164950949 1 0 -0.364950949
#> 49 119 0 0 -0.147650285 -0.147650285 0.052349715 1 1 0.052349715
#> 50 126 1 0 -0.238918827 -0.238918827 -0.038918827 1 1 -0.038918827
#> 51 128 1 0 0.245027794 0.245027794 0.445027794 1 1 0.445027794
#> 52 133 1 0 0.436195809 0.436195809 0.636195809 1 1 0.636195809
#> 53 134 1 0 -0.096465257 -0.096465257 0.103534743 1 1 0.103534743
#> 54 137 0 0 -0.462666965 -0.462666965 -0.262666965 1 0 -0.462666965
#> 55 139 0 0 0.066514133 0.066514133 0.266514133 1 0 0.066514133
#> 56 143 1 0 0.107158157 0.107158157 0.307158157 1 0 0.107158157
#> 57 144 0 0 -0.176548806 -0.176548806 0.023451194 1 0 -0.176548806
#> 58 146 1 0 -0.007097837 -0.007097837 0.192902163 1 1 0.192902163
#> 59 148 1 0 -0.624781883 -0.624781883 -0.424781883 1 0 -0.624781883
#> 60 149 1 0 0.328649226 0.328649226 0.528649226 1 0 0.328649226
#> 61 150 1 0 -0.081502244 -0.081502244 0.118497756 1 0 -0.081502244
#> 62 152 0 0 0.252666080 0.252666080 0.452666080 1 0 0.252666080
#> 63 153 0 0 -0.523880747 -0.523880747 -0.323880747 1 0 -0.523880747
#> 64 154 0 0 -0.054764353 -0.054764353 0.145235647 1 0 -0.054764353
#> 65 156 0 0 -0.223516858 -0.223516858 -0.023516858 1 1 -0.023516858
#> 66 158 1 0 -0.229085331 -0.229085331 -0.029085331 1 1 -0.029085331
#> 67 160 0 0 0.484904228 0.484904228 0.684904228 1 0 0.484904228
#> 68 162 0 0 0.117543376 0.117543376 0.317543376 1 1 0.317543376
#> 69 163 0 0 -0.279491090 -0.279491090 -0.079491090 1 0 -0.279491090
#> 70 168 0 0 -0.423143814 -0.423143814 -0.223143814 1 0 -0.423143814
#> 71 172 0 0 0.226501446 0.226501446 0.426501446 1 0 0.226501446
#> 72 175 0 0 -0.026728769 -0.026728769 0.173271231 1 1 0.173271231
#> 73 176 1 0 0.169806110 0.169806110 0.369806110 1 1 0.369806110
#> 74 177 0 0 -0.053604654 -0.053604654 0.146395346 1 0 -0.053604654
#> 75 179 0 0 -0.092802847 -0.092802847 0.107197153 1 1 0.107197153
#> 76 186 1 0 0.111338084 0.111338084 0.311338084 1 1 0.311338084
#> 77 187 0 0 -0.107007043 -0.107007043 0.092992957 1 0 -0.107007043
#> 78 189 1 0 0.065771209 0.065771209 0.265771209 1 1 0.265771209
#> 79 190 1 0 0.250706830 0.250706830 0.450706830 1 1 0.450706830
#> 80 193 1 0 -0.002604236 -0.002604236 0.197395764 1 1 0.197395764
#> 81 194 0 0 0.108041522 0.108041522 0.308041522 1 0 0.108041522
#> 82 196 0 0 0.376967915 0.376967915 0.576967915 1 0 0.376967915
#> 83 201 1 0 0.036848253 0.036848253 0.236848253 1 0 0.036848253
#> 84 202 0 0 0.303246130 0.303246130 0.503246130 1 0 0.303246130
#> 85 203 1 0 -0.376375468 -0.376375468 -0.176375468 1 0 -0.376375468
#> 86 205 1 0 -0.111211282 -0.111211282 0.088788718 1 0 -0.111211282
#> 87 207 1 0 0.324769205 0.324769205 0.524769205 1 0 0.324769205
#> 88 208 0 0 0.186462074 0.186462074 0.386462074 1 1 0.386462074
#> 89 210 0 0 -0.096467608 -0.096467608 0.103532392 1 1 0.103532392
#> 90 212 0 0 -0.039496265 -0.039496265 0.160503735 1 1 0.160503735
#> 91 213 0 0 0.116641488 0.116641488 0.316641488 1 0 0.116641488
#> 92 214 1 0 -0.295772913 -0.295772913 -0.095772913 1 1 -0.095772913
#> 93 216 0 0 -0.497124831 -0.497124831 -0.297124831 1 1 -0.297124831
#> 94 222 0 0 -0.073949646 -0.073949646 0.126050354 1 1 0.126050354
#> 95 223 0 0 0.090291939 0.090291939 0.290291939 1 0 0.090291939
#> 96 226 0 0 -0.129518713 -0.129518713 0.070481287 1 1 0.070481287
#> 97 227 0 0 0.302257818 0.302257818 0.502257818 1 1 0.502257818
#> 98 230 1 0 -0.304967004 -0.304967004 -0.104967004 1 1 -0.104967004
#> 99 234 0 0 0.173947868 0.173947868 0.373947868 1 0 0.173947868
#> 100 235 1 0 -0.364877829 -0.364877829 -0.164877829 1 1 -0.164877829
#> 101 236 1 0 -0.241318533 -0.241318533 -0.041318533 1 0 -0.241318533
#> 102 240 1 0 0.200259293 0.200259293 0.400259293 1 0 0.200259293
#> 103 247 1 0 -0.195956906 -0.195956906 0.004043094 1 1 0.004043094
#> 104 249 0 0 0.193768807 0.193768807 0.393768807 1 1 0.393768807
#> 105 250 0 0 0.043580301 0.043580301 0.243580301 1 0 0.043580301
#> 106 253 0 1 0.185631185 1.185631185 1.385631185 1 0 1.185631185
#> 107 255 0 1 0.137932656 1.137932656 1.337932656 1 0 1.137932656
#> 108 257 1 1 0.238735005 1.238735005 1.438735005 1 0 1.238735005
#> 109 261 0 1 -0.247058229 0.752941771 0.952941771 1 0 0.752941771
#> 110 262 1 1 0.147264042 1.147264042 1.347264042 1 1 1.347264042
#> 111 263 0 1 0.123360764 1.123360764 1.323360764 1 0 1.123360764
#> 112 265 1 1 -0.373182052 0.626817948 0.826817948 1 0 0.626817948
#> 113 269 1 1 -0.272512770 0.727487230 0.927487230 1 0 0.727487230
#> 114 270 0 1 0.256727861 1.256727861 1.456727861 1 0 1.256727861
#> 115 271 1 1 0.190649401 1.190649401 1.390649401 1 1 1.390649401
#> 116 272 0 1 -0.293593303 0.706406697 0.906406697 1 0 0.706406697
#> 117 279 1 1 0.289149551 1.289149551 1.489149551 1 1 1.489149551
#> 118 280 0 1 -0.141066063 0.858933937 1.058933937 1 0 0.858933937
#> 119 282 1 1 -0.078837209 0.921162791 1.121162791 1 0 0.921162791
#> 120 283 0 1 0.099488509 1.099488509 1.299488509 1 0 1.099488509
#> 121 285 0 1 0.234219376 1.234219376 1.434219376 1 0 1.234219376
#> 122 286 1 1 -0.271948773 0.728051227 0.928051227 1 0 0.728051227
#> 123 288 1 1 -0.110151739 0.889848261 1.089848261 1 0 0.889848261
#> 124 291 1 1 -0.098217524 0.901782476 1.101782476 1 1 1.101782476
#> 125 293 0 1 0.334025910 1.334025910 1.534025910 1 0 1.334025910
#> 126 295 1 1 0.111398001 1.111398001 1.311398001 1 1 1.311398001
#> 127 296 1 1 -0.249557874 0.750442126 0.950442126 1 1 0.950442126
#> 128 300 1 1 0.825186228 1.825186228 2.025186228 1 1 2.025186228
#> 129 302 1 1 0.426495523 1.426495523 1.626495523 1 0 1.426495523
#> 130 305 0 1 0.026029229 1.026029229 1.226029229 1 0 1.026029229
#> 131 313 0 1 0.246726833 1.246726833 1.446726833 1 1 1.446726833
#> 132 316 1 1 0.082116869 1.082116869 1.282116869 1 0 1.082116869
#> 133 320 0 1 -0.427016393 0.572983607 0.772983607 1 0 0.572983607
#> 134 321 1 1 -0.134838817 0.865161183 1.065161183 1 0 0.865161183
#> 135 325 0 1 0.275573831 1.275573831 1.475573831 1 1 1.475573831
#> 136 326 0 1 -0.307418931 0.692581069 0.892581069 1 1 0.892581069
#> 137 327 0 1 0.267825066 1.267825066 1.467825066 1 0 1.267825066
#> 138 332 1 1 0.270378845 1.270378845 1.470378845 1 0 1.270378845
#> 139 335 1 1 0.061134501 1.061134501 1.261134501 1 0 1.061134501
#> 140 336 1 1 0.058597149 1.058597149 1.258597149 1 0 1.058597149
#> 141 345 0 1 0.312730837 1.312730837 1.512730837 1 1 1.512730837
#> 142 347 0 1 0.155072433 1.155072433 1.355072433 1 0 1.155072433
#> 143 349 1 1 -0.077880873 0.922119127 1.122119127 1 1 1.122119127
#> 144 351 0 1 0.091023461 1.091023461 1.291023461 1 1 1.291023461
#> 145 352 0 1 0.044105635 1.044105635 1.244105635 1 1 1.244105635
#> 146 353 0 1 -0.089001914 0.910998086 1.110998086 1 1 1.110998086
#> 147 357 0 1 0.019351872 1.019351872 1.219351872 1 1 1.219351872
#> 148 360 1 1 -0.272669922 0.727330078 0.927330078 1 1 0.927330078
#> 149 361 0 1 0.264651833 1.264651833 1.464651833 1 0 1.264651833
#> 150 367 0 1 -0.021311982 0.978688018 1.178688018 1 0 0.978688018
#> 151 369 1 1 -0.073838783 0.926161217 1.126161217 1 0 0.926161217
#> 152 375 0 1 0.154233333 1.154233333 1.354233333 1 1 1.354233333
#> 153 376 1 1 0.066056317 1.066056317 1.266056317 1 0 1.066056317
#> 154 380 0 1 -0.210735625 0.789264375 0.989264375 1 0 0.789264375
#> 155 382 1 1 0.661744630 1.661744630 1.861744630 1 1 1.861744630
#> 156 388 1 1 0.199478058 1.199478058 1.399478058 1 0 1.199478058
#> 157 390 1 1 -0.161388702 0.838611298 1.038611298 1 1 1.038611298
#> 158 391 0 1 0.093368239 1.093368239 1.293368239 1 1 1.293368239
#> 159 396 1 1 -0.034596872 0.965403128 1.165403128 1 1 1.165403128
#> 160 402 1 1 0.273754514 1.273754514 1.473754514 1 0 1.273754514
#> 161 403 1 1 -0.276768124 0.723231876 0.923231876 1 1 0.923231876
#> 162 405 1 1 -0.099970195 0.900029805 1.100029805 1 0 0.900029805
#> 163 407 0 1 -0.036263383 0.963736617 1.163736617 1 1 1.163736617
#> 164 408 0 1 0.027439922 1.027439922 1.227439922 1 1 1.227439922
#> 165 414 0 1 0.189571159 1.189571159 1.389571159 1 0 1.189571159
#> 166 415 1 1 0.008293403 1.008293403 1.208293403 1 1 1.208293403
#> 167 416 1 1 0.227398890 1.227398890 1.427398890 1 1 1.427398890
#> 168 417 1 1 -0.463742802 0.536257198 0.736257198 1 0 0.536257198
#> 169 420 0 1 -0.016597096 0.983402904 1.183402904 1 1 1.183402904
#> 170 423 1 1 0.513626924 1.513626924 1.713626924 1 0 1.513626924
#> 171 427 1 1 -0.223924285 0.776075715 0.976075715 1 0 0.776075715
#> 172 432 0 1 0.463381477 1.463381477 1.663381477 1 1 1.663381477
#> 173 433 1 1 -0.250567258 0.749432742 0.949432742 1 1 0.949432742
#> 174 434 1 1 -0.229476685 0.770523315 0.970523315 1 1 0.970523315
#> 175 435 0 1 0.601435867 1.601435867 1.801435867 1 0 1.601435867
#> 176 438 1 1 -0.344237066 0.655762934 0.855762934 1 0 0.655762934
#> 177 439 1 1 0.559467791 1.559467791 1.759467791 1 1 1.759467791
#> 178 441 0 1 0.513095750 1.513095750 1.713095750 1 1 1.713095750
#> 179 443 0 1 0.034384527 1.034384527 1.234384527 1 1 1.234384527
#> 180 445 1 1 -0.084501452 0.915498548 1.115498548 1 1 1.115498548
#> 181 446 0 1 -0.024997747 0.975002253 1.175002253 1 0 0.975002253
#> 182 448 1 1 -0.137692707 0.862307293 1.062307293 1 1 1.062307293
#> 183 455 1 1 0.467432845 1.467432845 1.667432845 1 1 1.667432845
#> 184 458 1 1 -0.231270122 0.768729878 0.968729878 1 0 0.768729878
#> 185 463 0 1 0.183890362 1.183890362 1.383890362 1 0 1.183890362
#> 186 467 0 1 -0.048691656 0.951308344 1.151308344 1 0 0.951308344
#> 187 472 1 1 0.225677244 1.225677244 1.425677244 1 0 1.225677244
#> 188 474 1 1 -0.136867141 0.863132859 1.063132859 1 0 0.863132859
#> 189 475 1 1 0.141380993 1.141380993 1.341380993 1 0 1.141380993
#> 190 479 1 1 -0.494876901 0.505123099 0.705123099 1 1 0.705123099
#> 191 484 0 1 -0.025197510 0.974802490 1.174802490 1 1 1.174802490
#> 192 485 1 1 -0.404826950 0.595173050 0.795173050 1 0 0.595173050
#> 193 488 0 1 -0.479031130 0.520968870 0.720968870 1 1 0.720968870
#> 194 490 0 1 0.395197808 1.395197808 1.595197808 1 0 1.395197808
#> 195 491 0 1 -0.043068902 0.956931098 1.156931098 1 1 1.156931098
#> 196 492 1 1 -0.317574983 0.682425017 0.882425017 1 0 0.682425017
#> 197 494 1 1 0.205320153 1.205320153 1.405320153 1 0 1.205320153
#> 198 496 1 1 0.110620318 1.110620318 1.310620318 1 1 1.310620318
#> 199 497 0 1 0.123112994 1.123112994 1.323112994 1 1 1.323112994
#> 200 498 0 1 -0.083191043 0.916808957 1.116808957 1 0 0.916808957
# Apply get_estimates
get_estimates(design, data = dat)
#> estimator term estimate std.error statistic p.value conf.low conf.high
#> 1 estimator Z 0.1810979 0.08397746 2.156505 0.03224976 0.01549283 0.3467029
#> df outcome inquiry
#> 1 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
#> 261 239
#> 0.52 0.48
#>
#> Added variable: X
#> 0 1
#> 250 250
#> 0.50 0.50
#>
#> Added variable: U
#> min median mean max sd N_missing N_unique
#> -0.68 0.02 0.02 0.72 0.25 0 500
#>
#> Added variable: Y_Z_0
#> min median mean max sd N_missing N_unique
#> -0.68 0.51 0.52 1.71 0.55 0 500
#>
#> Added variable: Y_Z_1
#> min median mean max sd N_missing N_unique
#> -0.48 0.71 0.72 1.91 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
#> 261 239
#> 0.52 0.48
#>
#> After:
#> 0 1
#> 97 103
#> 0.48 0.52
#>
#> Altered variable: X
#> Before:
#> 0 1
#> 250 250
#> 0.50 0.50
#>
#> After:
#> 0 1
#> 102 98
#> 0.51 0.49
#>
#> Altered variable: U
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.68 0.02 0.02 0.72 0.25 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.6 0.01 0.02 0.72 0.24 0 200
#>
#> Altered variable: Y_Z_0
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.68 0.51 0.52 1.71 0.55 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.6 0.48 0.51 1.71 0.55 0 200
#>
#> Altered variable: Y_Z_1
#> Before:
#> min median mean max sd N_missing N_unique
#> -0.48 0.71 0.72 1.91 0.55 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -0.4 0.68 0.71 1.91 0.55 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.51 0.64 0.61 1.91 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.1258775 0.07794153 1.615025 0.1078977 -0.02782454 0.2795796
#> 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.42 -0.09 -0.03 3.61 1.02 0 500
#>
#> Added variable: Y_Z_0
#> min median mean max sd N_missing N_unique
#> -3.42 -0.09 -0.03 3.61 1.02 0 500
#>
#> Added variable: Y_Z_1
#> min median mean max sd N_missing N_unique
#> -4.5 1.95 2 8.41 2.3 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.028576
#>
#> 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.42 -0.09 -0.03 3.61 1.02 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -2.7 -0.04 0 3.61 0.97 0 250
#>
#> Altered variable: Y_Z_0
#> Before:
#> min median mean max sd N_missing N_unique
#> -3.42 -0.09 -0.03 3.61 1.02 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -2.7 -0.04 0 3.61 0.97 0 250
#>
#> Altered variable: Y_Z_1
#> Before:
#> min median mean max sd N_missing N_unique
#> -4.5 1.95 2 8.41 2.3 0 500
#>
#> After:
#> min median mean max sd N_missing N_unique
#> -3.04 2 2.04 8.41 2.24 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.7 0.06 0.21 5.99 1.32 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.099025 0.4569331 4.593725 6.932089e-06 1.199061 2.998989
#> df outcome inquiry
#> 248 Y ATE
#>