Run Gibbs sampler without covariates
Usage
prepost_gibbs_nocovar(
formula,
data,
prepost,
moderator,
iter = 1000,
thin = 1,
burn = 0,
monotonicity = TRUE,
stable = TRUE,
priors,
predictive = FALSE
)
Arguments
- formula
A formula with syntax
y ~ t
, wherey
is the name of the outcome variable andt
is the name of the treatment.- data
A data frame containin the variables in the formula.
- prepost
A one-sided formula with syntax ~ z, where z is the indicator variable for whether the moderator was measured pre- or post-treatment.
- moderator
A formuala with syntax ~ d, where d is the moderator variable for the CATE.
- iter
Numeric, number of iterations for the Gibbs
- thin
Numeric, thinning parameter for the Gibbs
- burn
Numeric, burn in rate for the Gibbs
- monotonicity
A logical signifying whether Gibbs assumes monotonicity.
- stable
A logical signifying whether Gibbs assumes stability.
- priors
A list object containing the priors for the Gibbs sampler. Priors include beta.precision, psi.precision, alpha, y.alpha, and y.beta.
- predictive
A logical indicator for whether to return prior predictive draws (
TRUE
) or posterior draws (FALSE
, default).
Examples
data(land_experiment)
prepost_gibbs_nocovar(
support ~ treat_comb,
data = land_experiment,
moderator = ~ land_insecure,
prepost = ~ prepost,
iter = 50
)
#> $mu
#> 0_0_s111 1_0_s111 0_1_s111 1_1_s111 0_0_s100 1_0_s100
#> [1,] 0.43986822 0.9418856 0.3759009 0.9740708065 2.095683e-01 9.945370e-01
#> [2,] 0.24280692 0.6861317 0.3097660 0.4006188790 3.702659e-01 9.999430e-01
#> [3,] 0.08322491 0.8269939 0.3455480 0.0006465626 2.802050e-01 9.998181e-01
#> [4,] 0.61392198 0.8008764 0.3314226 0.0846494984 2.690489e-01 9.937705e-01
#> [5,] 0.44081658 0.7457039 0.5156145 0.1083357154 3.394624e-01 9.994329e-01
#> [6,] 0.44136482 0.6727126 0.4534436 0.7492091359 3.608359e-01 9.684792e-01
#> [7,] 0.37889336 0.9185981 0.4436669 0.9262557370 3.453402e-01 9.999993e-01
#> [8,] 0.07808525 0.5529428 0.7049742 0.9295994302 2.510430e-01 9.999999e-01
#> [9,] 0.05298677 0.7102308 0.4907146 0.9713788608 3.210604e-03 9.992987e-01
#> [10,] 0.66692369 0.5555195 0.6840628 0.8545523120 3.963323e-04 9.899735e-01
#> [11,] 0.21551597 0.5621939 0.6248165 0.9862382136 1.342093e-06 1.000000e+00
#> [12,] 0.21767418 0.8691576 0.5217377 0.9371903840 7.169184e-02 9.696264e-01
#> [13,] 0.52739186 0.6822244 0.3146828 0.9948681021 2.440298e-04 7.612572e-01
#> [14,] 0.14225841 0.8477438 0.4106453 0.9907081718 4.601361e-03 8.486149e-01
#> [15,] 0.27883754 0.6759082 0.4548538 0.7487873800 8.497298e-07 7.707280e-01
#> [16,] 0.24430158 0.8052916 0.4309683 0.9717533498 4.108381e-09 8.147914e-01
#> [17,] 0.10111125 0.6202207 0.6729306 0.9552509732 1.580995e-02 2.881014e-01
#> [18,] 0.15919028 0.9015161 0.5227016 0.9573754598 9.829226e-11 3.335120e-01
#> [19,] 0.29261014 0.8785741 0.4529485 0.9447302005 2.092828e-02 2.244645e-01
#> [20,] 0.34466852 0.6165346 0.7613942 0.8886660151 1.336164e-06 3.728880e-02
#> [21,] 0.30906402 0.7496685 0.1958003 0.9480485241 9.946869e-01 8.127741e-02
#> [22,] 0.65983453 0.7564899 0.5250157 0.9909857204 7.174594e-02 2.385729e-04
#> [23,] 0.40117028 0.8456856 0.3330645 0.9980716975 5.934552e-07 2.031991e-03
#> [24,] 0.32194498 0.5177283 0.6035044 0.9677712420 2.534110e-05 3.722797e-03
#> [25,] 0.39666911 0.8470458 0.5507888 0.9460021232 4.165734e-05 2.892646e-02
#> [26,] 0.26002832 0.5981523 0.4050646 0.7604407365 1.859768e-08 4.474327e-04
#> [27,] 0.20024033 0.7778041 0.3823704 0.9866328776 2.437101e-02 3.529716e-03
#> [28,] 0.46380583 0.7947460 0.5265196 0.8873927051 1.875278e-03 3.323654e-04
#> [29,] 0.31670529 0.7150313 0.4672922 0.9578109489 1.162112e-03 1.360049e-06
#> [30,] 0.31363507 0.7515677 0.7347078 0.8490707577 2.198038e-01 4.870137e-13
#> [31,] 0.45087450 0.7885220 0.4391928 0.7700390841 1.382328e-02 4.052843e-04
#> [32,] 0.20315964 0.8288378 0.3781987 0.8748098131 1.089160e-02 1.713467e-04
#> [33,] 0.34610664 0.8707385 0.6597452 0.9972513169 1.793490e-03 2.204967e-06
#> [34,] 0.19438832 0.7728394 0.2899702 0.9563664290 2.708485e-02 1.918422e-08
#> [35,] 0.48270499 0.9771821 0.4131893 0.8770899615 5.761167e-07 1.754464e-03
#> [36,] 0.48577934 0.6609496 0.4290459 0.9950995389 1.397707e-02 7.817802e-03
#> [37,] 0.09960552 0.6956785 0.5223892 0.9547094031 2.071255e-04 6.916517e-03
#> [38,] 0.09192394 0.8540595 0.5239369 0.8591687605 7.182367e-03 8.206889e-06
#> [39,] 0.17245554 0.9633608 0.7668637 0.9304664265 2.885112e-05 2.643165e-03
#> [40,] 0.39078106 0.6350170 0.6065560 0.8257311963 1.219287e-06 6.171765e-07
#> [41,] 0.19849419 0.9832708 0.4608306 0.7605033058 3.179588e-04 3.275330e-04
#> [42,] 0.06622052 0.7069056 0.3285479 0.4967639372 3.637688e-02 5.505240e-05
#> [43,] 0.09792800 0.7587445 0.6692741 0.5122641783 7.929768e-02 3.541589e-06
#> [44,] 0.33039190 0.4499013 0.3033961 0.8510178865 4.816656e-05 1.769446e-03
#> [45,] 0.77861094 0.9334992 0.6584963 0.7044143283 2.814906e-02 3.754673e-04
#> [46,] 0.60085650 0.9321154 0.5447841 0.9654207833 3.178429e-01 2.635654e-04
#> [47,] 0.33664031 0.7174537 0.6637041 0.7106668387 2.047458e-01 1.153975e-02
#> [48,] 0.42185168 0.8499946 0.5262866 0.8432387330 1.828219e-01 5.135007e-02
#> [49,] 0.21392604 0.8464720 0.6615916 0.9633037441 1.358193e-01 4.670466e-02
#> [50,] 0.69423100 0.9853025 0.2932695 0.9439797871 8.560109e-02 2.817877e-01
#> 0_1_s100 1_1_s100 0_0_s000 1_0_s000 0_1_s000 1_1_s000
#> [1,] 5.306467e-01 0.9991404 0.9636948 0.7425690 0.9420297 0.7765051
#> [2,] 3.753438e-01 0.9999999 0.9990037 0.8730449 0.8771330 0.7986517
#> [3,] 3.107106e-01 1.0000000 1.0000000 0.8499936 0.9038887 0.7652944
#> [4,] 5.937690e-01 0.9999966 0.9999987 0.8612660 0.9353512 0.8158791
#> [5,] 6.190851e-01 0.9999649 0.9962917 0.8580852 0.9505811 0.7691157
#> [6,] 3.036124e-01 0.9999994 0.9983792 0.8611341 0.9724666 0.7533058
#> [7,] 5.006364e-02 0.8413779 0.9747957 0.8477132 1.0000000 0.7557535
#> [8,] 8.291388e-05 0.9804314 0.9573719 0.8766492 1.0000000 0.8489989
#> [9,] 9.008029e-04 0.9925000 0.9674012 0.8181496 0.9942901 0.7804450
#> [10,] 1.652198e-04 0.9999997 0.9706533 0.8923930 0.9718381 0.7896234
#> [11,] 6.543871e-04 1.0000000 0.9927619 0.8405980 0.9996261 0.7876509
#> [12,] 4.630665e-03 0.8686217 1.0000000 0.8397002 0.9999990 0.7147348
#> [13,] 4.281498e-05 0.6500659 0.9990222 0.8528573 0.9999408 0.8032367
#> [14,] 2.951131e-04 0.9881377 0.9992091 0.8804525 0.9999590 0.8081158
#> [15,] 7.372951e-05 0.9983204 0.9997279 0.9179003 0.9858113 0.7887914
#> [16,] 1.894637e-01 0.9987194 0.9420497 0.9579776 0.9477679 0.8680322
#> [17,] 1.571738e-01 0.9997142 0.9287814 0.8960312 0.8850876 0.8465473
#> [18,] 3.394153e-03 0.9964434 0.9852595 0.9420836 0.8095104 0.7542210
#> [19,] 1.164843e-02 0.8782094 0.9735695 0.9580908 0.8113054 0.7455853
#> [20,] 9.872773e-03 0.9988058 0.9445582 0.9833694 0.8788545 0.7953742
#> [21,] 7.392228e-11 0.9988816 0.8580342 0.9932629 0.9266854 0.7449594
#> [22,] 4.728824e-06 0.9893477 0.9140865 0.9519722 0.8556147 0.8162982
#> [23,] 2.573420e-01 0.9999989 0.8543033 0.8710438 0.8203754 0.8005453
#> [24,] 1.586559e-01 0.9693907 0.9149630 0.9291936 0.9557171 0.8529529
#> [25,] 2.634067e-04 1.0000000 0.9838388 0.9417785 0.9260188 0.8365191
#> [26,] 1.745529e-03 0.9975638 0.9710896 0.9326720 0.9128435 0.7064501
#> [27,] 2.299364e-08 0.9998989 0.9290518 0.9589388 0.8926372 0.7928212
#> [28,] 3.528923e-01 1.0000000 0.9372146 0.9494454 0.7877170 0.7518033
#> [29,] 9.985620e-01 0.9920152 0.9770901 0.9621370 0.8289464 0.8401813
#> [30,] 8.851895e-01 0.9963201 0.9209563 0.9638250 0.8373765 0.8553272
#> [31,] 7.826966e-01 0.9999506 0.8760608 0.9830174 0.8358434 0.8130110
#> [32,] 9.958878e-01 0.9999997 0.9300434 0.9593046 0.8837092 0.7772736
#> [33,] 9.844862e-01 0.9999987 0.9787244 0.9154699 0.8515256 0.8323680
#> [34,] 9.668828e-01 0.9996915 1.0000000 0.9505579 0.8410065 0.7301320
#> [35,] 9.595463e-01 0.9999908 1.0000000 0.9814874 0.8387594 0.7885052
#> [36,] 9.610555e-01 1.0000000 0.9984748 0.9691370 0.7554524 0.7645448
#> [37,] 9.994511e-01 0.9999695 0.9991983 0.9826857 0.8490218 0.7725126
#> [38,] 9.999283e-01 0.9999996 0.9999986 0.9929418 0.8943910 0.7242137
#> [39,] 9.607800e-01 1.0000000 0.9999999 0.9999746 0.8495129 0.7675464
#> [40,] 9.360338e-01 0.9999747 0.9985166 1.0000000 0.8754403 0.8001959
#> [41,] 8.672259e-01 0.9999715 0.9999998 0.9989307 0.8566796 0.8067067
#> [42,] 1.875114e-01 0.9863229 1.0000000 0.9941010 0.8448307 0.7109405
#> [43,] 3.895442e-01 1.0000000 0.9889576 0.9999994 0.7592723 0.7278990
#> [44,] 1.365047e-07 0.9999740 0.9997763 0.9991956 0.9009243 0.7875409
#> [45,] 9.671972e-05 0.9999969 0.9976247 0.9999965 0.9145682 0.8535052
#> [46,] 1.406230e-03 0.9988886 0.9958879 0.9999515 0.9605013 0.8152399
#> [47,] 7.745810e-11 0.9881601 0.9999999 0.9996471 0.8779274 0.8329347
#> [48,] 1.284408e-01 0.9775774 1.0000000 0.9999936 0.9032210 0.7398883
#> [49,] 1.895985e-02 0.8005970 0.9993806 0.9999855 0.9764847 0.7650646
#> [50,] 2.663236e-06 0.9889048 0.9999976 0.9971694 0.9853764 0.8467847
#>
#> $psis
#> s111 s100 s000
#> [1,] 0.06899581 0.24066146 0.6903427
#> [2,] 0.06439397 0.22311059 0.7124954
#> [3,] 0.07541109 0.20215758 0.7224313
#> [4,] 0.03271615 0.15962921 0.8076546
#> [5,] 0.07022245 0.15432116 0.7754564
#> [6,] 0.04648564 0.17435316 0.7791612
#> [7,] 0.06611694 0.11734886 0.8165342
#> [8,] 0.10600770 0.12909639 0.7648959
#> [9,] 0.07036621 0.08894138 0.8406924
#> [10,] 0.07779870 0.07107568 0.8511256
#> [11,] 0.05995670 0.08444144 0.8556019
#> [12,] 0.07435816 0.09300356 0.8326383
#> [13,] 0.07074646 0.09660235 0.8326512
#> [14,] 0.07810278 0.08202187 0.8398754
#> [15,] 0.07679858 0.04940433 0.8737971
#> [16,] 0.06997596 0.09210190 0.8379221
#> [17,] 0.08184419 0.05662742 0.8615284
#> [18,] 0.09961509 0.05811878 0.8422661
#> [19,] 0.07636392 0.04035646 0.8832796
#> [20,] 0.05663945 0.03781032 0.9055502
#> [21,] 0.07980986 0.02807042 0.8921197
#> [22,] 0.07075129 0.03791879 0.8913299
#> [23,] 0.10924112 0.04755468 0.8432042
#> [24,] 0.09734429 0.06224960 0.8404061
#> [25,] 0.08234048 0.04989976 0.8677598
#> [26,] 0.08105655 0.04911452 0.8698289
#> [27,] 0.09008075 0.06768733 0.8422319
#> [28,] 0.06083061 0.03619976 0.9029696
#> [29,] 0.08648789 0.03569151 0.8778206
#> [30,] 0.09300659 0.06531837 0.8416750
#> [31,] 0.08856620 0.07358365 0.8378502
#> [32,] 0.05752004 0.07289864 0.8695813
#> [33,] 0.06860555 0.05080812 0.8805863
#> [34,] 0.07595617 0.09227298 0.8317709
#> [35,] 0.07403733 0.10604329 0.8199194
#> [36,] 0.05684829 0.09031376 0.8528380
#> [37,] 0.05763901 0.07015260 0.8722084
#> [38,] 0.07745137 0.06926572 0.8532829
#> [39,] 0.06647909 0.09454196 0.8389789
#> [40,] 0.08117803 0.10955487 0.8092671
#> [41,] 0.06817810 0.09444204 0.8373799
#> [42,] 0.05864091 0.09370690 0.8476522
#> [43,] 0.06519405 0.11001454 0.8247914
#> [44,] 0.07880107 0.08908284 0.8321161
#> [45,] 0.07382658 0.11609058 0.8100828
#> [46,] 0.07424108 0.09662604 0.8291329
#> [47,] 0.06577901 0.07482053 0.8594005
#> [48,] 0.06189630 0.10912836 0.8289753
#> [49,] 0.05926884 0.09560686 0.8451243
#> [50,] 0.06058023 0.12215472 0.8172651
#>
#> $s.tab
#> s111 s100 s000
#> [1,] 0.06400000 0.22933333 0.7066667
#> [2,] 0.05866667 0.17333333 0.7680000
#> [3,] 0.05600000 0.17333333 0.7706667
#> [4,] 0.05600000 0.16533333 0.7786667
#> [5,] 0.05600000 0.15200000 0.7920000
#> [6,] 0.05866667 0.13333333 0.8080000
#> [7,] 0.06400000 0.14400000 0.7920000
#> [8,] 0.08266667 0.09866667 0.8186667
#> [9,] 0.07733333 0.10133333 0.8213333
#> [10,] 0.08266667 0.09066667 0.8266667
#> [11,] 0.07200000 0.08800000 0.8400000
#> [12,] 0.07466667 0.08000000 0.8453333
#> [13,] 0.07200000 0.09066667 0.8373333
#> [14,] 0.07200000 0.08800000 0.8400000
#> [15,] 0.07466667 0.08000000 0.8453333
#> [16,] 0.07733333 0.07733333 0.8453333
#> [17,] 0.08000000 0.04800000 0.8720000
#> [18,] 0.07200000 0.05866667 0.8693333
#> [19,] 0.07466667 0.05600000 0.8693333
#> [20,] 0.08800000 0.04800000 0.8640000
#> [21,] 0.08800000 0.04800000 0.8640000
#> [22,] 0.08266667 0.04533333 0.8720000
#> [23,] 0.07733333 0.03733333 0.8853333
#> [24,] 0.08266667 0.04533333 0.8720000
#> [25,] 0.08533333 0.04266667 0.8720000
#> [26,] 0.08000000 0.04800000 0.8720000
#> [27,] 0.08000000 0.06666667 0.8533333
#> [28,] 0.07733333 0.04533333 0.8773333
#> [29,] 0.08000000 0.04266667 0.8773333
#> [30,] 0.07733333 0.06133333 0.8613333
#> [31,] 0.07466667 0.06933333 0.8560000
#> [32,] 0.07466667 0.06666667 0.8586667
#> [33,] 0.07733333 0.05866667 0.8640000
#> [34,] 0.06933333 0.07466667 0.8560000
#> [35,] 0.07200000 0.08533333 0.8426667
#> [36,] 0.06933333 0.09866667 0.8320000
#> [37,] 0.06666667 0.08533333 0.8480000
#> [38,] 0.07466667 0.07200000 0.8533333
#> [39,] 0.07733333 0.08000000 0.8426667
#> [40,] 0.06933333 0.10133333 0.8293333
#> [41,] 0.07733333 0.09066667 0.8320000
#> [42,] 0.06666667 0.09333333 0.8400000
#> [43,] 0.06133333 0.09600000 0.8426667
#> [44,] 0.06666667 0.08800000 0.8453333
#> [45,] 0.06933333 0.09066667 0.8400000
#> [46,] 0.06400000 0.10400000 0.8320000
#> [47,] 0.06666667 0.10400000 0.8293333
#> [48,] 0.06933333 0.09066667 0.8400000
#> [49,] 0.07466667 0.10133333 0.8240000
#> [50,] 0.06400000 0.11733333 0.8186667
#>
#> $delta.1
#> [1] 0.62606838 0.07687355 -0.41162228 -0.24334140 -0.48950767 0.08215297
#> [7] 0.50498575 0.28394599 0.59238589 0.22843211 0.57630907 0.29271305
#> [13] 0.71902937 0.67879949 0.44936188 0.48006777 0.35652174 0.47318008
#> [19] 0.48270893 0.33811802 0.72115896 0.53966617 0.55192346 0.40106902
#> [25] 0.56413994 0.47681159 0.60144928 0.25583018 0.57391304 0.11500897
#> [31] 0.42743928 0.53808152 0.36794897 0.81672912 0.31353768 0.65505841
#> [37] 0.52000000 0.46953479 0.36545744 0.14569099 0.46272673 0.20571429
#> [43] -0.28557312 0.50571429 0.14359709 0.46118234 0.16000000 0.48324884
#> [49] 0.39923837 0.69408832
#>
#> $delta.2
#> [1] 0.599802933 0.001659586 -0.387320455 -0.214056422 -0.319149375
#> [6] 0.347515422 0.596709980 0.212254503 0.579180311 0.261601654
#> [11] 0.464587412 0.585245832 0.788866239 0.666948570 0.426989846
#> [16] 0.532482326 0.266519793 0.422294209 0.516767646 0.167769226
#> [21] 0.897959844 0.463311231 0.644130567 0.404033630 0.425483415
#> [26] 0.497515357 0.622272571 0.370460022 0.479978560 0.089701713
#> [31] 0.334295525 0.594496075 0.354772426 0.762922861 0.503767876
#> [36] 0.554102658 0.503095195 0.492626743 0.233296081 0.277824044
#> [41] 0.331126708 0.209261144 -0.201171638 0.553340028 -0.026004738
#> [46] 0.446624150 0.009211514 0.362505633 0.412207375 0.642691576
#>
#> $loglike
#> [1] 296.9760 290.3734 291.4722 287.4248 284.6050 284.3368 281.0415 288.3082
#> [9] 282.9032 280.5217 282.7722 281.8393 281.3886 281.6311 283.0879 285.5557
#> [17] 281.0653 282.1907 281.1789 283.8162 288.1495 279.8502 284.8815 282.5055
#> [25] 279.2906 280.9269 279.7592 280.0153 280.9631 280.4430 279.8242 279.5247
#> [33] 281.9022 281.0522 281.6882 282.3514 281.5317 283.1552 282.6242 280.0346
#> [41] 282.5274 284.7997 284.8925 281.0373 284.1501 281.4321 281.4759 279.9431
#> [49] 280.7662 286.5794
#>
#> $logpost
#> [1] -298.0146 -279.7250 -254.3389 -276.3252 -280.9147 -279.9714 -259.0705
#> [8] -261.9591 -273.1888 -264.6807 -239.7498 -254.7302 -267.4669 -267.8486
#> [15] -266.4207 -273.5190 -281.8609 -264.9718 -284.1584 -273.8090 -268.7275
#> [22] -269.5310 -267.9426 -278.2929 -254.0522 -264.3894 -262.5645 -261.2890
#> [29] -267.6297 -263.7946 -275.4671 -265.7788 -261.8975 -256.3578 -253.0814
#> [36] -267.7540 -264.8191 -252.8589 -247.1503 -245.1148 -258.4769 -268.5994
#> [43] -258.1890 -252.9204 -260.0633 -266.8303 -253.4522 -265.8435 -273.5263
#> [50] -268.5725
#>