Skip to content

REF: review and refactor for computational efficiency in ZeroInflated models #7632

Open

Description

@josef-pkt

The zeroinflated models have not been reviewed for computational efficiency in loglike and similar.
(My review before merging was mainly functional.)

  • hessian uses double loop (but for triangle, and so might not necessarily be slower than the rectangular vectorized solution)
  • no, or not enough temp variables, e.g. indexing occurs multiple times within methods, e.g. self.exog_infl[zero_idx, i], np.exp(llf[zero_idx]))
  • zero_idx could be attached as attribute instead of computed each time
  • score_obs uses numerical derivatives for probit inflation, this should be possible to be computed generically with delegating the binary model specific part to the inflation model.

also the computations are difficult to read, no visible structure (by algebraic priority rules)

Activity

  1. added this to the 0.15 milestone on May 5, 2023
  2. josef-pkt commented on May 5, 2023

    @josef-pkt
    MemberAuthor

    we need also score_factor for score_test

    review score hessian

    • score:
      • derivative w.r.t. zero model params dldw can use score_obs, score_factor from inflation model. currently logit is explicit and probit uses numdiff
      • use of score_obs of submodels can be replace by score_factor to the score_factor of ZI model
    • hessian
      • uses currently numdiff because _hessian_main returns None
      • The code in hessian that is currently not used does not look correct to me. Maybe it is, _hessian_logit contains the cross model derivative. (explicit formulas are or will be complicated)

    Note,
    score_factor if k_extra>0, with GPP, NBP as main model, will have 3 terms, one score factor for inflation model, two score factors for main model (mean parameters and extra shape/dispersion parameter)
    NB can have either zero or one k_extra, but it does not have score_factor yet. (k_extra=0 for geometric special case)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions