Skip to content

Commit 84f6463

Browse files
committed
Use :copy where possible
1 parent 65ebb03 commit 84f6463

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

boottest.ado

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ program define _boottest, rclass sortpreserve
124124
exit 198
125125
}
126126
parse "`r(version)'", parse(".")
127-
local v1 `1'
128-
local v2 `3'
129-
local v3 `5'
127+
local v1: copy local 1
128+
local v2: copy local 3
129+
local v3: copy local 5
130130
parse "`JLVERSION'", parse(".")
131131
if `v1'<`1' | `v1'==`1' & `v2'<`3' | `v1'==`1' & `v2'==`3' & `v3'<`5' {
132132
di as txt "The Stata package {cmd:julia} is not up to date. Attempting to update it with {stata ssc install julia, replace}." _n
@@ -171,7 +171,7 @@ program define _boottest, rclass sortpreserve
171171
di as err "option " as res "svmat(" `svmat' ")" as err " not allowed."
172172
error 198
173173
}
174-
if "`svmat'" == "" local svmat `_svmat'
174+
if "`svmat'" == "" local svmat: copy local _svmat
175175
}
176176
177177
if `"`options'"' != "" {
@@ -190,7 +190,7 @@ program define _boottest, rclass sortpreserve
190190
local madjust `bonferroni'`sidak'
191191
192192
if `"`graphname'"' != "" {
193-
local 0 `graphname'
193+
local 0: copy local graphname
194194
syntax [anything(name=graphname)], [replace]
195195
}
196196
else local graphname Graph
@@ -225,7 +225,7 @@ program define _boottest, rclass sortpreserve
225225
226226
if `"`robust'`cluster'"' != "" {
227227
local hasrobust 1
228-
local clustvars `cluster'
228+
local clustvars: copy local cluster
229229
if `"`clustvars'"'!="" confirm var `clustvars'
230230
local override 1
231231
di as txt _n "Overriding estimator's cluster/robust settings with " as res `"`=cond("`clustvars'"=="", "robust", "cluster(`clustvars')")'"'
@@ -340,7 +340,7 @@ program define _boottest, rclass sortpreserve
340340
tempvar FEname
341341
qui egen long `FEname' = group(`_FEname') if e(sample)
342342
}
343-
else local FEname `_FEname'
343+
else local FEname: copy local _FEname
344344
}
345345

346346
if "`cmd'" == "xtreg" {
@@ -350,7 +350,7 @@ program define _boottest, rclass sortpreserve
350350
}
351351
else if inlist("`cmd'","xtivreg","xtivreg2","xtdidregress") local FEdfadj 0
352352
else if inlist("`cmd'", "reghdfe", "ivreghdfe") local FEdfadj = max(1, e(df_a))
353-
else local FEdfadj `NFE'
353+
else local FEdfadj: copy local NFE
354354

355355
if `"`seed'"'!="" set seed `seed'
356356

@@ -364,7 +364,7 @@ program define _boottest, rclass sortpreserve
364364
qui gen double `wtname' `e(wexp)'
365365
}
366366
else if c(varabbrev)=="on" unab wtname: `2'
367-
else local wtname `2'
367+
else local wtname: copy local 2
368368
}
369369

370370
if `"`h0s'"' != "" {
@@ -423,7 +423,7 @@ program define _boottest, rclass sortpreserve
423423
if `"`: constraint `c''"' == "" di as res "Constraint `c' not found and will be skipped."
424424
}
425425
}
426-
local h0_1 `h0'
426+
local h0_1: copy local h0
427427
}
428428

429429
if `N_h0s'==1 local madjust
@@ -477,7 +477,7 @@ program define _boottest, rclass sortpreserve
477477
}
478478
}
479479
else {
480-
local Xnames_exog `colnames'
480+
local Xnames_exog: copy local colnames
481481
if inlist("`e(cmd)'", "didregress", "xtdidregress") local Xnames_exog: subinstr local Xnames_exog "r1vs0." ""
482482
}
483483

@@ -503,7 +503,7 @@ program define _boottest, rclass sortpreserve
503503
}
504504
}
505505
}
506-
local `varlist' `_revarlist'
506+
local `varlist': copy local _revarlist
507507
}
508508
mata _boottestkeepC = st_matrix("`keepC'"); _boottestp = cols(_boottestkeepC)? _boottestp[_boottestkeepC] : J(0,1,0)
509509

@@ -528,7 +528,7 @@ program define _boottest, rclass sortpreserve
528528
}
529529

530530
if `"`bootcluster'"' == "" {
531-
local bootcluster `clustvars'
531+
local bootcluster: copy local clustvars
532532
if `reps' & `NErrClustVar'>1 di as txt "({cmdab:bootcl:uster(`clustvars')} assumed)"
533533
}
534534
local clustvars `:list clustvars & bootcluster' `:list clustvars - bootcluster'
@@ -544,7 +544,7 @@ program define _boottest, rclass sortpreserve
544544
}
545545
else local _allclustvars `_allclustvars' `clustvar'
546546
}
547-
local allclustvars `_allclustvars'
547+
local allclustvars: copy local _allclustvars
548548
}
549549
local NBootClustVar: word count `bootcluster'
550550

@@ -668,7 +668,7 @@ program define _boottest, rclass sortpreserve
668668
_parse expand lc lg: cmdline, common(CONSTraints(passthru) from(passthru) INIt(passthru) ITERate(passthru) Robust) // would be nice to extract, thus remove, cluster() option for speed, but it affects sample
669669
local 0, `lg_op'
670670
syntax, [from(passthru) INIt(passthru) ITERate(passthru) *]
671-
local 0 `lc_1'
671+
local 0: copy local lc_1
672672
syntax [anything] [aw pw fw iw] [if] [in], [*]
673673

674674
if "`e(cmd)'"=="ml" local max max // tack on max option in case ml run in interactive model and cmdline() is missing it
@@ -762,7 +762,7 @@ program define _boottest, rclass sortpreserve
762762
qui forvalues i=1/`k' {
763763
if "``i''" != "`lasteq'" | "``i''"=="/" {
764764
local ++eq
765-
local lasteq ``i''
765+
local lasteq: copy local `i'
766766
}
767767
local var: word `i' of `colnames'
768768
if "`var'"=="_cons" | strmatch("`var'","*._cons") | "``i''"=="/" local _sc `_sc' `:word `eq' of `scnames'' // constant term or free parameter
@@ -772,7 +772,7 @@ program define _boottest, rclass sortpreserve
772772
local _sc `_sc' `t'
773773
}
774774
}
775-
local scnames `_sc'
775+
local scnames: copy local _sc
776776
}
777777
}
778778

@@ -808,9 +808,9 @@ program define _boottest, rclass sortpreserve
808808
if `margins' {
809809
cap drop `touse'
810810
gen byte `touse' = `hold' & `marginstouse'
811-
local sample `touse'
811+
local sample: copy local touse
812812
}
813-
else local sample `hold'
813+
else local sample: copy local hold
814814

815815
return local seed = cond("`seed'"!="", "`seed'", "`c(seed)'")
816816

@@ -1072,7 +1072,7 @@ program define _boottest, rclass sortpreserve
10721072
mat colnames `cimat' = lo hi
10731073
cap mat rownames `cimat' = `h0text'
10741074
return matrix CI`_h' = `cimat'
1075-
return local CIstr`_h' `CIstr'
1075+
return local CIstr`_h': copy local CIstr
10761076
}
10771077

10781078
if "`statistic'"=="c" & `df'==1 {
@@ -1091,10 +1091,10 @@ program define _boottest, rclass sortpreserve
10911091
cap mat_put_rr `C' // can fail in boottest, margins
10921092
return scalar level = `level'
10931093
return scalar ptol = `ptolerance'
1094-
return local statistic `statistic'
1095-
return local weighttype `weighttype'
1096-
return local boottype `boottype'
1097-
return local clustvars `clustvars'
1094+
return local statistic: copy local statistic
1095+
return local weighttype: copy local weighttype
1096+
return local boottype: copy local boottype
1097+
return local clustvars: copy local clustvars
10981098
return scalar null = `null'
10991099
return scalar reps = `repsname'
11001100
return scalar NH0s = `N_h0s'

unit tests.log

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,9 +1479,7 @@ Wild bootstrap-t, null not imposed, 999 replications, Wald test, bootstrap clust
14791479
Prob>|t| = 0.3894
14801480

14811481
95% confidence set for null hypothesis expression: [−.09375, .2381]
1482-
The Julia package StableRNGs is not installed and up-to-date. Attempting to update it. This could take a few minutes.
1483-
1484-
The Julia package WildBootTests is not installed and up-to-date. Attempting to update it. This could take a few minutes.
1482+
The Julia package DataFrames is not installed and up-to-date. Attempting to update it. This could take a few minutes.
14851483

14861484

14871485
Warning: with 8 bootstrap clusters, the number of replications, 999, exceeds the universe of Rademacher draws, 2^8 = 256. Sampling each once.

0 commit comments

Comments
 (0)