diff --git a/DESCRIPTION b/DESCRIPTION index 3ed889b..bba4fad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: jstable Title: Create Tables from Different Types of Regression Version: 1.1.7 -Date: 2024-02-28 +Date: 2024-02-29 Authors@R: c(person("Jinseob", "Kim", email = "jinseob2kim@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9403-605X")), person("Zarathu", role = c("cph", "fnd")), person("Yoonkyoung","Jeon", role = c("aut")) diff --git a/R/forestglm.R b/R/forestglm.R index da2146d..ed3c72e 100644 --- a/R/forestglm.R +++ b/R/forestglm.R @@ -61,14 +61,9 @@ TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data, }, NA) possible_glm <- purrr::possibly(stats::glm, NA) possible_svyglm <- purrr::possibly(survey::svyglm, NA) - possible_confint <- purrr::possibly(stats::confint, NA) possible_modely <- purrr::possibly(function(x) { purrr::map_dbl(x, .[["y"]], 1) }, NA) - possible_rowone <- purrr::possibly(function(x) { - x[2, ] - }, NA) - xlabel <- setdiff(as.character(formula)[[3]], "+")[1] ncoef <- ifelse(any(class(data) == "survey.design"), ifelse(length(levels(data$variables[[xlabel]])) <= 2, 1, length(levels(data$variables[[xlabel]])) - 1), ifelse(length(levels(data[[xlabel]])) <= 2, 1, length(levels(data[[xlabel]])) - 1) @@ -94,11 +89,10 @@ TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data, cc<-summary(model)$coefficients Point.Estimate <- round(stats::coef(model), decimal.estimate)[2] - # CI <- round(stats::confint(model)[2, ], decimal.estimate) + CI<-round(c(cc[2, 1] - qnorm(0.975) * cc[2, 2],cc[2, 1] + qnorm(0.975) * cc[2, 2]),decimal.estimate) if (family %in% c("binomial",'poisson','quasipoisson')) { Point.Estimate <- round(exp(stats::coef(model)), decimal.estimate)[2] - # CI <- round(exp(stats::confint(model)[2, ]), decimal.estimate) CI<-round(exp(c(cc[2, 1] - qnorm(0.975) * cc[2, 2],cc[2, 1] + qnorm(0.975) * cc[2, 2])),decimal.estimate) } @@ -189,8 +183,13 @@ TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data, Estimate <- model %>% purrr::map("coefficients", .default = NA) %>% purrr::map_dbl(2, .default = NA) - cc0<-summary(model)$coefficients - CI0 <- c(cc0[2, 1] - qnorm(0.975) * cc0[2, 2],cc0[2, 1] + qnorm(0.975) * cc0[2, 2]) + + CI0 <- model %>% + purrr::map(function(model){ + cc0<-summary(model)$coefficients + c(cc0[2, 1] - qnorm(0.975) * cc0[2, 2],cc0[2, 1] + qnorm(0.975) * cc0[2, 2]) + }) %>% + Reduce(rbind, .) Point.Estimate <- round(Estimate, decimal.estimate) CI <- round(CI0, decimal.estimate) if (family %in% c("binomial",'poisson','quasipoisson')) { diff --git a/R/glmshow.R b/R/glmshow.R index 494117b..781e5e2 100644 --- a/R/glmshow.R +++ b/R/glmshow.R @@ -4,6 +4,7 @@ #' @return coefficient table with NA #' @details DETAILS #' @examples +#' #' coefNA(glm(mpg ~ wt + qsec, data = mtcars)) #' @rdname coefNA #' @export