Skip to content

Likelihood slices, profiles, Monte Carlo adjusted profiles, and diagnostic plots - #25

Open
atpabuser wants to merge 1 commit into
kingaa:develfrom
atpabuser:analysis-layer
Open

atpabuser wants to merge 1 commit into
kingaa:develfrom
atpabuser:analysis-layer

Conversation

@atpabuser

Copy link
Copy Markdown
Contributor

What it adds

  • Designs (src/design.jl): slice_design, profile_design,
    runif_design, sobol_design, as in R pomp. profile_design records
    which parameters are profiled, so that profile can refuse a
    perturbation of them.
  • Likelihood estimation at a point (pfilter_loglik): nreps
    independent particle filters, combined by logmeanexp, with the
    jack-knife standard error and the effective sample size of the
    replicates. A replicate whose estimate is zero (log likelihood −∞) is
    kept, since dropping it biases the average upward.
  • Slices (slice): the log likelihood along each row of a design,
    with the model and resampling settings (trigger, target) of the
    object passed, including a pfilter or mif result.
  • Profiles (profile): for each design row, mif with the profiled
    parameters held fixed, then an evaluation by pfilter_loglik at
    exactly the reported point, with the model and resampling settings
    that mif used.
  • Monte Carlo adjusted profile (mcap) as in R pomp::mcap. The local quadratic smoother is R's loess with
    surface = "direct", fitted in standardized units so that the result
    does not depend on the units of the parameter. When fewer than three
    distinct parameter values carry weight, the quadratic is not
    determined by the data: its coefficients, standard errors and interval
    are NaN (R's NA), with a warning, and a smoothing window that cannot
    determine its local quadratic is refused rather than resolved by a
    pseudoinverse.
  • Monitoring mif (monitor): the log likelihood of the
    unperturbed model at the point estimates recorded in the traces,
    across one run or a sequence of continuations, using its own random
    numbers so the fit is unchanged. Also hyperbolic_cooling and
    resampled.
  • Plots (sliceplot, mcapplot, traceplot, filterplot), as a
    package extension loaded only with AlgebraOfGraphics.

New dependencies: Sobol and LinearAlgebra; AlgebraOfGraphics as a
weak dependency.

How it was checked

  • Against exact likelihoods. For the Gompertz model, whose
    likelihood is exact by the Kalman filter, the particle-filter
    estimates, the slices and the profile are compared with the exact
    values. Further tests use models whose likelihood is known in closed
    form, so that each estimate reveals the parameters it was computed
    at.
  • Against R. loess and mcap agree with R (pomp::mcap on the
    direct surface) to about 1e-10. Over 600 profile layouts with
    irregular spacing and unequal numbers of starts, the cases Julia
    refuses or marks NaN are exactly those where R stops, falls back on its
    pseudoinverse, or returns NA.
  • Each test was run against deliberately wrong
    versions of the code, e.g. a slice evaluated on the bare model, a
    profile evaluated at the swarm average, or mcap without centring.
    Every such version that changes a result is caught.

Notes

  • profile with the default avfun = geomean fails for a parameter
    that takes negative values, or that the model needs as an integer. The
    docstring says to pass avfun = mean.
  • test/mif.jl also carries the geometric_cooling value test that I
    sent separately.

…or, and plots

Designs (slice_design, profile_design, runif_design, sobol_design),
pfilter_loglik, slice, profile, mcap (as R pomp::mcap, direct loess
surface), monitor, hyperbolic_cooling, resampled, and an AlgebraOfGraphics
extension (sliceplot, mcapplot, traceplot, filterplot), with tests against
exact likelihoods and R.
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.84211% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.04%. Comparing base (d592885) to head (54a1145).

Additional details and impacted files
@@             Coverage Diff             @@
##             devel      #25      +/-   ##
===========================================
- Coverage   100.00%   99.04%   -0.96%     
===========================================
  Files           28       33       +5     
  Lines          871     1251     +380     
===========================================
+ Hits           871     1239     +368     
- Misses           0       12      +12     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant