|
1 | | -*! boottest 4.4.11 12 April 2024 |
2 | | -*! Copyright (C) 2015-24 David Roodman |
| 1 | +*! boottest 4.4.12 15 January 2025 |
| 2 | +*! Copyright (C) 2015-25 David Roodman |
3 | 3 |
|
4 | 4 | * This program is free software: you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
@@ -151,15 +151,25 @@ program define _boottest, rclass sortpreserve |
151 | 151 | } |
152 | 152 |
|
153 | 153 | local margins = "`margins'" != "" |
154 | | - if `margins' & `"`h0s'`h0'"' != "" { |
155 | | - di as err "Include the {cmd:margins} option or state null hyptheses, but don't do both." |
156 | | - exit 198 |
157 | | - } |
158 | | - if `margins' & "`r(predict1_label)'" != "Linear prediction" { |
159 | | - di as err _n "{cmd:margins} option only works with linear margins predictions such as average predictions after {cmd:regress}." |
160 | | - exit 198 |
| 154 | + if `margins' { |
| 155 | + if `"`h0s'`h0'"' != "" { |
| 156 | + di as err "Include the {cmd:margins} option or state null hyptheses, but don't do both." |
| 157 | + exit 198 |
| 158 | + } |
| 159 | + if "`r(predict1_label)'" != "Linear prediction" { |
| 160 | + di as err _n "{cmd:margins} option only works with linear margins predictions such as average predictions after {cmd:regress}." |
| 161 | + exit 198 |
| 162 | + } |
| 163 | + if strlen("`r(Jacobian)'") { |
| 164 | + tempname rJacobian |
| 165 | + mat `rJacobian' = r(Jacobian) |
| 166 | + } |
| 167 | + else { |
| 168 | + di as err "{cmd:margins} results not found." |
| 169 | + error 303 |
| 170 | + } |
161 | 171 | } |
162 | | - |
| 172 | +
|
163 | 173 | if inlist("`e(cmd)'", "didregress", "xtdidregress") & `"`h0s'`h0'"' == "" local h0s r1vs0.`e(treatment)' |
164 | 174 |
|
165 | 175 | if `matsizegb'==1000000 local matsizegb . |
@@ -396,25 +406,18 @@ program define _boottest, rclass sortpreserve |
396 | 406 | local anythingh0 1 |
397 | 407 | } |
398 | 408 | else if `margins' { |
399 | | - if strlen("`r(Jacobian)'") { |
400 | | - mata _boottestp = selectindex(rowsum(st_matrix("r(Jacobian)"):!=0)) // skip all-zero rows |
401 | | - mata st_local("marginsnames", invtokens(st_matrixrowstripe("r(Jacobian)")[_boottestp,2]')) |
402 | | - mata st_matrix("`marginsH0'", st_matrix("r(Jacobian)")[_boottestp,]) |
403 | | - mata st_local("N_h0s", strofreal(length(_boottestp))) |
404 | | - if `N_h0s'==0 { |
405 | | - di as err "No valid {cmd:margins} results not found." |
406 | | - error 303 |
407 | | - } |
408 | | - scalar `df' = 1 // always when working with margins results, df = 1 and constant term = 0 |
409 | | - mat `r' = 0 |
410 | | - |
411 | | - local 0 r(cmdline) |
412 | | - marksample marginstouse, strok |
413 | | - } |
414 | | - else { |
415 | | - di as err "{cmd:margins} results not found." |
| 409 | + mata _boottestp = selectindex(rowsum(st_matrix("`rJacobian'"):!=0)) // skip all-zero rows |
| 410 | + mata st_local("marginsnames", invtokens(st_matrixrowstripe("`rJacobian'")[_boottestp,2]')) |
| 411 | + mata st_matrix("`marginsH0'", st_matrix("`rJacobian'")[_boottestp,]) |
| 412 | + mata st_local("N_h0s", strofreal(length(_boottestp))) |
| 413 | + if `N_h0s'==0 { |
| 414 | + di as err "No valid {cmd:margins} results not found." |
416 | 415 | error 303 |
417 | 416 | } |
| 417 | + scalar `df' = 1 // always when working with margins results, df = 1 and constant term = 0 |
| 418 | + mat `r' = 0 |
| 419 | + |
| 420 | + marksample marginstouse, strok |
418 | 421 | } |
419 | 422 | else { |
420 | 423 | local N_h0s 1 // number of nulls |
@@ -1105,6 +1108,7 @@ end |
1105 | 1108 |
|
1106 | 1109 |
|
1107 | 1110 | * Version history |
| 1111 | +* 4.4.12 Fixed crash on boottest, margins after areg |
1108 | 1112 | * 4.4.11 Change formula for bounds search start in ARubin to prevent missings. Updated jl usage. |
1109 | 1113 | * 4.4.10 Fixed crash after latest versions of *reghdfe* |
1110 | 1114 | * 4.4.9 Added jl SetEnv call to create private Julia package environment |
|
0 commit comments