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.120003505 -0.120003505  0.87999649 1 0 -0.12000351
#> 2  002  1.395008391  1.395008391  2.39500839 1 0  1.39500839
#> 3  003 -0.499316907 -0.499316907  0.50068309 1 1  0.50068309
#> 4  004  3.208459197  3.208459197  4.20845920 1 1  4.20845920
#> 5  007 -0.556071372 -0.556071372  0.44392863 1 1  0.44392863
#> 6  008  0.494066167  0.494066167  1.49406617 1 1  1.49406617
#> 7  009  0.287289687  0.287289687  1.28728969 1 0  0.28728969
#> 8  010  0.032472018  0.032472018  1.03247202 1 0  0.03247202
#> 9  012 -0.581642588 -0.581642588  0.41835741 1 1  0.41835741
#> 10 013  0.711623077  0.711623077  1.71162308 1 1  1.71162308
#> 11 014 -0.904759184 -0.904759184  0.09524082 1 1  0.09524082
#> 12 015 -0.257546579 -0.257546579  0.74245342 1 1  0.74245342
#> 13 016 -1.476130766 -1.476130766 -0.47613077 1 0 -1.47613077
#> 14 017  1.019658251  1.019658251  2.01965825 1 1  2.01965825
#> 15 019  0.588553405  0.588553405  1.58855341 1 0  0.58855341
#> 16 020  0.975705502  0.975705502  1.97570550 1 0  0.97570550
#> 17 022  0.879515871  0.879515871  1.87951587 1 0  0.87951587
#> 18 025  0.255588781  0.255588781  1.25558878 1 1  1.25558878
#> 19 026 -0.622418529 -0.622418529  0.37758147 1 1  0.37758147
#> 20 027  0.352437504  0.352437504  1.35243750 1 0  0.35243750
#> 21 028  2.088369839  2.088369839  3.08836984 1 1  3.08836984
#> 22 029  0.129024612  0.129024612  1.12902461 1 1  1.12902461
#> 23 031 -0.016523057 -0.016523057  0.98347694 1 1  0.98347694
#> 24 032  1.034356278  1.034356278  2.03435628 1 0  1.03435628
#> 25 033 -0.729137994 -0.729137994  0.27086201 1 1  0.27086201
#> 26 034 -0.029048094 -0.029048094  0.97095191 1 0 -0.02904809
#> 27 036 -0.389889943 -0.389889943  0.61011006 1 1  0.61011006
#> 28 037  0.117133769  0.117133769  1.11713377 1 1  1.11713377
#> 29 038 -0.487347576 -0.487347576  0.51265242 1 1  0.51265242
#> 30 039  0.454523043  0.454523043  1.45452304 1 1  1.45452304
#> 31 040  0.470199698  0.470199698  1.47019970 1 1  1.47019970
#> 32 041 -0.435200491 -0.435200491  0.56479951 1 0 -0.43520049
#> 33 042  1.224618991  1.224618991  2.22461899 1 1  2.22461899
#> 34 043 -0.358041654 -0.358041654  0.64195835 1 0 -0.35804165
#> 35 044 -0.089466258 -0.089466258  0.91053374 1 1  0.91053374
#> 36 045 -0.054874909 -0.054874909  0.94512509 1 1  0.94512509
#> 37 046  0.179801431  0.179801431  1.17980143 1 1  1.17980143
#> 38 047 -0.290165586 -0.290165586  0.70983441 1 1  0.70983441
#> 39 048  1.066339413  1.066339413  2.06633941 1 1  2.06633941
#> 40 049 -1.643981009 -1.643981009 -0.64398101 1 1 -0.64398101
#> 41 050  0.930799162  0.930799162  1.93079916 1 1  1.93079916
#> 42 055 -1.057700644 -1.057700644 -0.05770064 1 1 -0.05770064
#> 43 056  0.410267318  0.410267318  1.41026732 1 1  1.41026732
#> 44 057  0.049820897  0.049820897  1.04982090 1 1  1.04982090
#> 45 058 -1.293853009 -1.293853009 -0.29385301 1 1 -0.29385301
#> 46 059 -0.002055775 -0.002055775  0.99794422 1 1  0.99794422
#> 47 060 -1.075758967 -1.075758967 -0.07575897 1 0 -1.07575897
#> 48 061 -0.767654899 -0.767654899  0.23234510 1 1  0.23234510
#> 49 065  1.454138213  1.454138213  2.45413821 1 1  2.45413821
#> 50 066  1.263068966  1.263068966  2.26306897 1 0  1.26306897
#> 51 067  0.365938700  0.365938700  1.36593870 1 1  1.36593870
#> 52 068 -0.246704524 -0.246704524  0.75329548 1 0 -0.24670452
#> 53 069  0.418697410  0.418697410  1.41869741 1 1  1.41869741
#> 54 070  0.714488065  0.714488065  1.71448807 1 0  0.71448807
#> 55 071  0.504745012  0.504745012  1.50474501 1 1  1.50474501
#> 56 072 -0.592150088 -0.592150088  0.40784991 1 1  0.40784991
#> 57 074  0.514515680  0.514515680  1.51451568 1 0  0.51451568
#> 58 075  0.179091258  0.179091258  1.17909126 1 1  1.17909126
#> 59 076  0.532944188  0.532944188  1.53294419 1 0  0.53294419
#> 60 077  0.761457683  0.761457683  1.76145768 1 1  1.76145768
#> 61 078 -0.091102004 -0.091102004  0.90889800 1 0 -0.09110200
#> 62 079  0.674661541  0.674661541  1.67466154 1 0  0.67466154
#> 63 080  1.854759926  1.854759926  2.85475993 1 0  1.85475993
#> 64 082 -0.284921515 -0.284921515  0.71507849 1 0 -0.28492151
#> 65 083 -1.570667343 -1.570667343 -0.57066734 1 1 -0.57066734
#> 66 084 -0.309283049 -0.309283049  0.69071695 1 1  0.69071695
#> 67 085  0.489510274  0.489510274  1.48951027 1 1  1.48951027
#> 68 086 -0.475816241 -0.475816241  0.52418376 1 1  0.52418376
#> 69 087  0.098768642  0.098768642  1.09876864 1 1  1.09876864
#> 70 090 -0.396678429 -0.396678429  0.60332157 1 0 -0.39667843
#> 71 092 -0.745559818 -0.745559818  0.25444018 1 1  0.25444018
#> 72 096 -3.493515322 -3.493515322 -2.49351532 1 1 -2.49351532
#> 73 097 -0.374073821 -0.374073821  0.62592618 1 1  0.62592618
#> 74 098 -0.474357385 -0.474357385  0.52564262 1 1  0.52564262
#> 75 099  0.054682715  0.054682715  1.05468271 1 0  0.05468271

get_estimates(design, data = dat)
#>   estimator term estimate std.error statistic      p.value  conf.low conf.high
#> 1 estimator    Z 1.108226 0.2077582  5.334209 1.031719e-06 0.6941642  1.522287
#>   df outcome inquiry
#> 1 73       Y     ATE