Open eadkins333 opened 3 years ago
The lmfit documentation specifies that the emcee can "can be used to obtain the posterior probability distribution of parameters, given a set of experimental data," but it "does not actually perform a fit." It instead explores the parameter space around a given solution to determine the probability distribution, but without the explicit goal of attempting to refine the solution. - Minimizer Fitting emcee documentation
defines residuals as data - model
can use residuals as the feed to the emcee function without defining the log likeliehood function by specifying is_weighted = False, it will then automatically assign.
res = lmfit.minimize(residual, method='emcee', nan_policy='omit', burn=300, steps=1000, thin=20, params=mi.params, is_weighted=False, progress=False)
Success can be checked by the autocorrelation time and/or acceptance fraction for the walkers. Acceptance fraction plot as number of walkers should be between 0.2 and 0.5
installation of the corner package can allow for plotting of the results, but the Minimizer results
`import corner
emcee_plot = corner.corner(res.flatchain, labels=res.var_names, truths=list(res.params.valuesdict().values()))`
The minimizer result will print the median of the probability distribution and one sigma quantile estimated as half the difference between the 15.8 and 84.2 quantiles.
The emcee can then be used to calculated the maximum likelihood estimation and various quantiles (code on the linked page)
Another solution would be to call the confidence interval function.
https://lmfit.github.io/lmfit-py/confidence.html#label-confidence-advanced
In meantime could make an error analysis example