We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Making this issue so I don't forget about it. I can work on this at some point in the future
library(gtsummary) tidy_gam <- function(x, conf.int = FALSE, exponentiate = FALSE, ...) { broom::tidy(x, conf.int = conf.int, exponentiate = exponentiate, parametric = TRUE, ...) %>% dplyr::mutate(parametric = TRUE) %>% dplyr::bind_rows( broom::tidy(x, parametric = FALSE, ...) %>% dplyr::mutate(parametric = FALSE) ) %>% dplyr::relocate(.data$parametric, .after = dplyr::last_col()) } tidy <- mgcv::gam(age ~ s(marker, ttdeath) + grade, data = trial) %>% tidy_gam(conf.int = TRUE) tidy #> # A tibble: 4 x 10 #> term estimate std.error statistic p.value conf.low conf.high edf ref.df #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 (Int~ 46.2 1.85 24.9 2.37e-59 42.5 49.8 NA NA #> 2 grad~ 0.467 2.72 0.172 8.64e- 1 -4.86 5.79 NA NA #> 3 grad~ 2.13 2.69 0.792 4.30e- 1 -3.14 7.40 NA NA #> 4 s(ma~ NA NA 0.163 8.49e- 1 NA NA 2. 2. #> # ... with 1 more variable: parametric <lgl> # parametric terms are tidied just like a regular model # the smooth non-parametric terms are taken as is # this is what I would like to see tibble::tribble( ~variable, ~term, ~label, "(Intercept)", "(Intercept)", "(Intercept)", "grade", "gradeI", "I", "grade", "gradeII", "II", "grade", "gradeIII", "III", "s(marker,ttdeath)", "s(marker,ttdeath)", "s(marker,ttdeath)" ) %>% dplyr::left_join(tidy, by = "term") #> # A tibble: 5 x 12 #> variable term label estimate std.error statistic p.value conf.low conf.high #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 (Interc~ (Int~ (Int~ 46.2 1.85 24.9 2.37e-59 42.5 49.8 #> 2 grade grad~ I NA NA NA NA NA NA #> 3 grade grad~ II 0.467 2.72 0.172 8.64e- 1 -4.86 5.79 #> 4 grade grad~ III 2.13 2.69 0.792 4.30e- 1 -3.14 7.40 #> 5 s(marke~ s(ma~ s(ma~ NA NA 0.163 8.49e- 1 NA NA #> # ... with 3 more variables: edf <dbl>, ref.df <dbl>, parametric <lgl>
Created on 2021-01-08 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered:
mgcv::gam()
Successfully merging a pull request may close this issue.
Making this issue so I don't forget about it. I can work on this at some point in the future
Created on 2021-01-08 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: