From aad32ba0a471631b9bc288b2020e83430b8c0dfd Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 4 Jul 2024 20:02:11 +0200 Subject: [PATCH] objects of class [clogit, coxph] are not supported by report() (#446) Fixes #417 --- DESCRIPTION | 1 + NAMESPACE | 10 ++++++++++ R/report.coxph.R | 30 ++++++++++++++++++++++++++++++ R/report.lm.R | 6 ++++++ 4 files changed, 47 insertions(+) create mode 100644 R/report.coxph.R diff --git a/DESCRIPTION b/DESCRIPTION index bdb68e65..bd4cf6df 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -111,6 +111,7 @@ Collate: 'report.character.R' 'report.compare.loo.R' 'report.compare_performance.R' + 'report.coxph.R' 'report.data.frame.R' 'report.default.R' 'report.estimate_contrasts.R' diff --git a/NAMESPACE b/NAMESPACE index 3763ed14..b835971f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,6 +39,7 @@ S3method(report,brmsfit) S3method(report,character) S3method(report,compare.loo) S3method(report,compare_performance) +S3method(report,coxph) S3method(report,data.frame) S3method(report,default) S3method(report,estimate_contrasts) @@ -64,6 +65,7 @@ S3method(report_effectsize,anova) S3method(report_effectsize,aov) S3method(report_effectsize,aovlist) S3method(report_effectsize,brmsfit) +S3method(report_effectsize,coxph) S3method(report_effectsize,default) S3method(report_effectsize,glm) S3method(report_effectsize,glmmTMB) @@ -80,6 +82,7 @@ S3method(report_info,anova) S3method(report_info,aov) S3method(report_info,aovlist) S3method(report_info,brmsfit) +S3method(report_info,coxph) S3method(report_info,default) S3method(report_info,glm) S3method(report_info,glmmTMB) @@ -93,6 +96,7 @@ S3method(report_info,survreg) S3method(report_info,zeroinfl) S3method(report_intercept,MixMod) S3method(report_intercept,brmsfit) +S3method(report_intercept,coxph) S3method(report_intercept,default) S3method(report_intercept,glm) S3method(report_intercept,glmmTMB) @@ -108,6 +112,7 @@ S3method(report_model,anova) S3method(report_model,aov) S3method(report_model,aovlist) S3method(report_model,brmsfit) +S3method(report_model,coxph) S3method(report_model,default) S3method(report_model,glm) S3method(report_model,glmmTMB) @@ -127,6 +132,7 @@ S3method(report_parameters,aovlist) S3method(report_parameters,brmsfit) S3method(report_parameters,character) S3method(report_parameters,compare_performance) +S3method(report_parameters,coxph) S3method(report_parameters,data.frame) S3method(report_parameters,default) S3method(report_parameters,factor) @@ -147,6 +153,7 @@ S3method(report_parameters,test_performance) S3method(report_parameters,zeroinfl) S3method(report_performance,MixMod) S3method(report_performance,brmsfit) +S3method(report_performance,coxph) S3method(report_performance,default) S3method(report_performance,glm) S3method(report_performance,glmmTMB) @@ -177,6 +184,7 @@ S3method(report_statistics,aovlist) S3method(report_statistics,brmsfit) S3method(report_statistics,character) S3method(report_statistics,compare_performance) +S3method(report_statistics,coxph) S3method(report_statistics,data.frame) S3method(report_statistics,default) S3method(report_statistics,factor) @@ -203,6 +211,7 @@ S3method(report_table,bayesfactor_models) S3method(report_table,brmsfit) S3method(report_table,character) S3method(report_table,compare_performance) +S3method(report_table,coxph) S3method(report_table,data.frame) S3method(report_table,default) S3method(report_table,estimate_contrasts) @@ -233,6 +242,7 @@ S3method(report_text,bayesfactor_models) S3method(report_text,brmsfit) S3method(report_text,character) S3method(report_text,compare_performance) +S3method(report_text,coxph) S3method(report_text,data.frame) S3method(report_text,default) S3method(report_text,estimate_contrasts) diff --git a/R/report.coxph.R b/R/report.coxph.R new file mode 100644 index 00000000..230abac3 --- /dev/null +++ b/R/report.coxph.R @@ -0,0 +1,30 @@ +#' @include report.lm.R +#' @export +report.coxph <- report.lm + +#' @export +report_effectsize.coxph <- report_effectsize.lm + +#' @export +report_table.coxph <- report_table.lm + +#' @export +report_statistics.coxph <- report_statistics.lm + +#' @export +report_parameters.coxph <- report_parameters.lm + +#' @export +report_intercept.coxph <- report_intercept.lm + +#' @export +report_model.coxph <- report_model.lm + +#' @export +report_performance.coxph <- report_performance.lm + +#' @export +report_info.coxph <- report_info.lm + +#' @export +report_text.coxph <- report_text.lm diff --git a/R/report.lm.R b/R/report.lm.R index 904c8ce1..69df2167 100644 --- a/R/report.lm.R +++ b/R/report.lm.R @@ -345,6 +345,12 @@ report_intercept.lm <- function(x, table = NULL, ...) { } else { idx <- !is.na(table$Parameter) & table$Parameter == "(Intercept)" } + + # sanity check - if model has no intercept, return NULL + if (!any(idx)) { + return(NULL) + } + intercept <- table[idx, ] estimate <- .find_regression_estimate(table)