statsmodels / statsmodels/statsmodels

parameter restrictions where to define df_model, xnames, ...

Open
#921 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

comp-base design type-bug
Dominant language
Python
Stars
11.6k
Forks
3.6k
Avg merge
7h 37m
Merged PRs (30d)
96

Description

I'm reviewing the GenericLikelihoodModel, and try to fix so it works again out of the box.

One problem I run into is when I set a parameter restriction in the fit method. During initialization I don't know yet how many parameters will be estimated. fit can fix some parameters at predefined values, and as a consequence the actual number of params can change.

Since now the initialization code for xnames, df_model, df_resid, and so on, is in the __init__ and initialize which is called by __init__, the default code paths don't work correctly.

I get exceptions at various places, when df_model, xnames, ... are not defined or not defined correctly.

One option is to force that the restrictions are in __init__, so that the correct number of parameters is already known.

The other option is a fall back that fixes up the missing or incorrect meta attributes during fit.

I don't really like the first option, since it makes it more difficult to write fit methods with different constraints. However, the problem is a bit similar to the one we had when we moved order from fit to __init__ in ARMA.

The parameters in my cases are extra parameters that are not associated with an exog. The two cases I'm looking at are fixing the location in distribution estimation (like floc in scipy.stats) and fixing extra shape parameters such as the degrees of freedom in a maximum likelihood estimation with the t distribution.

The same problem will show up when we get non-linear least squares with or without restrictions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GenericLikelihoodModel.init, initialize, and fit, focusing on when parameter restrictions change the number of estimated parameters. Trace how xnames, df_model, and df_resid are set and used; done means restricted fits work without missing or incorrect metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.