Reputation: 23
I'm trying to perform a logistic regression on imputed data, but I can't get the global p-values. When I try it on the dataset without imputation, it works, but as soon as it's on imputed data, it doesn't work anymore.
Does someone know if there's a way to calculate and display them in gtsummary?
For example, with random variables :
library(tidyverse)
library(gtsummary)
library(mice)
n <- 500
set.seed(123)
data <- data.frame(
rep_2cl = factor(sample(0:1, n, replace = TRUE)),
Age = sample(18:62, n, replace = TRUE),
Diplome = factor(sample(c("1", "2", "3", "4", NA), n, replace = TRUE)),
Study = factor(sample(c("0", "1", NA), n, replace = TRUE)),
Alone = factor(sample(c("0", "1", NA), n, replace = TRUE)),
Special = factor(sample(c("1", "2", "3"), n, replace = TRUE)),
Contract = factor(sample(c("1", "2", "3", NA), n, replace = TRUE)),
Durr = factor(sample(c("1", "2", NA), n, replace = TRUE)),
Vax = factor(sample(c("0", "1", NA), n, replace = TRUE)))
data.i <- mice(data,
m = 5,
seed = 123,
print = FALSE)
# non imputed data
fit <- glm(formula = rep_2cl ~ Age + Diplome + Study + Alone + Special + Contract + Durr + Vax,
family = binomial,
data)
tbl_regression(fit, exponentiate = T) |> add_global_p()
# imputed data
fit.i <- with(data.i,
glm(formula = rep_2cl ~ Age + Diplome + Study + Alone + Special + Contract + Durr + Vax,
family = binomial))
tbl_regression(fit.i, exponentiate = T) |> add_global_p()
thank you
Upvotes: 1
Views: 65