From 1a74296cf57fc1d1590f9c09d2387cbe93a58f76 Mon Sep 17 00:00:00 2001 From: Gabriel E Kreindler Date: Mon, 1 Jan 2024 12:44:35 -0500 Subject: [PATCH] IO bugs --- src/functions_estimation.jl | 4 ++-- src/functions_inference.jl | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/functions_estimation.jl b/src/functions_estimation.jl index 88b9490..b1bf181 100644 --- a/src/functions_estimation.jl +++ b/src/functions_estimation.jl @@ -333,7 +333,7 @@ function fit_onestep( # skip if output file already exists if !opts.overwrite && (opts.path != "") - opt_results_from_file = read_fit(opts) + opt_results_from_file = read_fit(opts.path, subpath=opts.subpath) if !isnothing(opt_results_from_file) println(" Results file already exists. Reading from file.") @@ -385,7 +385,7 @@ function fit_onerun( # skip if output file already exists if !opts.overwrite && (opts.path != "") - opt_results_from_file = read_fit(opts, subpath="__iter__/fit_" * string(idx)) + opt_results_from_file = read_fit(opts.path, subpath="__iter__/fit_" * string(idx)) if !isnothing(opt_results_from_file) (opts.trace > 0) && println(" Reading from file.") diff --git a/src/functions_inference.jl b/src/functions_inference.jl index 96c0e70..bf3b3dc 100644 --- a/src/functions_inference.jl +++ b/src/functions_inference.jl @@ -56,11 +56,13 @@ function vcov_simple( myfit.errored && error("Cannot compute vcov_simple because estimation errored.") # try to read from file - myvcov = read_vcov(opts.path) - if !opts.overwrite && !isnothing(myvcov) && myvcov.method == :simple - # TODO: use opts.overwrite option to error if vcov already exists but is not :simple - myfit.vcov = myvcov - return + if !opts.overwrite + myvcov = read_vcov(opts.path) + if !isnothing(myvcov) && myvcov.method == :simple + # TODO: use opts.overwrite option to error if vcov already exists but is not :simple + myfit.vcov = myvcov + return + end end # jacobian @@ -281,11 +283,13 @@ function vcov_bboot( opts::GMMOptions=default_gmm_opts()) # try to read from file - myvcov = read_vcov(opts.path) - if !opts.overwrite && !isnothing(myvcov) && myvcov.method == :bayesian_bootstrap - # TODO: use opts.overwrite option to error if vcov already exists but is not bayesian_bootstrap - myfit.vcov = myvcov - return + # TODO: use opts.overwrite option to error if vcov already exists but is not bayesian_bootstrap + if !opts.overwrite + myvcov = read_vcov(opts.path) + if !isnothing(myvcov) && myvcov.method == :bayesian_bootstrap + myfit.vcov = myvcov + return + end end # copy options so we can modify them (trace and path)