|
27 | 27 | from estimagic.parameters.conversion import get_converter |
28 | 28 | from estimagic.shared.check_option_dicts import check_numdiff_options |
29 | 29 | from estimagic.shared.check_option_dicts import check_optimization_options |
| 30 | +from estimagic.utilities import to_pickle |
30 | 31 |
|
31 | 32 |
|
32 | 33 | def estimate_ml( |
@@ -81,7 +82,7 @@ def estimate_ml( |
81 | 82 | upper_bounds (pytree): As lower_bounds. Can be ``np.inf`` for parameters with |
82 | 83 | no upper bound. |
83 | 84 | constraints (list, dict): List with constraint dictionaries or single dict. |
84 | | - See .. _link: ../../docs/source/how_to_guides/how_to_use_constraints.ipynb |
| 85 | + See :ref:`constraints`. |
85 | 86 | logging (pathlib.Path, str or False): Path to sqlite3 file (which typically has |
86 | 87 | the file extension ``.db``. If the file does not exist, it will be created. |
87 | 88 | The dashboard can only be used when logging is used. |
@@ -211,7 +212,7 @@ def estimate_ml( |
211 | 212 | # Get the converter for params and function outputs |
212 | 213 | # ================================================================================== |
213 | 214 |
|
214 | | - converter, flat_estimates = get_converter( |
| 215 | + converter, internal_estimates = get_converter( |
215 | 216 | func=loglike, |
216 | 217 | params=estimates, |
217 | 218 | constraints=constraints, |
@@ -241,9 +242,9 @@ def func(x): |
241 | 242 |
|
242 | 243 | jac_res = first_derivative( |
243 | 244 | func=func, |
244 | | - params=flat_estimates.values, |
245 | | - lower_bounds=flat_estimates.lower_bounds, |
246 | | - upper_bounds=flat_estimates.upper_bounds, |
| 245 | + params=internal_estimates.values, |
| 246 | + lower_bounds=internal_estimates.lower_bounds, |
| 247 | + upper_bounds=internal_estimates.upper_bounds, |
247 | 248 | **numdiff_options, |
248 | 249 | ) |
249 | 250 |
|
@@ -284,9 +285,9 @@ def func(x): |
284 | 285 |
|
285 | 286 | hess_res = second_derivative( |
286 | 287 | func=func, |
287 | | - params=flat_estimates.values, |
288 | | - lower_bounds=flat_estimates.lower_bounds, |
289 | | - upper_bounds=flat_estimates.upper_bounds, |
| 288 | + params=internal_estimates.values, |
| 289 | + lower_bounds=internal_estimates.lower_bounds, |
| 290 | + upper_bounds=internal_estimates.upper_bounds, |
290 | 291 | **numdiff_options, |
291 | 292 | ) |
292 | 293 | int_hess = hess_res["derivative"] |
@@ -335,7 +336,7 @@ def func(x): |
335 | 336 | _internal_jacobian=int_jac, |
336 | 337 | _internal_hessian=int_hess, |
337 | 338 | _design_info=design_info, |
338 | | - _flat_params=flat_estimates, |
| 339 | + _flat_params=internal_estimates, |
339 | 340 | _has_constraints=constraints not in [None, []], |
340 | 341 | ) |
341 | 342 |
|
@@ -615,7 +616,7 @@ def summary( |
615 | 616 |
|
616 | 617 | summary = calculate_inference_quantities( |
617 | 618 | estimates=self.params, |
618 | | - flat_estimates=self._flat_params, |
| 619 | + internal_estimates=self._flat_params, |
619 | 620 | free_cov=free_cov, |
620 | 621 | ci_level=ci_level, |
621 | 622 | ) |
@@ -737,3 +738,12 @@ def p_values( |
737 | 738 | out = self._converter.params_from_internal(helper) |
738 | 739 |
|
739 | 740 | return out |
| 741 | + |
| 742 | + def to_pickle(self, path): |
| 743 | + """Save the LikelihoodResult object to pickle. |
| 744 | +
|
| 745 | + Args: |
| 746 | + path (str, pathlib.Path): A str or pathlib.path ending in .pkl or .pickle. |
| 747 | +
|
| 748 | + """ |
| 749 | + to_pickle(self, path=path) |
0 commit comments