Skip to content

Commit

Permalink
Correct dof when constraints include restrictions on o. and b. regres…
Browse files Browse the repository at this point in the history
…sors
  • Loading branch information
droodman committed Apr 27, 2023
1 parent 551150c commit 469d1de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
28 changes: 14 additions & 14 deletions boottest.ado
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,20 @@ program define _boottest, rclass sortpreserve
if _rc exit 111
_estimates unhold `hold'
if r(k_autoCns) mat `C' = `C'[r(k_autoCns)+1...,1...]
scalar `df' = rowsof(`C')
mat `R' = `C'[1...,1..colsof(`C')-1]
mat `r' = `C'[1..., colsof(`C') ]

* get rid of any remaining o. and b. constraints; r(k_autoCns) doesn't capture all
mata _boottestC = st_matrixcolstripe("`R'")[,2]
mata _boottestC = rowsum(select(st_matrix("`R'"), !(strmatch(_boottestC, "*b*.*") :| strmatch(_boottestC, "*o*.*"))') :!= 0)
mata st_matrix("`R'", select(st_matrix("`R'"), _boottestC))
mata st_matrix("`r'", select(st_matrix("`r'"), _boottestC))
cap mat `R'[1,1] = `R'[1,1]
if _rc {
di as error _n "Null constraint applies only to omitted variables or base levels of factor variables."
continue
}
scalar `df' = rowsof(`R')
}

if 0`NFE' {
Expand Down Expand Up @@ -744,17 +755,6 @@ program define _boottest, rclass sortpreserve
mat `R1R' = `R' \ nullmat(`R1') // add null to model constraints
mat `r1r' = `r' \ nullmat(`r1')

* get rid of any remaining o. and b. constraints; r(k_autcns) doesn't capture all
mata _boottestC = st_matrixcolstripe("`R1R'")[,2]
mata _boottestC = rowsum(select(st_matrix("`R1R'"), !(strmatch(_boottestC, "*b*.*") :| strmatch(_boottestC, "*o*.*"))') :!= 0)
mata st_matrix("`R1R'", select(st_matrix("`R1R'"), _boottestC))
mata st_matrix("`r1r'", select(st_matrix("`r1r'"), _boottestC))
cap mat `R1R'[1,1] = `R1R'[1,1]
if _rc {
di as error _n "Null constraint applies only to omitted variables or base levels of factor variables."
continue
}

`quietly' di as res _n "Re-running regression with null imposed." _n
if `"`cmdline'"'=="" local 0 `e(cmdline)'
else local 0 `cmdline'
Expand Down Expand Up @@ -878,7 +878,7 @@ program define _boottest, rclass sortpreserve
else local sample `hold'

return local seed = cond("`seed'"!="", "`seed'", "`c(seed)'")
// noi matlist `R'

if !`julia' {
mata boottest_stata("`teststat'", "`df'", "`df_r'", "`p'", "`padj'", "`cimat'", "`plotmat'", "`peakmat'", `level', `ptolerance', ///
`ML', `LIML', 0`fuller', `K', `ar', `null', `scoreBS', `jk', "`weighttype'", "`ptype'", "`statistic'", ///
Expand Down Expand Up @@ -1187,8 +1187,8 @@ end


* Version history
* 4.4.4 Fix wrong scaling of test stat after non-robust ML with Rademacher, Webb, Mammen weights
* 4.4.3 Increase WildBootTests.jl version 0.9.0. Fixed bug in WRE jk test stat computation when clusters are many ("granular"). Changed ptol() default to 1e-3. Fixed computation bug in WRE with classical errors.
* Correct dof when constraints include restrictions on o. and b. regressors
* 4.4.2 Fixed wrong "robust" CI's after OLS
* 4.4.1 Fixed crash in AR test after over-ID'd regression; added mention of jackknifing to output
* 4.4.0 Minimized O(N) operations in non-jk WRE when clustering is coarse. Skip FE code in WRE if FE = cluster grouping. Bumped Julia version to 0.8.5.
Expand Down
22 changes: 11 additions & 11 deletions unit tests.log
Original file line number Diff line number Diff line change
Expand Up @@ -1149,15 +1149,15 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clusterin
tenure

t(11) = 0.8177
Prob>|t| = 0.4545
Prob>|t| = 0.4535

95% confidence set for null hypothesis expression: [−.02371, .06616]
95% confidence set for null hypothesis expression: [−.02484, .06616]

Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clustering by industry, Rademacher weights:
occupation

t(11) = 1.5398
Prob>|t| = 0.2162
Prob>|t| = 0.2152

95% confidence set for null hypothesis expression: (−∞, ∞)
(A confidence interval could not be bounded. Try widening the search range with the gridmin() and gridmax() options.)
Expand All @@ -1166,9 +1166,9 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clusterin
tenure

t(11) = 0.6068
Prob>|t| = 0.4785
Prob>|t| = 0.4775

95% confidence set for null hypothesis expression: [−.04893, .05472]
95% confidence set for null hypothesis expression: [−.04893, .05461]

Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clustering by industry, Rademacher weights:
collgrad tenure
Expand Down Expand Up @@ -1217,7 +1217,7 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, clustering by id ye
t(8) = 28.4248
Prob>|t| = 0.0000

95% confidence set for null hypothesis expression: [.7915, .9431]
95% confidence set for null hypothesis expression: [.7899, .9431]

Overriding estimator's cluster/robust settings with cluster(ccode pixcluster)

Expand All @@ -1227,7 +1227,7 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, clustering by ccode
t(48) = 3.5211
Prob>|t| = 0.0020

95% confidence set for null hypothesis expression: [.0591, .2528]
95% confidence set for null hypothesis expression: [.05866, .2528]

Overriding estimator's cluster/robust settings with cluster(ccode pixcluster)

Expand All @@ -1254,7 +1254,7 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clusterin
merit

t(41) = 6.7127
Prob>|t| = 0.4645
Prob>|t| = 0.4635

95% confidence set for null hypothesis expression: [−2.826, 1.31]

Expand All @@ -1270,9 +1270,9 @@ Wild bootstrap-t, null imposed, 999 replications, Wald test, bootstrap clusterin
merit

t(41) = 6.7127
Prob>|t| = 0.3103
Prob>|t| = 0.3113

95% confidence set for null hypothesis expression: [−5.388, 4.886]
95% confidence set for null hypothesis expression: [−5.392, 4.968]

Wild bootstrap-t, null not imposed, 999 replications, Wald test, bootstrap clustering by state year, Rademacher weights:
merit
Expand All @@ -1294,7 +1294,7 @@ Wild bootstrap-t, null not imposed, 999 replications, Wald test, bootstrap clust
merit

t(41) = 6.7127
Prob>|t| = 0.4114
Prob>|t| = 0.4094

95% confidence set for null hypothesis expression: [−.09893, .2433]

Expand Down

0 comments on commit 469d1de

Please sign in to comment.