Skip to content

Commit c27706d

Browse files
fix bootstrap tests
1 parent 5e5575b commit c27706d

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/frontend/fit/standard_errors/bootstrap.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Return bootstrap samples for `statistic`.
1919
- `n_boot`: number of boostrap samples
2020
- `data`: data to sample from. Only needed if different than the data from `sem_fit`
2121
- `specification`: a `ParameterTable` or `RAMMatrices` object passed to `replace_observed`.
22-
Necessary for FIML models.
22+
Necessary for FIML / WLS models.
2323
- `engine`: optimizer engine, passed to `fit`.
2424
- `parallel`: if `true`, run bootstrap samples in parallel on all available threads.
2525
The number of threads is controlled by the `JULIA_NUM_THREADS` environment variable or
@@ -143,7 +143,7 @@ Return bootstrap standard errors.
143143
- `n_boot`: number of boostrap samples
144144
- `data`: data to sample from. Only needed if different than the data from `sem_fit`
145145
- `specification`: a `ParameterTable` or `RAMMatrices` object passed to `replace_observed`.
146-
Necessary for FIML models.
146+
Necessary for FIML / WLS models.
147147
- `engine`: optimizer engine, passed to `fit`.
148148
- `parallel`: if `true`, run bootstrap samples in parallel on all available threads.
149149
The number of threads is controlled by the `JULIA_NUM_THREADS` environment variable or

test/examples/helper.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ function test_estimates(
136136
end
137137
end
138138

139-
function test_bootstrap(model_fit; n_boot = 500)
139+
function test_bootstrap(model_fit, spec; n_boot = 500)
140140
# hessian and bootstrap se are close
141141
se_he = se_hessian(model_fit)
142-
se_bs = se_bootstrap(model_fit; n_boot = n_boot)
142+
se_bs = se_bootstrap(model_fit; specification = spec, n_boot = n_boot)
143143
@test isapprox(se_bs, se_he, rtol = 0.2)
144144
# se_bootstrap and bootstrap |> se are close
145-
bs_samples = bootstrap(model_fit; n_boot = n_boot)
145+
bs_samples = bootstrap(model_fit; specification = spec, n_boot = n_boot)
146146
@test bs_samples[:n_converged] > 0.95*n_boot
147147
bs_samples = cat(bs_samples[:samples][BitVector(bs_samples[:converged])]..., dims = 2)
148148
se_bs_2 = sqrt.(var(bs_samples, corrected = false, dims = 2))

test/examples/multigroup/build_models.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ end
8383
lav_col = :se,
8484
lav_groups = Dict(:Pasteur => 1, :Grant_White => 2),
8585
)
86-
test_bootstrap(solution_ml)
86+
test_bootstrap(solution_ml, partable)
8787
smoketest_CI_z(solution_ml, partable)
8888

8989
solution_ml = fit(model_ml_multigroup2)
@@ -293,7 +293,7 @@ end
293293
lav_col = :se,
294294
lav_groups = Dict(:Pasteur => 1, :Grant_White => 2),
295295
)
296-
test_bootstrap(solution_ls)
296+
test_bootstrap(solution_ls, partable)
297297
smoketest_CI_z(solution_ls, partable)
298298
end
299299

@@ -412,7 +412,7 @@ if !isnothing(specification_miss_g1)
412412
lav_col = :se,
413413
lav_groups = Dict(:Pasteur => 1, :Grant_White => 2),
414414
)
415-
test_bootstrap(solution; n_boot = 500)
415+
test_bootstrap(solution, partable_miss)
416416
smoketest_CI_z(solution, partable_miss)
417417

418418
solution = fit(semoptimizer, model_ml_multigroup2)

test/examples/political_democracy/constructor.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ end
131131
lav_col = :se,
132132
)
133133

134-
test_bootstrap(solution_ml)
134+
test_bootstrap(solution_ml, partable)
135135
smoketest_CI_z(solution_ml, partable)
136136
end
137137

@@ -161,7 +161,7 @@ end
161161
lav_col = :se,
162162
)
163163

164-
test_bootstrap(solution_ls)
164+
test_bootstrap(solution_ls, partable)
165165
smoketest_CI_z(solution_ls, partable)
166166
end
167167

@@ -344,7 +344,7 @@ end
344344
lav_col = :se,
345345
)
346346

347-
test_bootstrap(solution_ml)
347+
test_bootstrap(solution_ml, partable_mean)
348348
smoketest_CI_z(solution_ml, partable_mean)
349349
end
350350

@@ -373,7 +373,7 @@ end
373373
lav_col = :se,
374374
)
375375

376-
test_bootstrap(solution_ls)
376+
test_bootstrap(solution_ls, partable_mean)
377377
smoketest_CI_z(solution_ls, partable_mean)
378378
end
379379

@@ -507,6 +507,6 @@ end
507507
lav_col = :se,
508508
)
509509

510-
test_bootstrap(solution_ml)
510+
test_bootstrap(solution_ml, partable_mean)
511511
smoketest_CI_z(solution_ml, partable_mean)
512512
end

0 commit comments

Comments
 (0)