Conversation
simonpcouch
left a comment
There was a problem hiding this comment.
Thank you!
Could you also add a test in tests/testthat/test-lmtest.R for this case and note the change in NEWS?
| rownames(ci) <- names(coef(x))[1] | ||
| } | ||
|
|
||
| # Handle `coeftest` one-dimensional case |
There was a problem hiding this comment.
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.
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_termsfunction.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
coeftestand uses therownamesfunction on thexvariable to get the correct intercept name ontothe resulting
ciobject.Browse[2]> x t test of coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.1039 4.4520 -0.6972 0.486 Browse[2]> class(x) [1] "coeftest" Browse[2]> is.null(dim(ci)) [1] FALSE Browse[2]> coef(x) [1] -3.103912 Browse[2]> names(coef(x)) NULL Browse[2]>Output when using broom package
SessionInfo
Output when using pull request
Test script