-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_hddid_p_current_surface.ado
More file actions
2419 lines (2403 loc) · 147 KB
/
Copy path_hddid_p_current_surface.ado
File metadata and controls
2419 lines (2403 loc) · 147 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
capture program drop _hddid_p_current_surface
capture program drop _hddid_current_beta_coords
capture program drop _hddid_p_current_preflight
program define _hddid_current_beta_coords, rclass
version 16
return clear
local _coords = strtrim(`"`e(xvars)'"')
local _coords : list retokenize _coords
if `"`_coords'"' == "" {
capture confirm matrix e(xdebias)
if _rc == 0 {
tempname _xdebias_coords
matrix `_xdebias_coords' = e(xdebias)
local _coords : colnames `_xdebias_coords'
local _coords : list retokenize _coords
}
}
if `"`_coords'"' == "" {
capture confirm matrix e(stdx)
if _rc == 0 {
tempname _stdx_coords
matrix `_stdx_coords' = e(stdx)
local _coords : colnames `_stdx_coords'
local _coords : list retokenize _coords
}
}
if `"`_coords'"' == "" {
capture confirm matrix e(b)
if _rc == 0 {
tempname _b_coords
matrix `_b_coords' = e(b)
local _coords : colnames `_b_coords'
local _coords : list retokenize _coords
}
}
return local coords `"`_coords'"'
end
program define _hddid_p_current_preflight
capture program list _hddid_preflight_current_vectors
if _rc == 0 {
exit
}
local _hddid_pst_pkgdir `"$HDDID_SOURCE_RUN_PKGDIR"'
if `"`_hddid_pst_pkgdir'"' == "" {
local _hddid_pst_pkgdir `"$HDDID_WRAPPER_PKGDIR"'
}
if `"`_hddid_pst_pkgdir'"' == "" {
local _hddid_pst_pkgdir `"$HDDID_PACKAGE_DIR"'
}
if `"`_hddid_pst_pkgdir'"' != "" {
quietly capture run `"`_hddid_pst_pkgdir'/_hddid_preflight_current_vectors.ado"'
capture program list _hddid_preflight_current_vectors
}
if _rc != 0 {
capture findfile _hddid_preflight_current_vectors.ado
if _rc == 0 {
quietly capture run `"`r(fn)'"'
}
}
capture program list _hddid_preflight_current_vectors
if _rc != 0 {
di as error "{bf:hddid}: failed to load {bf:_hddid_preflight_current_vectors.ado}"
di as error " Reason: direct unsupported predict on current results delegates beta/interval consistency checks to a sibling helper"
di as error " Please reinstall the hddid package or remove shadow/old copies from adopath"
exit 198
}
end
program define _hddid_p_current_surface
version 16
syntax , [ESTOPTRAW(string asis) ESTOPTCANONICAL(string asis)]
local _hddid_estopt_raw `"`estoptraw'"'
local _hddid_estopt_canonical `"`estoptcanonical'"'
local _depvar_eq = strtrim(`"`e(depvar)'"')
local _depvar_eq_missing = (`"`_depvar_eq'"' == "")
local _depvar_role = strtrim(`"`e(depvar_role)'"')
local _firststage_mode = lower(strtrim(`"`e(firststage_mode)'"'))
local _cmdline = `"`e(cmdline)'"'
local _cmdline_probe = strtrim(`"`_cmdline'"')
local _cmdline_parse_pre = `"`_cmdline'"'
local _cmdline_lc_pre ""
local _cmdline_depvar_pre ""
if `"`_cmdline_probe'"' != "" {
local _cmdline_parse_pre = ///
subinstr(`"`_cmdline_parse_pre'"', char(9), " ", .)
local _cmdline_parse_pre = ///
subinstr(`"`_cmdline_parse_pre'"', char(10), " ", .)
local _cmdline_parse_pre = ///
subinstr(`"`_cmdline_parse_pre'"', char(13), " ", .)
local _cmdline_lc_pre = lower(`"`_cmdline_parse_pre'"')
if regexm(`"`_cmdline_lc_pre'"', "^[ ]*hddid[ ]+([^, ]+)") {
local _cmdline_depvar_pre = strtrim(regexs(1))
}
}
capture confirm scalar e(N_pretrim)
local _has_n_pretrim_marker = (_rc == 0)
capture confirm scalar e(clime_nfolds_cv_max)
local _has_clime_max_marker = (_rc == 0)
capture confirm scalar e(clime_nfolds_cv_effective_min)
local _has_clime_effmin_marker = (_rc == 0)
capture confirm scalar e(clime_nfolds_cv_effective_max)
local _has_clime_effmax_marker = (_rc == 0)
capture confirm matrix e(clime_nfolds_cv_per_fold)
local _has_clime_perfold_marker = (_rc == 0)
local _current_result_surface = (`"`_depvar_role'"' != "")
if `_current_result_surface' == 0 & ///
(`"`_firststage_mode'"' != "" | `_has_n_pretrim_marker' | ///
`_has_clime_max_marker' | `_has_clime_effmin_marker' | ///
`_has_clime_effmax_marker' | `_has_clime_perfold_marker') {
local _current_result_surface 1
}
if `_depvar_eq_missing' & `_current_result_surface' {
local _depvar_eq "beta"
}
if `_current_result_surface' & `"`_depvar_role'"' == "" & ///
`"`_depvar_eq'"' != "" & `"`_depvar_eq'"' != "beta" {
di as error "{bf:hddid}: stored e(depvar) must be {bf:beta} on current results"
di as error " Reason: current hddid results are already identified by current-only machine-readable metadata such as {bf:e(firststage_mode)}, {bf:e(N_pretrim)}, or the published CLIME fold-provenance block, so {bf:e(depvar)} must remain the generic beta-block label rather than a legacy outcome-role name."
exit 498
}
local _depvar_role_from_cmdline 0
local _cmd_has_roles 0
local _cmdline_has_nofirst 0
local _firststage_mode_from_cmdline 0
local _fstage_from_folds 0
local _cmdline_treat ""
local _cmdline_xvars ""
local _cmdline_zvar ""
local _cmdroles_checked 0
if `_current_result_surface' & `"`_depvar_role'"' == "" & ///
`"`_depvar_eq'"' == "beta" {
if `"`_cmdline_depvar_pre'"' != "" {
local _depvar_role `"`_cmdline_depvar_pre'"'
local _depvar_role_from_cmdline 1
}
else {
di as error "{bf:hddid}: current results require stored e(depvar_role) or current e(cmdline) depvar provenance"
di as error " Reason: once current-only metadata such as {bf:e(firststage_mode)}, {bf:e(N_pretrim)}, or the published CLIME fold-provenance block is present,"
di as error " {bf:e(depvar)=beta} is only the generic beta-block label, so direct unsupported postestimation must recover the original outcome-role label from {bf:e(depvar_role)} or the successful-call record in {bf:e(cmdline)}."
exit 498
}
}
if `_current_result_surface' {
local _predict_stub = strtrim(`"`e(predict)'"')
if `"`_predict_stub'"' != "hddid_p" {
local _predict_stub "hddid_p"
}
local _estat_stub = strtrim(`"`e(estat_cmd)'"')
if `"`_estat_stub'"' != "hddid_estat" {
local _estat_stub "hddid_estat"
}
local _vce = strtrim(`"`e(vce)'"')
// e(vce) is the variance tag paired with the posted covariance
// matrix e(V); when absent or malformed, the default robust
// tag is applied.
if `"`_vce'"' != "robust" {
local _vce "robust"
}
local _vcetype = strtrim(`"`e(vcetype)'"')
if `"`_vcetype'"' != "Robust" {
local _vcetype "Robust"
}
local _marginsnotok = strtrim(`"`e(marginsnotok)'"')
if `"`_marginsnotok'"' != "_ALL" {
local _marginsnotok "_ALL"
}
if `"`_cmdline_probe'"' != "" {
local _cmdline_parse = `"`_cmdline'"'
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(9), " ", .)
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(10), " ", .)
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(13), " ", .)
local _cmdline_lc = lower(`"`_cmdline_parse'"')
local _cmdline_opts = ""
local _cmdline_comma = strpos(`"`_cmdline_lc'"', ",")
if `_cmdline_comma' > 0 {
local _cmdline_opts = ///
strtrim(substr(`"`_cmdline_lc'"', `_cmdline_comma' + 1, .))
}
local _cmdline_depvar = ""
if regexm(`"`_cmdline_lc'"', "^[ ]*hddid[ ]+([^, ]+)") {
local _cmdline_depvar = strtrim(regexs(1))
}
local _cmdline_treat_head ///
"(^tr(e(a(t)?)?)?[(])|([ ,]tr(e(a(t)?)?)?[(])"
local _cmdline_treat_token ///
"(^tr(e(a(t)?)?)?[(][^)]*[)])|([ ,]tr(e(a(t)?)?)?[(][^)]*[)])"
local _cmd_has_roles = ///
regexm(`"`_cmdline_opts'"', `"`_cmdline_treat_head'"') & ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])x[(]") & ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])z[(]")
local _cmdline_has_nofirst = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])nof(i(r(s(t)?)?)?)?([ ,]|$)")
local _cmdline_has_seed = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])seed[(][ ]*[^)]*[)]")
local _cmdline_dup_role_opts = 0
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', `"`_cmdline_treat_token'"') {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
`"`_cmdline_treat_token'"', " ")
if regexm(`"`_cmdline_role_probe'"', `"`_cmdline_treat_head'"') {
local _cmdline_dup_role_opts = 1
}
}
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])x[(][^)]*[)]") {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
"(^|[ ,])x[(][^)]*[)]", " ")
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])x[(]") {
local _cmdline_dup_role_opts = 1
}
}
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])z[(][^)]*[)]") {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
"(^|[ ,])z[(][^)]*[)]", " ")
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])z[(]") {
local _cmdline_dup_role_opts = 1
}
}
if `_cmdline_dup_role_opts' {
di as error "{bf:hddid}: stored e(cmdline) must encode each treat()/x()/z() role option at most once"
di as error " Current postestimation guidance found duplicated role provenance in {bf:e(cmdline)} = {bf:`_cmdline'}"
exit 498
}
if regexm(`"`_cmdline_opts'"', "(^|[ ,])tr(e(a(t)?)?)[(]([^)]*)[)]") {
local _cmdline_treat = strtrim(regexs(5))
}
if regexm(`"`_cmdline_opts'"', "(^|[ ,])x[(]([^)]*)[)]") {
local _cmdline_xvars = strtrim(regexs(2))
}
if regexm(`"`_cmdline_opts'"', "(^|[ ,])z[(]([^)]*)[)]") {
local _cmdline_zvar = strtrim(regexs(2))
}
if `"`_cmdline_depvar'"' == "" | `_cmd_has_roles' == 0 {
local _published_xcoords_ok 0
quietly _hddid_current_beta_coords
local _published_xcoords `"`r(coords)'"'
if `"`_published_xcoords'"' != "" {
local _published_xcoords_ok 1
}
local _stored_role_bundle_ok = ///
(`"`_depvar_role'"' != "" & ///
strtrim(`"`e(treat)'"') != "" & ///
(strtrim(`"`e(xvars)'"') != "" | `_published_xcoords_ok') & ///
strtrim(`"`e(zvar)'"') != "")
if `_stored_role_bundle_ok' == 0 {
di as error "{bf:hddid}: stored e(cmdline) must include depvar plus treat()/x()/z() role provenance"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'}"
di as error " Reason: the successful-call record can omit role text only when the published role metadata already remain complete in {bf:e(depvar_role)}, {bf:e(treat)}, and {bf:e(zvar)},"
di as error " and when the beta-coordinate order still remains recoverable from machine-readable {bf:e(xvars)} or the published beta-surface labels."
exit 498
}
}
capture confirm matrix e(tc)
if _rc == 0 {
tempname _tc_pre_disp
matrix `_tc_pre_disp' = e(tc)
local _tc_pre_names_actual : colnames `_tc_pre_disp'
local _tc_pre_names_actual : list retokenize _tc_pre_names_actual
if rowsof(`_tc_pre_disp') != 1 | colsof(`_tc_pre_disp') != 2 | ///
missing(`_tc_pre_disp'[1,1]) | missing(`_tc_pre_disp'[1,2]) {
di as error "{bf:hddid}: stored e(tc) must be a finite 1 x 2 rowvector"
di as error " Current postestimation guidance must validate the published CIuniform bootstrap provenance before ancillary seed()/alpha()/nboot() cmdline checks."
exit 498
}
if `"`_tc_pre_names_actual'"' != "tc_lower tc_upper" {
di as error "{bf:hddid}: stored e(tc) must use colnames {bf:tc_lower tc_upper}"
di as error " Current postestimation guidance must validate unambiguous CIuniform bootstrap provenance before ancillary seed()/alpha()/nboot() cmdline checks: {bf:`_tc_pre_names_actual'}"
exit 498
}
if `_tc_pre_disp'[1,1] > `_tc_pre_disp'[1,2] {
di as error "{bf:hddid}: stored e(tc) must satisfy lower <= upper"
di as error " Current postestimation guidance must validate ordered CIuniform bootstrap provenance before ancillary seed()/alpha()/nboot() cmdline checks."
exit 498
}
capture confirm matrix e(CIuniform)
local _has_ciuniform_pre = (_rc == 0)
capture confirm matrix e(CIpoint)
local _has_cipoint_pre = (_rc == 0)
capture confirm matrix e(xdebias)
local _has_xdebias_pre = (_rc == 0)
capture confirm matrix e(stdx)
local _has_stdx_pre = (_rc == 0)
capture confirm matrix e(gdebias)
local _has_gdebias_pre = (_rc == 0)
capture confirm matrix e(stdg)
local _has_stdg_pre = (_rc == 0)
_hddid_p_current_preflight
_hddid_preflight_current_vectors, mode(postest)
if `_has_ciuniform_pre' & `_has_gdebias_pre' & `_has_stdg_pre' {
tempname _ciuniform_gap_pre _ciuniform_scale_pre _ciuniform_tol_pre
mata: _hddid_ciuniform_actual_pre = st_matrix("e(CIuniform)")
mata: _hddid_gdebias_pre = st_matrix("e(gdebias)")
mata: _hddid_stdg_pre = st_matrix("e(stdg)")
mata: _hddid_tc_pre = st_matrix("e(tc)")
mata: _hddid_ciuniform_lower_pre = _hddid_gdebias_pre :+ _hddid_tc_pre[1, 1] * _hddid_stdg_pre
mata: _hddid_ciuniform_upper_pre = _hddid_gdebias_pre :+ _hddid_tc_pre[1, 2] * _hddid_stdg_pre
mata: _hddid_ciuniform_oracle_pre = _hddid_ciuniform_lower_pre \ _hddid_ciuniform_upper_pre
mata: _hddid_ciuniform_gap_pre = max(abs(_hddid_ciuniform_actual_pre :- _hddid_ciuniform_oracle_pre))
mata: st_numscalar("`_ciuniform_gap_pre'", _hddid_ciuniform_gap_pre)
mata: _hddid_ciuniform_scale_pre = max((1, max(abs(_hddid_ciuniform_actual_pre)), max(abs(_hddid_ciuniform_oracle_pre))))
mata: st_numscalar("`_ciuniform_scale_pre'", _hddid_ciuniform_scale_pre)
scalar `_ciuniform_tol_pre' = 1e-12 * scalar(`_ciuniform_scale_pre')
if scalar(`_ciuniform_gap_pre') > scalar(`_ciuniform_tol_pre') {
di as error "{bf:hddid}: stored e(CIuniform) must equal the lower/upper rows implied by e(gdebias), e(stdg), and e(tc)"
di as error " Current postestimation guidance must reject malformed current interval-object metadata before ancillary seed()/alpha()/nboot() cmdline checks."
exit 498
}
tempname _stdg0pr _ciug0pr _cius0pr
mata: st_numscalar("`_stdg0pr'", max(abs(st_matrix("e(stdg)"))))
mata: _hddid_ciu0pr = st_matrix("e(gdebias)") \ st_matrix("e(gdebias)")
mata: st_numscalar("`_ciug0pr'", max(abs(st_matrix("e(CIuniform)") :- _hddid_ciu0pr)))
mata: st_numscalar("`_cius0pr'", max((1, max(abs(st_matrix("e(CIuniform)"))), max(abs(_hddid_ciu0pr)))))
if scalar(`_stdg0pr') <= scalar(`_ciuniform_tol_pre') & ///
scalar(`_ciug0pr') <= scalar(`_ciuniform_tol_pre') & ///
(abs(`_tc_pre_disp'[1,1]) > scalar(`_ciuniform_tol_pre') | ///
abs(`_tc_pre_disp'[1,2]) > scalar(`_ciuniform_tol_pre')) {
di as error "{bf:hddid}: stored e(tc) must equal (0, 0) when stored e(stdg) is identically zero"
di as error " Current postestimation guidance must reject impossible zero-SE bootstrap provenance before ancillary seed()/alpha()/nboot() cmdline checks."
exit 498
}
}
local _ciuniform_zero_shortcut_pre = 0
if `_has_ciuniform_pre' & `_has_gdebias_pre' & `_has_stdg_pre' {
tempname _stdg_absmax_pre _ciuniform_shortcut_gap_pre _ciuniform_shortcut_scale_pre
mata: st_numscalar("`_stdg_absmax_pre'", max(abs(st_matrix("e(stdg)"))))
mata: _hddid_ciuniform_shortcut_pre = st_matrix("e(gdebias)") \ st_matrix("e(gdebias)")
mata: st_numscalar("`_ciuniform_shortcut_gap_pre'", max(abs(st_matrix("e(CIuniform)") :- _hddid_ciuniform_shortcut_pre)))
mata: st_numscalar("`_ciuniform_shortcut_scale_pre'", max((1, max(abs(st_matrix("e(CIuniform)"))), max(abs(_hddid_ciuniform_shortcut_pre)))))
if abs(`_tc_pre_disp'[1,1]) <= scalar(`_ciuniform_tol_pre') & ///
abs(`_tc_pre_disp'[1,2]) <= scalar(`_ciuniform_tol_pre') & ///
scalar(`_stdg_absmax_pre') <= scalar(`_ciuniform_tol_pre') & ///
scalar(`_ciuniform_shortcut_gap_pre') <= scalar(`_ciuniform_tol_pre') {
local _ciuniform_zero_shortcut_pre = 1
}
}
local _cmdline_alpha_value_pre = .
local _cmdline_alpha_ok_pre = 0
if regexm(`"`_cmdline_opts'"', "(^|[ ,])alpha[(][ ]*([^)]*)[ ]*[)]") {
local _cmdline_alpha_arg_pre = strtrim(regexs(2))
if regexm(`"`_cmdline_alpha_arg_pre'"', ///
"^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?$") {
local _cmdline_alpha_value_pre = real(`"`_cmdline_alpha_arg_pre'"')
if !missing(`_cmdline_alpha_value_pre') & ///
`_cmdline_alpha_value_pre' > 0 & ///
`_cmdline_alpha_value_pre' < 1 {
local _cmdline_alpha_ok_pre = 1
}
}
}
capture confirm scalar e(alpha)
local _has_alpha_pre = (_rc == 0)
local _alpha_pre = .
if `_has_alpha_pre' {
local _alpha_pre = e(alpha)
}
else if `_cmdline_alpha_ok_pre' {
local _alpha_pre = `_cmdline_alpha_value_pre'
}
if `_has_cipoint_pre' & `_has_xdebias_pre' & `_has_stdx_pre' & ///
`_has_gdebias_pre' & `_has_stdg_pre' & !missing(`_alpha_pre') {
tempname _cipoint_gap_pre _cipoint_scale_pre _cipoint_tol_pre _zcrit_pre
scalar `_zcrit_pre' = invnormal(1 - `_alpha_pre' / 2)
mata: _hddid_cipoint_actual_pre = st_matrix("e(CIpoint)")
mata: _hddid_cipoint_lower_pre = (st_matrix("e(xdebias)") :- st_numscalar("`_zcrit_pre'") :* st_matrix("e(stdx)"), st_matrix("e(gdebias)") :- st_numscalar("`_zcrit_pre'") :* st_matrix("e(stdg)"))
mata: _hddid_cipoint_upper_pre = (st_matrix("e(xdebias)") :+ st_numscalar("`_zcrit_pre'") :* st_matrix("e(stdx)"), st_matrix("e(gdebias)") :+ st_numscalar("`_zcrit_pre'") :* st_matrix("e(stdg)"))
mata: _hddid_cipoint_oracle_pre = _hddid_cipoint_lower_pre \ _hddid_cipoint_upper_pre
mata: _hddid_cipoint_gap_pre = max(abs(_hddid_cipoint_actual_pre :- _hddid_cipoint_oracle_pre))
mata: st_numscalar("`_cipoint_gap_pre'", _hddid_cipoint_gap_pre)
mata: _hddid_cipoint_scale_pre = max((1, max(abs(_hddid_cipoint_actual_pre)), max(abs(_hddid_cipoint_oracle_pre))))
mata: st_numscalar("`_cipoint_scale_pre'", _hddid_cipoint_scale_pre)
scalar `_cipoint_tol_pre' = 1e-12 * scalar(`_cipoint_scale_pre')
if scalar(`_cipoint_gap_pre') > scalar(`_cipoint_tol_pre') {
di as error "{bf:hddid}: stored e(CIpoint) must equal the pointwise intervals implied by e(xdebias), e(stdx), e(gdebias), e(stdg), and e(alpha)"
di as error " Current postestimation guidance must reject malformed current pointwise interval metadata before ancillary seed()/alpha()/nboot() cmdline checks."
exit 498
}
}
local _cmdline_seed_suppressed_pre = 0
if regexm(`"`_cmdline_opts'"', "(^|[ ,])seed[(][ ]*-1[ ]*[)]") {
local _cmdline_seed_suppressed_pre = 1
}
capture confirm scalar e(seed)
local _cmdline_seed_has_estored = (_rc == 0)
if `_cmdline_has_seed' & !`_cmdline_seed_suppressed_pre' & ///
`_cmdline_seed_has_estored' == 0 {
di as error "{bf:hddid}: current results with stored e(cmdline) seed() provenance require stored e(seed)"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} but no machine-readable {bf:e(seed)}."
if `_ciuniform_zero_shortcut_pre' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still publish RNG provenance through both the successful-call record and the machine-readable {bf:e(seed)} scalar for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish RNG provenance through both the successful-call record and the machine-readable {bf:e(seed)} scalar behind the realized bootstrap path."
}
exit 498
}
local _treat = strtrim(`"`e(treat)'"')
local _xvars = strtrim(`"`e(xvars)'"')
local _zvar = strtrim(`"`e(zvar)'"')
if `"`_depvar_role'"' != "" & `"`_treat'"' != "" & `"`_xvars'"' != "" & `"`_zvar'"' != "" {
_hddid_pst_cmdroles, ///
cmdline("`_cmdline'") ///
depvar("`_depvar_role'") ///
treat("`_treat'") ///
xvars("`_xvars'") ///
zvar("`_zvar'")
local _cmdroles_checked 1
}
}
}
// Beta-labeled result surfaces must satisfy the saved-results
// contract before postestimation validation terminates.
capture confirm scalar e(N_pretrim)
local _has_n_pretrim = (_rc == 0)
capture confirm scalar e(N_trimmed)
local _has_n_trimmed = (_rc == 0)
capture confirm scalar e(N_outer_split)
local _has_n_outer_split = (_rc == 0)
if `_has_n_pretrim' == 0 {
if `_has_n_trimmed' {
di as error " Inspect {bf:e(N_trimmed)} and {bf:e(N)} for the stored retained-sample accounting."
}
else {
di as error " Stored retained-sample accounting is incomplete because {bf:e(N_trimmed)} is not available."
di as error " Inspect {bf:e(N)} for the retained-sample count that remains stored."
}
if `_current_result_surface' {
di as error " When available, inspect {bf:e(N_pretrim)} for the full pretrim-to-retained accounting identity."
}
}
di as error " HDDID always uses the paper's fixed {bf:AIPW (doubly robust)} estimator path."
capture confirm scalar e(propensity_nfolds)
local _has_prop_nf_fst = (_rc == 0)
capture confirm scalar e(outcome_nfolds)
local _has_out_nf_fst = (_rc == 0)
if `"`_firststage_mode'"' == "" & `_current_result_surface' {
if `"`_cmdline_probe'"' == "" & ///
(`_has_prop_nf_fst' + `_has_out_nf_fst') == 1 {
di as error "{bf:hddid}: current direct unsupported postestimation requires stored {bf:e(propensity_nfolds)} and {bf:e(outcome_nfolds)} when first-stage provenance is recovered from fold metadata"
di as error " Reason: direct unsupported postestimation must disclose the published paired internal-only fold block {bf:e(propensity_nfolds)}/{bf:e(outcome_nfolds)} before it can reuse the current saved-results surface as an internal first-stage fit."
exit 498
}
if `"`_cmdline_probe'"' != "" & `_cmd_has_roles' {
if `_cmdline_has_nofirst' {
local _firststage_mode "nofirst"
}
else {
local _firststage_mode "internal"
}
local _firststage_mode_from_cmdline 1
}
else if `_has_prop_nf_fst' & `_has_out_nf_fst' {
local _firststage_mode "internal"
local _fstage_from_folds 1
}
}
if `"`_firststage_mode'"' == "" {
if `_current_result_surface' {
di as error "{bf:hddid}: current results require stored e(firststage_mode)"
di as error " Reason: current hddid direct unsupported postestimation can recover first-stage provenance from stored {bf:e(firststage_mode)},"
di as error " from the published paired internal-only fold block {bf:e(propensity_nfolds)}/{bf:e(outcome_nfolds)}, or, when the successful-call record remains available, from {bf:e(cmdline)}."
di as error " It only fails closed when all three are unavailable on a malformed current saved-results surface."
exit 498
}
}
if `"`_firststage_mode'"' != "" & ///
!inlist(`"`_firststage_mode'"', "internal", "nofirst") {
di as error " stored {bf:e(firststage_mode)} must be {bf:internal} or {bf:nofirst}."
di as error " Current postestimation guidance refuses to reinterpret malformed first-stage provenance as a legacy {bf:e(cmdline)}-only result."
exit 498
}
if inlist(`"`_firststage_mode'"', "internal", "nofirst") {
if `_firststage_mode_from_cmdline' {
di as error " Recover the stored first-stage provenance from {bf:e(cmdline)}."
}
else if `_fstage_from_folds' {
di as error " Recover the stored internal first-stage provenance from the published paired {bf:e(propensity_nfolds)} and {bf:e(outcome_nfolds)} block."
}
else {
di as error " Use {bf:e(firststage_mode)} for the stored first-stage provenance."
}
}
else {
local _cmdline_legacy_probe = strtrim(`"`e(cmdline)'"')
if `"`_cmdline_legacy_probe'"' == "" {
di as error "{bf:hddid}: legacy results without stored e(firststage_mode) require stored e(cmdline)"
di as error " Reason: direct unsupported postestimation cannot classify the published first-stage path as {bf:internal} or {bf:nofirst} without either machine-readable {bf:e(firststage_mode)} or the successful-call provenance record."
exit 498
}
di as error " Legacy results without {bf:e(firststage_mode)} should recover that first-stage provenance from {bf:e(cmdline)}."
}
if `_current_result_surface' & inlist(`"`_firststage_mode'"', "internal", "nofirst") {
capture confirm scalar e(N_outer_split)
local _has_n_outer_split_fast = (_rc == 0)
if `_has_n_outer_split_fast' {
local _n_outer_split_fast = e(N_outer_split)
if `"`_firststage_mode'"' == "internal" {
capture confirm scalar e(N_pretrim)
local _has_n_pretrim_fast = (_rc == 0)
if `_has_n_pretrim_fast' {
local _n_pretrim_fast = e(N_pretrim)
if missing(`_n_pretrim_fast') | ///
missing(`_n_outer_split_fast') | ///
`_n_pretrim_fast' != floor(`_n_pretrim_fast') | ///
`_n_outer_split_fast' != floor(`_n_outer_split_fast') | ///
`_n_outer_split_fast' != `_n_pretrim_fast' {
di as error "{bf:hddid}: stored e(N_outer_split) must equal stored e(N_pretrim) for current internal results"
di as error " Current postestimation guidance refuses to advertise malformed outer-split provenance metadata."
exit 498
}
}
}
else if missing(`_n_outer_split_fast') | ///
`_n_outer_split_fast' < e(N) | ///
`_n_outer_split_fast' != floor(`_n_outer_split_fast') {
di as error "{bf:hddid}: stored e(N_outer_split) must be a finite integer >= stored e(N) for current nofirst results"
di as error " Current postestimation guidance refuses to advertise malformed nofirst outer-split provenance before ancillary seed()/alpha()/nboot() checks."
exit 498
}
}
capture confirm matrix e(N_per_fold)
local _has_n_per_fold_fast = (_rc == 0)
if `_has_n_per_fold_fast' {
capture confirm scalar e(k)
local _has_k_fast = (_rc == 0)
capture confirm scalar e(N)
local _has_n_retained_fast = (_rc == 0)
if `_has_k_fast' {
local _k_fast = e(k)
tempname _N_per_fold_fast
matrix `_N_per_fold_fast' = e(N_per_fold)
if rowsof(`_N_per_fold_fast') != 1 | ///
colsof(`_N_per_fold_fast') != `_k_fast' {
di as error "{bf:hddid}: stored e(N_per_fold) must be a 1 x k rowvector"
di as error " Current postestimation guidance refuses to advertise malformed retained fold-count metadata before ancillary seed()/alpha()/nboot() checks."
exit 498
}
local _N_per_fold_sum_fast = 0
forvalues _kk = 1/`_k_fast' {
local _N_per_fold_val_fast = ///
`_N_per_fold_fast'[1, `_kk']
if missing(`_N_per_fold_val_fast') | ///
`_N_per_fold_val_fast' < 1 | ///
`_N_per_fold_val_fast' != ///
floor(`_N_per_fold_val_fast') {
di as error "{bf:hddid}: stored e(N_per_fold) entries must be finite integers >= 1"
di as error " Current postestimation guidance refuses to advertise malformed retained fold-count metadata before ancillary seed()/alpha()/nboot() checks."
exit 498
}
local _N_per_fold_sum_fast = ///
`_N_per_fold_sum_fast' + ///
`_N_per_fold_val_fast'
}
if `_has_n_retained_fast' {
local _n_retained_fast = e(N)
if !missing(`_n_retained_fast') & ///
`_N_per_fold_sum_fast' != `_n_retained_fast' {
di as error "{bf:hddid}: stored e(N_per_fold) must sum to stored e(N)"
di as error " Current postestimation guidance refuses to advertise malformed retained fold-count metadata before ancillary seed()/alpha()/nboot() checks."
exit 498
}
}
}
}
}
local _cmdline = `"`e(cmdline)'"'
local _cmdline_probe = strtrim(`"`_cmdline'"')
local _cmdline_has_seed 0
local _cmdline_has_alpha 0
local _cmdline_has_nboot 0
local _cmdline_has_method 0
local _cmdline_method ""
local _cmdline_has_q 0
local _cmdline_q_value .
local _cmdline_seed_value .
local _cmdline_alpha_value .
local _cmdline_nboot_value .
local _ciuniform_zero_shortcut 0
capture confirm matrix e(tc)
local _hddid_has_tc_shortcut = (_rc == 0)
capture confirm matrix e(gdebias)
local _hddid_has_gdebias_shortcut = (_rc == 0)
capture confirm matrix e(stdg)
local _hddid_has_stdg_shortcut = (_rc == 0)
capture confirm matrix e(CIuniform)
local _hddid_has_ciuniform_shortcut = (_rc == 0)
if `_hddid_has_tc_shortcut' & `_hddid_has_gdebias_shortcut' & ///
`_hddid_has_stdg_shortcut' & `_hddid_has_ciuniform_shortcut' {
tempname _hddid_shortcut_tc _hddid_shortcut_stdgmax _hddid_shortcut_gap _hddid_shortcut_scale _hddid_shortcut_tol
matrix `_hddid_shortcut_tc' = e(tc)
mata: st_numscalar("`_hddid_shortcut_stdgmax'", max(abs(st_matrix("e(stdg)"))))
mata: _hddid_shortcut_ciu = st_matrix("e(gdebias)") \ st_matrix("e(gdebias)")
mata: st_numscalar("`_hddid_shortcut_gap'", max(abs(st_matrix("e(CIuniform)") :- _hddid_shortcut_ciu)))
mata: st_numscalar("`_hddid_shortcut_scale'", max((1, max(abs(st_matrix("e(CIuniform)"))), max(abs(_hddid_shortcut_ciu)))))
scalar `_hddid_shortcut_tol' = 1e-12 * scalar(`_hddid_shortcut_scale')
local _hddid_shortcut_tc_shape_ok = ///
(rowsof(`_hddid_shortcut_tc') == 1 & colsof(`_hddid_shortcut_tc') == 2)
local _hddid_shortcut_tc_zero_ok = ///
(abs(`_hddid_shortcut_tc'[1,1]) <= scalar(`_hddid_shortcut_tol') & ///
abs(`_hddid_shortcut_tc'[1,2]) <= scalar(`_hddid_shortcut_tol'))
local _hddid_shortcut_surface_zero_ok = ///
(scalar(`_hddid_shortcut_stdgmax') <= scalar(`_hddid_shortcut_tol') & ///
scalar(`_hddid_shortcut_gap') <= scalar(`_hddid_shortcut_tol'))
if `_hddid_shortcut_tc_shape_ok' & `_hddid_shortcut_tc_zero_ok' & ///
`_hddid_shortcut_surface_zero_ok' {
local _ciuniform_zero_shortcut 1
}
}
local _tc_zero_shortcut = `_ciuniform_zero_shortcut'
if `_current_result_surface' & `"`_firststage_mode'"' != "" & ///
`"`_cmdline_probe'"' != "" {
local _cmdline_parse = `"`_cmdline'"'
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(9), " ", .)
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(10), " ", .)
local _cmdline_parse = ///
subinstr(`"`_cmdline_parse'"', char(13), " ", .)
local _cmdline_opts = ""
local _cmdline_lc = lower(`"`_cmdline_parse'"')
local _cmdline_comma = strpos(`"`_cmdline_lc'"', ",")
if `_cmdline_comma' > 0 {
local _cmdline_opts = ///
strtrim(substr(`"`_cmdline_lc'"', `_cmdline_comma' + 1, .))
}
local _cmdline_depvar = ""
if regexm(`"`_cmdline_lc'"', "^[ ]*hddid[ ]+([^, ]+)") {
local _cmdline_depvar = strtrim(regexs(1))
}
local _cmdline_treat_head ///
"(^tr(e(a(t)?)?)?[(])|([ ,]tr(e(a(t)?)?)?[(])"
local _cmdline_treat_token ///
"(^tr(e(a(t)?)?)?[(][^)]*[)])|([ ,]tr(e(a(t)?)?)?[(][^)]*[)])"
local _cmd_has_roles = ///
regexm(`"`_cmdline_opts'"', `"`_cmdline_treat_head'"') & ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])x[(]") & ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])z[(]")
local _cmdline_dup_role_opts = 0
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', `"`_cmdline_treat_token'"') {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
`"`_cmdline_treat_token'"', " ")
if regexm(`"`_cmdline_role_probe'"', `"`_cmdline_treat_head'"') {
local _cmdline_dup_role_opts = 1
}
}
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])x[(][^)]*[)]") {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
"(^|[ ,])x[(][^)]*[)]", " ")
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])x[(]") {
local _cmdline_dup_role_opts = 1
}
}
local _cmdline_role_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])z[(][^)]*[)]") {
local _cmdline_role_probe = ///
regexr(`"`_cmdline_role_probe'"', ///
"(^|[ ,])z[(][^)]*[)]", " ")
if regexm(`"`_cmdline_role_probe'"', "(^|[ ,])z[(]") {
local _cmdline_dup_role_opts = 1
}
}
if `_cmdline_dup_role_opts' {
di as error "{bf:hddid}: stored e(cmdline) must encode each treat()/x()/z() role option at most once"
di as error " Current postestimation guidance found duplicated role provenance in {bf:e(cmdline)} = {bf:`_cmdline'}"
exit 498
}
if `"`_cmdline_depvar'"' == "" | `_cmd_has_roles' == 0 {
local _published_xcoords_ok 0
quietly _hddid_current_beta_coords
local _published_xcoords `"`r(coords)'"'
if `"`_published_xcoords'"' != "" {
local _published_xcoords_ok 1
}
local _stored_role_bundle_ok = ///
(`"`_depvar_role'"' != "" & ///
strtrim(`"`e(treat)'"') != "" & ///
(strtrim(`"`e(xvars)'"') != "" | `_published_xcoords_ok') & ///
strtrim(`"`e(zvar)'"') != "")
if `_stored_role_bundle_ok' == 0 {
di as error "{bf:hddid}: stored e(cmdline) must include depvar plus treat()/x()/z() role provenance"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'}"
di as error " Reason: the successful-call record can omit role text only when the published role metadata already remain complete in {bf:e(depvar_role)}, {bf:e(treat)}, and {bf:e(zvar)}, and when the beta-coordinate order still remains recoverable from machine-readable {bf:e(xvars)} or the published beta-surface labels."
exit 498
}
}
local _cmdline_has_nofirst = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])nof(i(r(s(t)?)?)?)?([ ,]|$)")
local _cmdline_has_seed = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])seed[(][ ]*[^)]*[)]")
local _cmdline_has_alpha = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])alpha[(][ ]*[^)]*[)]")
local _cmdline_has_nboot = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])nboot[(][ ]*[^)]*[)]")
if regexm(`"`_cmdline_opts'"', "(^|[ ,])method[(][ ]*([^)]*)[ ]*[)]") {
local _cmdline_has_method = 1
local _cmdline_method = strtrim(regexs(2))
if strlen(`"`_cmdline_method'"') >= 2 {
local _cmdline_method_first = substr(`"`_cmdline_method'"', 1, 1)
local _cmdline_method_last = substr(`"`_cmdline_method'"', -1, 1)
if (`"`_cmdline_method_first'"' == `"""' & ///
`"`_cmdline_method_last'"' == `"""') | ///
(`"`_cmdline_method_first'"' == "'" & ///
`"`_cmdline_method_last'"' == "'") {
local _cmdline_method = substr(`"`_cmdline_method'"', 2, ///
strlen(`"`_cmdline_method'"') - 2)
}
}
local _cmdline_method = strproper(strtrim(`"`_cmdline_method'"'))
}
if regexm(`"`_cmdline_opts'"', "(^|[ ,])q[(][ ]*([0-9]+)[ ]*[)]") {
local _cmdline_has_q = 1
local _cmdline_q_value = real(regexs(2))
}
local _cmdline_dup_seed = 0
local _cmdline_dup_alpha = 0
local _cmdline_dup_nboot = 0
local _cmdline_scalar_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])seed[(][^)]*[)]") {
local _cmdline_scalar_probe = ///
regexr(`"`_cmdline_scalar_probe'"', ///
"(^|[ ,])seed[(][^)]*[)]", " ")
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])seed[(]") {
local _cmdline_dup_seed = 1
}
}
local _cmdline_scalar_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])alpha[(][^)]*[)]") {
local _cmdline_scalar_probe = ///
regexr(`"`_cmdline_scalar_probe'"', ///
"(^|[ ,])alpha[(][^)]*[)]", " ")
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])alpha[(]") {
local _cmdline_dup_alpha = 1
}
}
local _cmdline_scalar_probe `"`_cmdline_opts'"'
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])nboot[(][^)]*[)]") {
local _cmdline_scalar_probe = ///
regexr(`"`_cmdline_scalar_probe'"', ///
"(^|[ ,])nboot[(][^)]*[)]", " ")
if regexm(`"`_cmdline_scalar_probe'"', "(^|[ ,])nboot[(]") {
local _cmdline_dup_nboot = 1
}
}
local _cmdline_seed_arg ""
local _cmdline_seed_value = .
local _cmdline_seed_ok = 0
local _cmdline_seed_suppressed = 0
if regexm(`"`_cmdline_opts'"', "(^|[ ,])seed[(][ ]*([^)]*)[ ]*[)]") {
local _cmdline_seed_arg = strtrim(regexs(2))
capture confirm number `_cmdline_seed_arg'
if _rc == 0 {
local _cmdline_seed_value = real(`"`_cmdline_seed_arg'"')
if !missing(`_cmdline_seed_value') & ///
`_cmdline_seed_value' == floor(`_cmdline_seed_value') & ///
`_cmdline_seed_value' == -1 {
local _cmdline_seed_ok = 1
local _cmdline_seed_suppressed = 1
}
else if !missing(`_cmdline_seed_value') & ///
`_cmdline_seed_value' == floor(`_cmdline_seed_value') & ///
`_cmdline_seed_value' >= 0 & ///
`_cmdline_seed_value' <= 2147483647 {
local _cmdline_seed_ok = 1
}
}
}
local _cmdline_alpha_arg ""
local _cmdline_alpha_value = .
local _cmdline_alpha_ok = 0
if regexm(`"`_cmdline_opts'"', "(^|[ ,])alpha[(][ ]*([^)]*)[ ]*[)]") {
local _cmdline_alpha_arg = strtrim(regexs(2))
if regexm(`"`_cmdline_alpha_arg'"', ///
"^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?$") {
local _cmdline_alpha_value = real(`"`_cmdline_alpha_arg'"')
if !missing(`_cmdline_alpha_value') & ///
`_cmdline_alpha_value' > 0 & ///
`_cmdline_alpha_value' < 1 {
local _cmdline_alpha_ok = 1
}
}
}
local _cmdline_nboot_arg ""
local _cmdline_nboot_value = .
local _cmdline_nboot_ok = 0
if regexm(`"`_cmdline_opts'"', "(^|[ ,])nboot[(][ ]*([^)]*)[ ]*[)]") {
local _cmdline_nboot_arg = strtrim(regexs(2))
if regexm(`"`_cmdline_nboot_arg'"', "^[+]?[0-9]+$") {
local _cmdline_nboot_value = real(`"`_cmdline_nboot_arg'"')
if !missing(`_cmdline_nboot_value') & ///
`_cmdline_nboot_value' >= 2 {
local _cmdline_nboot_ok = 1
}
}
}
local _mode_says_nofirst = (`"`_firststage_mode'"' == "nofirst")
if `_cmdline_has_nofirst' != `_mode_says_nofirst' {
di as error "{bf:hddid}: stored e(firststage_mode) must agree with whether e(cmdline) uses nofirst"
di as error " Postestimation found e(firststage_mode) = {bf:`_firststage_mode'} but e(cmdline) = {bf:`_cmdline'}"
exit 498
}
if `_cmdline_has_seed' & `_cmdline_dup_seed' {
di as error "{bf:hddid}: stored e(cmdline) must encode seed() provenance at most once"
di as error " Current postestimation guidance found duplicated {bf:seed()} provenance in {bf:e(cmdline)} = {bf:`_cmdline'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still publish one atomic RNG provenance record for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish one atomic RNG provenance record for the realized bootstrap path."
}
exit 498
}
if `_cmdline_has_seed' & `_cmdline_seed_ok' == 0 {
di as error "{bf:hddid}: stored e(cmdline) seed() provenance must be a finite integer in [0, 2147483647]"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} with malformed explicit {bf:seed()} provenance: {bf:`_cmdline_seed_arg'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still reconcile explicit {bf:seed()} across the successful-call record and machine-readable {bf:e(seed)} for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish RNG provenance through both the successful-call record and the machine-readable {bf:e(seed)} scalar behind the realized bootstrap path."
}
exit 498
}
capture confirm scalar e(seed)
if _rc == 0 {
local _stored_seed = e(seed)
if missing(`_stored_seed') | `_stored_seed' < 0 | ///
`_stored_seed' > 2147483647 | ///
`_stored_seed' != floor(`_stored_seed') {
di as error "{bf:hddid}: stored e(seed) must be a finite integer in [0, 2147483647]"
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid postestimation guidance still requires finite stored {bf:e(seed)} as machine-readable current-surface RNG metadata."
di as error " That metadata still pins the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Current postestimation guidance refuses to advertise malformed RNG provenance metadata."
}
exit 498
}
}
if `_cmdline_has_seed' & !`_cmdline_seed_suppressed' & _rc != 0 {
di as error "{bf:hddid}: current results with stored e(cmdline) seed() provenance require stored e(seed)"
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid postestimation guidance treats an explicit seed() as part of the machine-readable provenance for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid postestimation guidance treats an explicit seed() as part of the machine-readable bootstrap/RNG provenance behind the posted e(tc) and e(CIuniform) objects."
}
exit 498
}
if `_cmdline_has_seed' & `_cmdline_seed_suppressed' & _rc == 0 {
local _stored_seed = e(seed)
di as error "{bf:hddid}: stored e(cmdline) seed(-1) provenance forbids stored e(seed)"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} but stored {bf:e(seed)} = {bf:`_stored_seed'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, {bf:seed(-1)} is still the published no-reset sentinel, so current postestimation refuses a saved-results surface that simultaneously posts suppressed provenance and machine-readable metadata for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: {bf:seed(-1)} is the published no-reset sentinel, so current postestimation refuses a saved-results surface that simultaneously posts suppressed and realized RNG provenance."
}
exit 498
}
if `_cmdline_has_seed' & !`_cmdline_seed_suppressed' & _rc == 0 & !missing(`_cmdline_seed_value') {
local _stored_seed = e(seed)
if `_stored_seed' != `_cmdline_seed_value' {
di as error "{bf:hddid}: current results with stored e(cmdline) seed() provenance require stored e(seed) to match"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} but stored {bf:e(seed)} = {bf:`_stored_seed'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still publish RNG provenance through both the successful-call record and the machine-readable {bf:e(seed)} scalar for the realized outer fold assignment and Python CLIME CV splitting."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish RNG provenance through both the successful-call record and the machine-readable {bf:e(seed)} scalar behind the realized bootstrap path."
}
exit 498
}
}
if `_cmdline_has_alpha' & `_cmdline_dup_alpha' {
di as error "{bf:hddid}: stored e(cmdline) must encode alpha() provenance at most once"
di as error " Current postestimation guidance found duplicated {bf:alpha()} provenance in {bf:e(cmdline)} = {bf:`_cmdline'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on this degenerate zero-SE shortcut, current hddid results still publish one atomic shared {bf:e(alpha)} scalar that calibrates the analytic {bf:e(CIpoint)} pointwise intervals."
di as error " It does not recalibrate the collapsed {bf:e(CIuniform)} object because that published nonparametric interval object already equals {bf:e(gdebias)}."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish one atomic shared significance level behind the realized {bf:e(CIpoint)} object, and the same significance level also calibrates the realized {bf:e(tc)}/{bf:e(CIuniform)} bootstrap interval object."
}
exit 498
}
if `_cmdline_has_alpha' & `_cmdline_alpha_ok' == 0 {
di as error "{bf:hddid}: stored e(cmdline) alpha() provenance must be a finite scalar in (0, 1)"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} with malformed shared significance-level provenance in explicit {bf:alpha()}: {bf:`_cmdline_alpha_arg'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on this degenerate zero-SE shortcut, current hddid results still require the shared {bf:e(alpha)} scalar that calibrates the analytic {bf:e(CIpoint)} pointwise intervals."
di as error " It does not recalibrate the collapsed {bf:e(CIuniform)} object because that published nonparametric interval object already equals {bf:e(gdebias)}."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish the shared significance level through both the successful-call record and the machine-readable {bf:e(alpha)} scalar behind the realized {bf:e(CIpoint)} object, and the same {bf:e(alpha)} scalar also calibrates the realized {bf:e(tc)}/{bf:e(CIuniform)} bootstrap interval object."
}
exit 498
}
if `_cmdline_has_nboot' & `_cmdline_dup_nboot' {
di as error "{bf:hddid}: stored e(cmdline) must encode nboot() provenance at most once"
di as error " Current postestimation guidance found duplicated {bf:nboot()} provenance in {bf:e(cmdline)} = {bf:`_cmdline'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still publish one atomic {bf:nboot()} configuration record for the current saved-results surface."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish one atomic Gaussian-bootstrap replication count behind the realized {bf:e(tc)} / {bf:e(CIuniform)} path."
}
exit 498
}
if `_cmdline_has_nboot' & `_cmdline_nboot_ok' == 0 {
di as error "{bf:hddid}: stored e(cmdline) nboot() provenance must be an integer >= 2"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} with malformed explicit {bf:nboot()} provenance: {bf:`_cmdline_nboot_arg'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still reconcile {bf:nboot()} across the successful-call record and machine-readable {bf:e(nboot)} as configuration metadata."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish bootstrap replication-count provenance through both the successful-call record and the machine-readable {bf:e(nboot)} scalar behind the realized {bf:e(tc)} / {bf:e(CIuniform)} path."
}
exit 498
}
capture confirm scalar e(nboot)
if `_cmdline_has_nboot' & _rc != 0 & !missing(`_cmdline_nboot_value') {
di as error "{bf:hddid}: current results with stored e(cmdline) nboot() provenance require stored e(nboot)"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} but no machine-readable {bf:e(nboot)}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still reconcile {bf:nboot()} across the successful-call record and machine-readable {bf:e(nboot)} as configuration metadata."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish bootstrap replication-count provenance through both the successful-call record and the machine-readable {bf:e(nboot)} scalar behind the realized {bf:e(tc)} / {bf:e(CIuniform)} path."
}
exit 498
}
if `_cmdline_has_nboot' & _rc == 0 & !missing(`_cmdline_nboot_value') {
local _stored_nboot = e(nboot)
if `_stored_nboot' != `_cmdline_nboot_value' {
di as error "{bf:hddid}: current results with stored e(cmdline) nboot() provenance require stored e(nboot) to match"
di as error " Current postestimation guidance found {bf:e(cmdline)} = {bf:`_cmdline'} but stored {bf:e(nboot)} = {bf:`_stored_nboot'}."
if `_ciuniform_zero_shortcut' {
di as error " Reason: on the degenerate zero-SE shortcut, current hddid results still reconcile {bf:nboot()} across the successful-call record and machine-readable {bf:e(nboot)} as configuration metadata."
di as error " No studentized Gaussian-bootstrap draws were used for the published nonparametric interval object."
}
else {
di as error " Reason: current hddid results publish bootstrap replication-count provenance through both the successful-call record and the machine-readable {bf:e(nboot)} scalar behind the realized {bf:e(tc)} / {bf:e(CIuniform)} path."
}
exit 498
}
}
local _cmdline_has_method = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])method[(][ ]*[^)]*[)]")
local _cmdline_has_q = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])q[(][ ]*[^)]*[)]")
local _cmdline_has_method_assign = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])method[ ]*=")
local _cmdline_has_q_assign = ///
regexm(`"`_cmdline_opts'"', "(^|[ ,])q[ ]*=")
local _cmdline_dup_method = 0
local _cmdline_dup_q = 0
local _cmdline_method_arg ""
local _cmdline_method ""
local _cmdline_method_ok = 0
local _cmdline_q_arg ""
local _cmdline_q_value = .
local _cmdline_q_ok = 0
if `_cmdline_has_method_assign' | `_cmdline_has_q_assign' {
local _cmdline_assign_parts ""