Skip to content

Identifiability analysis

IdentifiabilityAnalysis quantifies how well parameters can be identified around a best fit, via the Laplace approximation (profile likelihood is planned). It wraps an existing CVS0DParamID object.

identifiabilty_analysis.identifiabilityAnalysis.IdentifiabilityAnalysis

IdentifiabilityAnalysis(
    model_path,
    model_type,
    file_name_prefix,
    DEBUG=False,
    param_id_output_dir=None,
    resources_dir=None,
    param_id=None,
)

Identifiability analysis for a 0D model.

Quantifies how well calibrated parameters can be identified around a best fit. Currently the Laplace approximation is implemented (computing a covariance matrix from the Hessian of the cost); profile likelihood is planned. Requires an existing inner param_id object (typically CVS0DParamID.param_id); build conveniently with init_from_dict.

Parameters:

Name Type Description Default
model_path

Path to the generated model file.

required
model_type

'cellml_only', 'python' or 'casadi_python'.

required
file_name_prefix

Model name prefix (names the saved result files).

required
DEBUG

Enable debug behaviour.

False
param_id_output_dir

Root output directory.

None
resources_dir

Directory holding input resources.

None
param_id

The inner param-id engine to analyse (required).

None

Attributes:

Name Type Description
mean_Laplace

Mean (best-fit) parameter vector after Laplace approximation.

covariance_matrix_Laplace

Posterior covariance matrix from the Laplace approximation.

init_from_dict classmethod

init_from_dict(inp_data_dict, param_id)

Build an IdentifiabilityAnalysis from a config dict and a param-id object.

Parameters:

Name Type Description Default
inp_data_dict

Configuration dict (e.g. user inputs).

required
param_id

The inner param-id engine, e.g. CVS0DParamID.param_id.

required

Returns:

Name Type Description
IdentifiabilityAnalysis

A configured instance.

set_best_param_vals

set_best_param_vals(best_param_vals)

Supply the best-fit parameter vector to analyse around.

Parameters:

Name Type Description Default
best_param_vals

Array of best-fit parameter values.

required

run

run(ia_options)

Run the identifiability analysis using the chosen method.

Parameters:

Name Type Description Default
ia_options

Options dict; method selects 'Laplace' or 'profile_likelihood' (the latter is not yet implemented).

required

run_laplace_approximation

run_laplace_approximation(ia_options)

Run the Laplace approximation around the best fit.

Forms the precision (negative log-likelihood Hessian) via ia_options['gradient_source'] -- 'AD'/'FSA' build the Fisher information matrix from the analytic observable sensitivities, 'FD' (default) uses the finite-difference sub_method -- and inverts it (in Jacobi-normalised space, see _invert_precision_normalised) to the parameter covariance, saving {prefix}_laplace_mean.npy and {prefix}_laplace_covariance.npy.

The normalisation makes wide-magnitude models (e.g. 3compartment, params ~1e-9..1e8) succeed with a real covariance where the raw inverse used to give meaningless, massively inflated uncertainties. Raises RuntimeError only when the normalised precision is still ill-conditioned (jointly non-identifiable parameters) or a parameter has literally zero curvature (no information). A mildly indefinite finite-difference Hessian -- a small negative curvature from FD/optimiser noise at a rough optimum -- still yields a finite covariance (with a logged warning), as the plain inverse always did (issue #293).

Parameters:

Name Type Description Default
ia_options

Options dict; gradient_source ('FD'|'AD'|'FSA', default 'FD') and, for 'FD', sub_method (default 'parabola_fit').

required

run_profile_likelihood

run_profile_likelihood(ia_options)

Profile-likelihood identifiability analysis (not yet implemented).

plot_laplace_results

plot_laplace_results(parameter_names, output_dir)

Plot the results of the Laplace approximation as corner plots.

Parameters:

Name Type Description Default
parameter_names

List of parameter names corresponding to the best_param_vals.

required
output_dir

Directory to save the plots.

required