Dear Statalist,
I am working on a project with two basic steps:
Step 1: perform a time-consuming (~45 minutes) optimization in Mata using optimize().
Step 2: use the results from the optimization, including the estimated parameters, the gradient vector, etc.
I have completed Step 1 more or less satisfactorily for now and am working on Step 2. I would like to avoid re-running Step 1 unnecessarily. My question is this:
At the end of Step 1, is it possible to save, and later retrieve, either the full Mata environment or the results from optimize? Then, to work on Step 2, I could load the results from Step 1 and proceed without re-running the optimization.
The (probably imperfect) analogy to working in Stata would be to save estimation results to a .ster file using estimates save, then retrieve these results using estimates use.
Since the Mata environment and results from optimize are Mata vectors, I imagine a workaround would be to store all of these in a Stata dataset using st_store(), save the Stata dataset, and then read the results back into Mata using st_data(). If this is in fact the best (or only) way to go, I'd appreciate any advice on how best to do this, especially since the Mata objects are likely to have different dimensions.
Many thanks,
Bert
PS - Stata 17.0 MP
I am working on a project with two basic steps:
Step 1: perform a time-consuming (~45 minutes) optimization in Mata using optimize().
Step 2: use the results from the optimization, including the estimated parameters, the gradient vector, etc.
I have completed Step 1 more or less satisfactorily for now and am working on Step 2. I would like to avoid re-running Step 1 unnecessarily. My question is this:
At the end of Step 1, is it possible to save, and later retrieve, either the full Mata environment or the results from optimize? Then, to work on Step 2, I could load the results from Step 1 and proceed without re-running the optimization.
The (probably imperfect) analogy to working in Stata would be to save estimation results to a .ster file using estimates save, then retrieve these results using estimates use.
Since the Mata environment and results from optimize are Mata vectors, I imagine a workaround would be to store all of these in a Stata dataset using st_store(), save the Stata dataset, and then read the results back into Mata using st_data(). If this is in fact the best (or only) way to go, I'd appreciate any advice on how best to do this, especially since the Mata objects are likely to have different dimensions.
Many thanks,
Bert
PS - Stata 17.0 MP
Comment