-
Notifications
You must be signed in to change notification settings - Fork 303
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
Fix coeftest bug #1227
Fix coeftest bug #1227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Could you also add a test in tests/testthat/test-lmtest.R
for this case and note the change in NEWS?
R/utilities.R
Outdated
@@ -517,6 +517,12 @@ broom_confint_terms <- function(x, ...) { | |||
rownames(ci) <- names(coef(x))[1] | |||
} | |||
|
|||
# Handle `coeftest` one-dimensional case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than dropping this code into the broom_confint_terms()
helper, could you situate it into the tidy.coeftest()
method itself? After calling broom_confint_terms()
there, we still have access to rownames(x)
and the result of this function. This will prevent tidier-specific code from leaking into more general tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the code review!
This is done now inside tidy.coeftest
Thanks for the code review! |
also, no need to test class inside of the dispatched S3 method.
Thank you for the revisions! I just pushed a few small edits—will merge once checks pass. I appreciate your work here! |
@simonpcouch thank you too! 😄 |
This pull request has been automatically locked. If you believe the issue addressed here persists, please file a new PR (with a reprex: https://reprex.tidyverse.org) and link to this one. |
When using tidy with coeftest on a model with a constant terms nan are produced
by the confint function.
The reason is that the intercept rowname does not pass through.
The error is inside the
broom_confint_terms
function.When hitting a breakpoint we can inspect the x input variable to the dataframe.
As shown below
names(coef(x))
returns NULL so no rowname will be set and whenit is larger merged onto the other variables the nans are produced.
This PR checks for a one-dimensional object of class
coeftest
and uses therownames
function on thex
variable to get the correct intercept name ontothe resulting
ci
object.Output when using broom package
SessionInfo
Output when using pull request
Test script