Skip to content

BUG: include finite exact-diffuse innovations in concentrated loglike (closes #10741) - #10742

Merged
bashtage merged 1 commit into
statsmodels:mainfrom
Swapnil-J20:case30-exact-diffuse-likelihood
Nov 15, 2026
Merged

bashtage merged 1 commit into
statsmodels:mainfrom
Swapnil-J20:case30-exact-diffuse-likelihood

Conversation

@Swapnil-J20

Copy link
Copy Markdown
Contributor

Description

When combining concentrated scale (filter_concentrated = True) with exact diffuse initialization, KalmanFilter.loglike() omits finite innovations that occur during diffuse periods from the quadratic penalty and subtracts them from the finite innovation count.

As reported in #10741, this leads to an internal inconsistency between loglike() and other likelihood methods: on a 2-observation, 1-state model, model.loglike() evaluates to -4.906342, whereas model.loglikeobs().sum(), result.llf, and model.fixed_scale(...) all evaluate to -4.004213 (~0.902 log-likelihood units discrepancy).

This PR:

  1. Retains finite diffuse innovations in the quadratic adjustment and innovation count in KalmanFilter.loglike().
  2. Handles loglikelihood_burn correctly when burn ends within the diffuse initialization period.
  3. Refilters only when required per-period information was discarded under memory conservation flags.
  4. Adds 74 tests in test_concentrated.py covering closed-form solutions, missingness patterns, and memory conservation.
  5. Adds a release note in docs/source/release/version0.15.1.rst.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): GitHub Copilot.
    Used for: code completion and drafting test assertions.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

Retain finite innovations inside diffuse periods in the concentrated joint log-likelihood calculation and count, handling burn consistently.

Closes statsmodels#10741
@bashtage

Copy link
Copy Markdown
Member

Thanks.

@bashtage
bashtage merged commit 64a46f8 into statsmodels:main Nov 15, 2026
4 checks passed
@Swapnil-J20
Swapnil-J20 deleted the case30-exact-diffuse-likelihood branch November 15, 2026 19:33
bashtage added a commit that referenced this pull request Nov 16, 2026
Move the bullet of #10742 to the end of the "Time series analysis" bug
fix list, add its :pr: role, and say what users see: loglike now equals
loglikeobs().sum(), llf and the fixed_scale value, also for
conserve_memory settings; values and fitted parameters change when the
diffuse periods contain finite innovations (several observed series with
one diffuse state, a diffuse state observed only later), and single
series models without such innovations (local level, local linear
trend, SARIMAX with concentrate_scale) are unchanged. The bullet stays
under Bug Fixes, as the neighbouring merged #10713 bullet.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit that referenced this pull request Nov 16, 2026
Follow-up to #10742. Drop atol from the new tests (values are of order 1
to 5, rtol=1e-12 holds on Python 3.13 and 3.10). Add a test against R
KFAS 1.6.0 for the issue model (KFAS logLik less 0.5 * log(2 * pi) of the
diffuse innovation, which KFAS omits), for every conserve_memory setting,
and tests through MLEModel: a bivariate local level with finite diffuse
innovations (complete and with missing data, loglikelihood_burn 0, 1, 3,
compared with the non-concentrated model at the estimated scale, plus
complex step against finite difference scores) and SARIMAX(0, 1, 1) with
concentrate_scale and exact diffuse initialization (default and explicit
loglikelihood_burn).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit that referenced this pull request Nov 16, 2026
DOC: Follow up #10742 on the concentrated diffuse loglike, with tests
bashtage added a commit that referenced this pull request Nov 16, 2026
The release note of #10744 named only cov_type="cluster". Every covariance
type that sets df_resid_inference changes: "cluster" (also two-way
clustering), "hac-panel" and "hac-groupsum" for all models and "cluster-crv3"
and "cluster-jk" for linear models, unless df_correction=False. With
use_t=False nothing changes. Checked with seeded OLS, GLM, Logit and Poisson
fits with 10 clusters on main before and after #10744.

The entry stays in Bug Fixes with the neighbouring #10742, #10737 and #10736.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

BUG: KalmanFilter.loglike() disagrees with loglikeobs().sum() and result.llf under exact diffuse initialization with concentrated scale

2 participants