Results

Fitting in redback returns a redback.result object. This object provides a homogenous format for all further analysis and plotting the results of the fitting. The redback.result object inherits from the bilby.result object so all functionality in the bilby.result such as making pp_plots, walker_plots, getting credible intervals etc. is automatically implemented. See the bilby API for a full list of features.

The result file is by default saved to the transient/transient_name/model/, but the user can of course change this. It is by default saved in a json format, which can be changed to ‘hdf5’ for more compression.

Fitting your favourite transient

The interface to fit is simple. Once a user has defined a transient object, a model object and a prior object, the user can fit the data via,

result = redback.fit_model(transient, model, priors)

The more advanced user can change things such as the sampler/likelihood etc

Changing the likelihood used for fitting

Some advanced users may wish to change the default likelihood used in redback to another likelihood implemented in redback or use a likelihood. For example, you may want to fit an additional noise source. Or fit non-detections. Or fit with errors in time etc.

Changing the likelihood used can be done easily by

import redback
transient = redback.transient.Transient(transient_name, data_mode, filters)
likelihood = redback.likelihood.Likelihood(transient, model)
result = redback.fit_model(likelihood, priors, sampler, outdir=outdir, label=label)

Plotting lightcurves and corner plots

Plotting a corner plot is as simple as

result.plot_corner()

The user can pass in different keyword arguments to change the look/format/what parameters are plotted. See the bilby API.

We can also plot the fit

result.plot_lightcurve(random_models=100)
result.plot_multiband_lightcurve()

Here the first line will plot the lightcurve on a single panel with a 100 random models randomly drawn from the posterior and the maximum likelihood model. The second line will plot the lightcurve on multiple panels, each panel corresponding to a particular band/frequency.

In both functions, users can pass additional keyword arguments to change the aesthetics or what is plotted. See the redback API for more details.

Further analysis

The result file provides the posterior values as a pandas data frame accessible via result.posterior. Other properties such as the evidence etc are also stored.

These posteriors and properties can be used for further analysis such as different diagnostic plots, model selection, reweighting or hierarchical inference.

The redback.analysis object enables users to easily make plots for diagnostics or further plots for specific models/transients.

MAP and MLE results

Fits run with fit_method="map" or fit_method="mle" return the same RedbackResult type as sampled fits, but their result.posterior contains one optimized row. That row can be accessed directly with result.point_estimate. The properties result.fit_method and result.optimization record the objective and optimizer diagnostics.

Lightcurve and spectrum plotting methods use that optimized row normally. Corner plots, credible intervals, evidence comparisons, and other operations requiring posterior samples are not defined for a point-estimate result. Use sampler="laplace" for an approximate local posterior or a standard Bilby sampler for full posterior inference.

Loading a result file

We also provide functionality for loading in a result file.

import redback
redback.result.read_in_result(filepath)

Here filepath is the path to file, the result file recreates the transient object exactly as it was used when fitted. This ensures users can keep their results consistent with the data_mode/filters etc of the transient they chose.

Fitting spectrums

The above generally describes the interface for fitting lightcurves. Redback also provides functionality for fitting spectrums, which has an identical interface except the result object is a redback.spectrum_result object, which has slightly different behavior.