Skip to content
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

[Issue-400] Implementing dynamic alpha for coefplot and iplot #528

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

rafimikail
Copy link
Contributor

No description provided.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@rafimikail
Copy link
Contributor Author

Hi @s3alfisc , this will be the merge request for implementing dynamic alpha for iplot and coefplot

I will re-do a sanity check, remove unnecessary files (used for testing), and put the proof of the test later

Thanks

_coefnames = self._coefnames
if alpha is None:
ub, lb = 0.975, 0.025
self.get_inference()
Copy link
Contributor Author

@rafimikail rafimikail Jun 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall the get_inference, as if the user had inputted non-default alpha for tidy previously, then the user recall tidy again, the value of confidence interval will be the non-default eventho the dataframe columns will show a default confidence interval

What do you think? @s3alfisc

@rafimikail
Copy link
Contributor Author

Hi @s3alfisc , kindly need your review for this merge request, I've also included the test results. Let me know if there are any improvements or changes needed. Thanks!

Test proofs:

  1. Coefplot using default alpha value
  2. Coefplot using adjusted alpha value
  3. Iplot using adjusted alpha value
image image image

@s3alfisc s3alfisc added the enhancement New feature or request label Jun 29, 2024
@s3alfisc s3alfisc linked an issue Jun 29, 2024 that may be closed by this pull request
Rafi Mikail and others added 3 commits June 29, 2024 16:58
add doc string for `alpha` argument to `tidy()`
unify alpha default for `get_inference`
@s3alfisc
Copy link
Member

s3alfisc commented Jul 3, 2024

Hi @rafimikail , I made minor adjustments. Will merge this after the CI tests pass =) Congrats 🎉 and thanks for your first contribution to pyfixest!

@s3alfisc
Copy link
Member

s3alfisc commented Jul 3, 2024

@all-contributors please add @rafimikail for code

Copy link
Contributor

@s3alfisc

I've put up a pull request to add @rafimikail! 🎉

@@ -1490,7 +1490,7 @@ def get_performance(self) -> None:
self._adj_r2 = np.nan
self._adj_r2_within = np.nan

def tidy(self, alpha=0.05) -> pd.DataFrame:
def tidy(self, alpha: Optional[float] = None) -> pd.DataFrame:
"""
Tidy model outputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a Parameters section to the docstring here that explains the alpha argument and its default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved by 695ad80695ad80

self.get_inference()
else:
ub, lb = 1 - alpha / 2, alpha / 2
self.get_inference(alpha=1 - alpha)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are inconsistent with the naming of the function arguments.

For tidy, alpha correctly describes the "size" of the test, while for .get_inference, it is 1-alpha.

Could you change

    def get_inference(self, alpha: float = 0.95) -> None:

to

    def get_inference(self, alpha: float = 0.05) -> None:

and within get_inference, change

z = np.abs(t.ppf((1 - alpha) / 2, df))
# to
z = np.abs(t.ppf((alpha) / 2, df))

and

z = np.abs(norm.ppf((1 - alpha) / 2))
# to
z = np.abs(norm.ppf(alpha / 2))

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved by 695ad80695ad80

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Files Coverage Δ
pyfixest/report/visualize.py 98.97% <100.00%> (ø)
pyfixest/estimation/feols_.py 87.60% <90.00%> (ø)

... and 29 files with indirect coverage changes

@s3alfisc s3alfisc merged commit e85fe7b into py-econometrics:master Jul 3, 2024
7 checks passed
@rafimikail
Copy link
Contributor Author

Hi @s3alfisc , I appreciate your help with the alpha consistency in get_inference, I was actually aware of it but I was concerned it might have dependencies with other functions, so i did not change it directly. Sorry could not address it myself immediately, it was quite late here in my country when you commented.

Also Big Thanks! I'm really pleased with my first contribution and I am interested to keep contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alpha (confidence interval) not used in plotting functions
2 participants