-
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
broom:::tidy.glht()
not working with conf.int = TRUE
#1103
Comments
I appreciate you reporting this! This edge case is now handled: library(tidyverse)
library(broom)
library(multcomp)
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Loading required package: MASS
#>
#> Attaching package: 'MASS'
#> The following object is masked from 'package:dplyr':
#>
#> select
#>
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#>
#> geyser
set.seed(660)
n <- 10
data <-
tibble(
y = rnorm(n),
a = factor(sample(0:1, size = n, replace = TRUE)),
x = rnorm(n),
)
fit <- lm(y ~ a * x, data = data)
linfct <- matrix(0, ncol = length(coef(fit)))
colnames(linfct) <- names(coef(fit))
linfct[, 1:4] <- rep(1, 4)
x <- glht(fit, linfct = linfct)
tidy(x, conf.int = TRUE)
#> Joining, by = c("contrast", "estimate")
#> # A tibble: 1 × 7
#> contrast null.value estimate conf.low conf.high statistic adj.p.value
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 0 0.0368 -1.91 1.98 0.0463 0.965 Created on 2022-06-01 by the reprex package (v2.0.1) |
Many thanks to you and your team for this excellent package. I'm currently writing code for a book, and it's wonderful to be able to use broom as a common interface to many packages, something I'm sure students will appreciate. I'd like to make a suggestion for
And do you mean to be joining on the estimate? If it was calculated in two different ways in the two tibbles, the two results could differ slightly. |
Yeah, I noticed that join message while I was putting together the fix.🤔 The tidyselect magic I used for f010098 doesn't do the trick here, and I don't feel confident enough in my understanding of the multcomp internals to alter that join code myself. I'd welcome a PR/suggestion if you have an idea for some solid logic to specify that join. :) |
Fortunately, I don't believe you need to understand multcomp internals to specify the The first tibble of the join can have these columns:
The second tibble of the join can have these columns:
where again Thus, the present code is equivalent to specifying the
Someone can double check me on this. I suspect that the |
Yup, that joining on doubles bit is what makes me hesitant, and I'm not confident |
I agree that the logic of this should be reviewed, especially joining on the double |
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
In the following code,
broom:::tidy.glht()
throws an error whenconf.int = TRUE
.The cause for this may be that
broom:::tidy.confint.glht()
expectsbroom:::glht_term_column()
to return a tibble with aterm
column. Instead, it returnsNULL
, since the glht object does not have afocus
component.Created on 2022-05-31 by the reprex package (v2.0.1)
Session info
The text was updated successfully, but these errors were encountered: