New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FAQ Having trouble getting Exogenous names in model summaries #5492
Comments
Are you using numpy arrays for endog and exog in numpy arrays don't hold names of variables/columns, so the param or exog names are just made up. Using pandas DataFrames for exog or using formulas preserves the names, and uses it in the summary. There is a way to set the names but that still does not have a very clean API. just for summary:
|
Yes, I am using NumPy arrays for this. The reason that I noticed it now, I used |
@josef-pkt , I tried to assign new names after the initialization, as
and also after init-fit phase
In both cases I got error. |
AFAICS, you are mixing up model and results instance (difference to sklearn)
In the second case to try to access exog_names in the results instance and not the model instance try this:
|
It did work! thank you for answering on such short notice |
@josef-pkt I'm always curious about this. Is there any reason why |
@StevenLi-DS It's just so we know when we estimated the model (or better when we printed the summary When I wrote the first implementation of summary, I just browsed through what several statistics and econometrics programs (especially Stata) were showing in the summary, and added what I thought looks useful and "traditional". There is currently no option to adjust what is in the summary, what is included is hardcoded for each model. ( |
I can't think about a useful case so far than exposing I got nothing to do than stats at late night. lol...😂 |
I just realized that I could actually modify the model = smf.ols(formula, data=df)
results = model.fit()
exogs_list = model.exog_names
exogs_list.remove('Intercept')
endog_name = model.endog_names
# call summary will raise error
results.summary()
|
@StevenLi-DS ,I think you are right. By modifying maybe only namechange should be allowed? |
I think maybe it should just return a copy of the exog names |
In general I don't think we have ever tried to prevent people from changing attributes of model or results classes. There are some "cache readonly" attributes in the results classes that cannot be changed, but this is an indirect effect of their being cached so that they are not repeatedly recomputed. |
To emphasize Kerby's comment. In general the user should not change any attributes of either model or results. There is a kind of exception for changing However, not changing attributes is not enforced. If the user changes attributes, then it is on her/his own risk. |
@kshedden @josef-pkt Thanks for the explanation. Maybe it should be written in the doc to warn the users. |
Hi. I am using using statsmodels installed with Anaconda with following versions:
Now when I fit a model, in summary table, I do not see the names of the variables. Only x1, x2, xN. Is there a way to have the variable names also in the summary? Or this change is permanent.
Thanks beforehand
The text was updated successfully, but these errors were encountered: