diff --git a/DESCRIPTION b/DESCRIPTION index 4d24190..c696497 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: jstable Title: Create Tables from Different Types of Regression -Version: 1.2.5 -Date: 2024-05-08 +Version: 1.2.6 +Date: 2024-05-31 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/NEWS.md b/NEWS.md index ee6ad43..dc87a80 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# jstable 1.2.6 + +* Add AIC metric to `cox2.display`. + # jstable 1.2.5 * Update: Add `cluster` option to `TableSubgroupCox` and `TableSubgroupMultiCox` for marginal cox model. ex: `cluster = "inst"` diff --git a/R/cox2.R b/R/cox2.R index 517a7f3..6ce88f3 100644 --- a/R/cox2.R +++ b/R/cox2.R @@ -14,7 +14,7 @@ #' @rdname cox2.display #' @export #' @importFrom survival coxph cluster frailty -#' @importFrom stats formula update +#' @importFrom stats formula update AIC cox2.display <- function(cox.obj.withmodel, dec = 2) { model <- cox.obj.withmodel @@ -191,8 +191,9 @@ cox2.display <- function(cox.obj.withmodel, dec = 2) { # no.grp = unlist(lapply(model$frail, length)) no.obs <- model$n no.event <- model$nevent - metric.mat <- cbind(c(NA, no.obs, no.event), matrix(NA, 3, ncol(fix.all) - 1)) - rownames(metric.mat) <- c(NA, "No. of observations", "No. of events") + aic <- stats::AIC(model) + metric.mat <- cbind(c(NA, no.obs, no.event, aic), matrix(NA, 4, ncol(fix.all) - 1)) + rownames(metric.mat) <- c(NA, "No. of observations", "No. of events", "AIC") ## Integrated ll # ll = model$loglik[2]