Skip to content

REF/ENH: fit_constrained generic method #4718

Open

Description

@josef-pkt

#4716 adds offset to the discrete binary models

We can add fit_constrained to more models. However, we might have to generalize the pattern, or make sure results instances are correctly created. Similar, case in fit_zeros and fit_collinear merged in #4576

  • fit_constrained currently has 3 times essentially the same code
    GLM.fit_constrained, Poisson.fit_constrained and outsourced to a standalone function base.constraints.fit_constrained_wrap.
    fit_constrained_wrap is not yet used in any model, but should be able to handle the details for most models.

  • inheritance or where do we attach it: next stage will just add discrete.BinaryModel

  • extra params: NegativeBinomial and GeneralizedPoisson have one extra param, This might or might not work, i.e. the constraint needs to be only on exog-params. The extra param might go through without changes. TransformRestriction needs to be checked whether it leaves unconstrained params unaffected/untransformed

  • multiple exog: Zero-Inflated has offset only for the main model, not the inflation model. params includes, concatenates the params of both models. Similarly, heteroscedastic models like Beta will have two exog. I don't remember whether hurdle models have two offset variables.
    Restricting the "main model" might work similar to the extra-params case where we ignore non-main-exog params in the constraints.
    Adding constraints for the second exog will be more work, and we will not be able to handle "cross-equation" constraints through exog transformation.

Activity

  1. added this to the 0.10 milestone on Jun 6, 2018
  2. josef-pkt commented on Jun 6, 2018

    @josef-pkt
    MemberAuthor

    discrete/tests/test_constrained.oy includes TestGLMLogitConstrained2.test_fit_constrained_wrap that verifies that params are the same with the standalone function

  3. josef-pkt commented on Jul 8, 2021

    @josef-pkt
    MemberAuthor

    working on Beta regression #7543

    _fit_zeros does not work with two-part, two exog model.

    When I fix the correct k_params, then it doesn't break before optimization
    mod_meth._fit_zeros([0, 1, 2], start_params=res_meth.params, k_params=mod_meth.nparams)
    but it breaks during the optimization of the auxiliary constrained model res_constr = mod_constr.fit(**fit_kwds)

    Either we need to separate out params and constraints for each exog separately,
    or we use transform_params for constraints that can be specified as parameter transformation, e.g. zero constraints.

    Zero-inflated models have two separate models, so we could apply the constraint transformation on each exog separately through the model instances.

    Similar to the extra_params case, we need to handle that constraints only affect part of the params, and we need to embed the constraint transformation in the larger params vector.

    I'm not sure there is a way to handle "cross-equation", cross-exog restrictions with the exog transformation, e.g. if mean and scale/variance/precision parameter have a joint constraint.
    Example might be zero-modified poisson, when the zero-poisson model and the truncated non-zero model have the same poisson rate under the null of no zero-modification. (This example is easier to work with because the null model is just a simple poisson. But that would not work in general if only part of the parameters are restricted, e.g. a separate zero constant)

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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions