11using LinearAlgebra: norm
2+ using Suppressor
23
34function is_extended_tests ()
45 return lowercase (get (ENV , " JULIA_EXTENDED_TESTS" , " false" )) == " true"
@@ -144,19 +145,23 @@ function test_bootstrap(
144145 compare_bs = true ,
145146 rtol_bs = 0.1 ,
146147 n_boot = 500 )
147- se_bs = se_bootstrap (model_fit, spec; n_boot = n_boot)
148- # hessian and bootstrap se are close
149- if compare_hessian
150- se_he = se_hessian (model_fit)
151- @test isapprox (se_bs, se_he, rtol = rtol_hessian)
152- end
153- # se_bootstrap and bootstrap |> se are close
154- if compare_bs
155- bs_samples = bootstrap (model_fit, spec; n_boot = n_boot)
156- @test bs_samples[:n_converged ] >= 0.95 * n_boot
157- bs_samples = cat (bs_samples[:samples ][BitVector (bs_samples[:converged ])]. .. , dims = 2 )
158- se_bs_2 = sqrt .(var (bs_samples, corrected = false , dims = 2 ))
159- @test isapprox (se_bs_2, se_bs, rtol = rtol_bs)
148+ @testset rng = Random. seed! (32432 ) " bootstrap" begin
149+ se_bs = @suppress se_bootstrap (model_fit, spec; n_boot = n_boot)
150+ # hessian and bootstrap se are close
151+ if compare_hessian
152+ se_he = @suppress se_hessian (model_fit)
153+ # println(maximum(abs.(se_he - se_bs)))
154+ @test isapprox (se_bs, se_he, rtol = rtol_hessian)
155+ end
156+ # se_bootstrap and bootstrap |> se are close
157+ if compare_bs
158+ bs_samples = bootstrap (model_fit, spec; n_boot = n_boot)
159+ @test bs_samples[:n_converged ] >= 0.95 * n_boot
160+ bs_samples = cat (bs_samples[:samples ][BitVector (bs_samples[:converged ])]. .. , dims = 2 )
161+ se_bs_2 = sqrt .(var (bs_samples, corrected = false , dims = 2 ))
162+ # println(maximum(abs.(se_bs_2 - se_bs)))
163+ @test isapprox (se_bs_2, se_bs, rtol = rtol_bs)
164+ end
160165 end
161166end
162167
@@ -168,7 +173,7 @@ function smoketest_bootstrap(model_fit, spec; n_boot = 5)
168173end
169174
170175function smoketest_CI_z (model_fit, partable)
171- se_he = se_hessian (model_fit)
176+ se_he = @suppress se_hessian (model_fit)
172177 normal_CI! (partable, model_fit, se_he)
173178 z_test! (partable, model_fit, se_he)
174179end
0 commit comments