Skip to content

Jacobian term shouldn't be included when transforming loglikelihoods #1705

Closed

Description

@frankiepe

When working in a transformed parameter space to perform maximum likelihood estimation, we don't need to include the Jacobian term provided we are not also transforming the data.

This follows from the "invariance property of the ML estimator": https://en.wikipedia.org/wiki/Maximum_likelihood_estimation

Activity

  1. MichaelClerx commented on Feb 20, 2025

    @MichaelClerx
    Member

    I think this means we need to update the Transformation class to have a transform_logpdf and a transform_loglikelihood.
    To do that, we'll need to start distinguishing between unnormalised log pdfs (which take a random variable as input) and loglikelihoods (which take a non-random variable as input, plus data sampled from some distribution (but fixed)). Might have some far-reaching consequences software wise...

    See #457

    The use case for this is performing MLP using the Transform class and an optimiser: at the moment that uses the transform_logpdf method even if you pass it a likelihood

  2. MichaelClerx commented on Feb 20, 2025

    @MichaelClerx
    Member
  3. martinjrobins commented on Feb 20, 2025

    @martinjrobins
    Member

    is this just for MLP? How about if the likelihood is part of a log posterior, do you transform its output then?

  4. MichaelClerx commented on Feb 20, 2025

    @MichaelClerx
    Member

    No but you'd have [changed prior] * [unchanged likelihood] = [changed pdf]. So the likelihood itself would be treated the same as in MLE, but the posterior would still change due to the prior changing.

  5. martinjrobins commented on Feb 21, 2025

    @martinjrobins
    Member

    No but you'd have [changed prior] * [unchanged likelihood] = [changed pdf]. So the likelihood itself would be treated the same as in MLE, but the posterior would still change due to the prior changing.

    so the likelihood is multiplied by a factor (lets say A where A = dp(sigma)/dsigma is the jacobian of the pdf) due to the change of variables, but MLE is unaffected by this since A is constant wrt the parameters sigma. The prior has an A that might be dependent on the parameters, so this needs to be transformed. More broadly, any logpdf that has a jacobian that is constant wrt the parameters sigma does not need to be transformed. So perhaps a pints logpdf can have a function that returns a bool indicating if its jacobian is constant wrt the parameters? Then the Transformation class can just check this?

  6. mirams commented on Jun 17, 2025

    @mirams
    Member

    I wrote a little explainer for the team here:

    ParameterTransformIssue.pptx

  7. DavidGavaghan commented on Jun 17, 2025

    @DavidGavaghan

    Thanks Gary - I think your first solution is probably the best one - the second one requires more understanding and people might still get it wrong.

  8. added theissue type on Jun 17, 2025
  9. MichaelClerx commented on Jan 26, 2026

    @MichaelClerx
    Member

    So:

    Sound OK, @mirams @frankiepe ?

  10. MichaelClerx commented on Feb 5, 2026

    @MichaelClerx
    Member

    @mirams am I right in thinking that we don't have to do anything special for the LogPosterior?

    I.e. do we want to return calculated log_pdf + jacobian term, which is the same as (calculated log_prior + jacobian term) + calculated log_likelihood ?

  11. mirams commented on Feb 5, 2026

    @mirams
    Member

    If you mean return JacTransform(log_prior) + log_likelihood then yes, that should be fine I think. But make sure there's a couple of tests with an analytic answer, like the uniform-log example in the powerpoint (should be simple enough with a flat likelihood and uniform prior that gets transformed)

  12. MichaelClerx commented on Feb 5, 2026

    @MichaelClerx
    Member

    Slight change of plan:

  13. MichaelClerx commented on Mar 6, 2026

    @MichaelClerx
    Member

    Fixed in #1730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions