Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objects of class [clogit, coxph] are not supported by report() #446

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
30 changes: 30 additions & 0 deletions R/report.coxph.R
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions R/report.lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
#' @export

report.lm <- function(x, include_effectsize = TRUE, effectsize_method = "refit", ...) {
table <- report_table(x,

Check warning on line 56 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=56,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.
include_effectsize = include_effectsize,
effectsize_method = effectsize_method, ...
)
text <- report_text(x,

Check warning on line 60 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=60,col=3,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
table = table, ...
)

Expand All @@ -72,7 +72,7 @@
#' @export

report_effectsize.lm <- function(x, effectsize_method = "refit", ...) {
table <- suppressWarnings(effectsize::effectsize(x, method = effectsize_method, ...))

Check warning on line 75 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=75,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.
method <- .text_standardize(table)
estimate <- names(table)[effectsize::is_effectsize_name(names(table))]

Expand Down Expand Up @@ -105,7 +105,7 @@
start_col <- 3L
}

table <- as.data.frame(table)[c(merge_by, estimate, "CI_low", "CI_high")]

Check warning on line 108 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=108,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.
names(table)[start_col:ncol(table)] <- c(paste0(estimate, "_CI_low"), paste0(estimate, "_CI_high"))

rules <- .text_effectsize(attr(attr(interpret, "rules"), "rule_name"))
Expand Down Expand Up @@ -162,13 +162,13 @@
params <- datawizard::data_remove(params, "df_error")
}
table_full <- datawizard::data_remove(params, "SE")
table <- datawizard::data_remove(

Check warning on line 165 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=165,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.
table_full,
select = "(_CI_low|_CI_high)$",
regex = TRUE,
verbose = FALSE
)
table <- table[!table$Parameter %in% c("AIC", "BIC", "ELPD", "LOOIC", "WAIC"), ]

Check warning on line 171 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=171,col=3,[object_overwrite_linter] 'table' is an exported object from package 'base'. Avoid re-using such symbols.

# Prepare -----
out <- as.report_table(table_full,
Expand Down Expand Up @@ -205,16 +205,16 @@
# Estimate
estimate <- .find_regression_estimate(table)
if (is.null(estimate) || is.na(estimate) || !estimate %in% names(table)) {
text <- ""

Check warning on line 208 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=208,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
} else if (estimate == "Coefficient") {
text <- paste0("beta = ", insight::format_value(table[[estimate]]))

Check warning on line 210 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=210,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
} else {
text <- paste0(estimate, " = ", insight::format_value(table[[estimate]]))

Check warning on line 212 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=212,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
}

# CI
if (!is.null(table$CI_low)) {
text <- datawizard::text_paste(text, insight::format_ci(table$CI_low, table$CI_high, ci = attributes(table)$ci))

Check warning on line 217 in R/report.lm.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report.lm.R,line=217,col=5,[object_overwrite_linter] 'text' is an exported object from package 'graphics'. Avoid re-using such symbols.
}

# Statistic
Expand Down Expand Up @@ -345,6 +345,12 @@
} 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)
Expand Down
Loading