Reputation: 53
I am trying to use a gee like the following code:
example <- trial%>%
na.omit()%>%
tbl_uvregression(
method = geepack::geeglm,
y = death,
method.args = list(
family = binomial,
id = grade,
corstr = "independence"),
exponentiate = TRUE,
add_estimate_to_reference_rows = T,
conf.level = 0.95)
Which works just fine and gives me desired univariate analysis for all Xs. However, when I try to use add_global_p, I get the following error: There was an error running car::Anova()
for "trt", likely due to this model type not being supported. The results displayed are based on add_global_p(anova_fun = gtsummary::tidy_wald_test)
. This also happens to all Xs. However, I know for sure this model is supported by car::Anova since I used it with geeglm (see example 1 down):
example1 <- trial%>%na.omit()
example1.outcome <- geepack::geeglm(death ~ trt,family = binomial,id = grade,corstr = "independence", data = example1)
car::Anova(example1.outcome, type = 3, test.statistic = "Wald")
Outcome:
Analysis of Deviance table (Type III tests) Response: death
variable | Df | Chisq | Pr(>chisq) |
---|---|---|---|
intercept | 1 | 0.28 | 0.6 |
trt | 1 | 2.03 | 0.15 |
Going back to example, I tried a few different things such as:
example%>%
add_global_p(car::Anova(type = 3, test.statistic = "Chisq"))
But it gives the following error: Error in car::Anova(type = 3, test.statistic = "Chisq") : argument "mod" is missing, with no default.
I also tried:
add_global_p(car::Anova(example, type = 3, test.statistic = "Chisq"))
but the following error arises: Error in UseMethod("vcov") : no applicable method for 'vcov' applied to an object of class "c('tbl_uvregression', 'gtsummary')"
I also tried:
example%>%
add_global_p(anova_fun= car::Anova)
But it says argument mod is missing. I tried a few different things, but I do not seem to be able to get it. I also looked at the following question, and still could not figure it out: Problem using 'anova_fun' argument in 'add_global_p()'
Bonus: I am also wondering if it would be possible to add the values of Chisq test (the 3rd column in the output of example 1) in a column next to p-values.
Upvotes: 0
Views: 250
Reputation: 11774
See below for a working example:
library(gtsummary)
tbl <-
trial %>%
na.omit()%>%
tbl_uvregression(
method = geepack::geeglm,
y = death,
include = response,
method.args = list(
family = binomial,
id = grade,
corstr = "independence"),
exponentiate = TRUE,
add_estimate_to_reference_rows = T,
conf.level = 0.95
)
# this is the geepack::geeglm() model
class(tbl$tbls$response$model_obj)
#> [1] "geeglm" "gee" "glm" "lm"
# not compatible with `car::Anova()`
car::Anova(tbl$tbls$response$model_obj)
#> Error in glm.control(trace = 0L, jack = 0L, j1s = 0L, fij = 0L, maxit = 25L, : unused arguments (jack = 0, j1s = 0, fij = 0)
# the non-compatibility is shown below from within gtsummary
tbl_error <- tbl %>% add_global_p()
#> ✖ There was an error running `car::Anova()` for "response", likely due to this model type not being supported. The results displayed are based on `add_global_p(anova_fun = gtsummary::tidy_wald_test)`
# as the error message indicates, use the tidy_wald_test() function to get around the error
# FYI, this function was written FOR geepack models
tbl %>%
add_global_p(anova_fun = gtsummary::tidy_wald_test) %>%
as_kable() # convert to kable so it will display on StackOverflow
Characteristic | N | OR | 95% CI | p-value |
---|---|---|---|---|
Tumor Response | 173 | 0.35 | 0.19, 0.66 | <0.001 |
Created on 2023-06-29 with reprex v2.0.2
Upvotes: 0