Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyk0315 committed Feb 29, 2024
1 parent ffc1897 commit 6934fe3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9403-605X")),
person("Zarathu", role = c("cph", "fnd")),
person("Yoonkyoung","Jeon", role = c("aut"))
Expand Down
17 changes: 8 additions & 9 deletions R/forestglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down Expand Up @@ -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')) {
Expand Down
1 change: 1 addition & 0 deletions R/glmshow.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @return coefficient table with NA
#' @details DETAILS
#' @examples
#'
#' coefNA(glm(mpg ~ wt + qsec, data = mtcars))
#' @rdname coefNA
#' @export
Expand Down

0 comments on commit 6934fe3

Please sign in to comment.