Skip to content

If B_xxx are used to construct random effects, then non-centering occurs #49

Description

@fhui28

Because of the conditional nature of the optimization process in CBFM, such that if a B_xxx argument is used to construct random intercepts, then they are not centered around zero i.e., the mean of the random intercepts is not zero, even though by definition of PQL estimation they should be.

The problem occurs because when basis_effects_mat is meant to operate like random intercepts, then that are updated conditional on the Xbeta part of the model. So then the update behaves like estimationg random intercepts when there is no overall intercept in the model. This then causes these estimates to not be centered around zero.

It is a problem for interpretation but not for prediction, at least in principle;

Solutions:

  • If B_xxx itself is centered around zero i.e., a smooth basis function matrix from many options in mgcv, then this is not a problem. In principle, one could also scale B_xxx externall to have columns sum to zero to fix this problem. But this is fraught with danger if you don't know what you are doing!
  • Employ a separate step when you move the mean of any random intercept type B_xxx terms to the overall intercept in the Xbeta component.

Activity

  1. added
    Long term enhancementLow priority/will take a long time to do...many cups of tea required!
    on Nov 5, 2025
  2. fhui28 commented on Feb 15, 2026

    @fhui28
    OwnerAuthor

    control$backfitting_trick = TRUE can now be set, which is an ad-hoc attempt to implement the second solution above. From a bit of testing it seems to help somewhat, but is by no means perfect!

    Really the best solution is to solve everything jointly, but that is not what CBFM (for good or for bad) was set up to do.

  3. added
    bugSomething isn't working
    and removed
    Long term enhancementLow priority/will take a long time to do...many cups of tea required!
    on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions