Skip to content

Commit

Permalink
Added more info to printed output (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Aug 31, 2023
1 parent 0b80aae commit 470e35d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
20 changes: 13 additions & 7 deletions R/permChacko.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ permChacko <- function(x, n_perm = 1000L, verbosity = 0) {
table_p_value <- NA
}
if (verbosity >= 1L) message("\nTest statistics")
statistics <- c(
"chisq_bar" = chisq_bar,
"analytic_p-value" = anal_p_value,
"numeric_p-value" = perm_p_value,
"tabular_p-value" = table_p_value
p_values <- c(
"analytic" = anal_p_value,
"numeric" = perm_p_value,
"tabular" = table_p_value
)
class(statistics) <- "chacko_test"
return(statistics)
out <- list(
statistic = chisq_bar,
p_values = p_values,
n_perm = n_perm,
observed_data = x,
reduced_data = x_t
)
class(out) <- "chacko_test"
return(out)
}
25 changes: 19 additions & 6 deletions R/print.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#' @export
print.chacko_test <- function(x, ...) {
cat("Chacko test for order-restriction with permutation test\n\n")
cat("Test statistic (chisq_bar):", x[["chisq_bar"]], "\n")
cat("p-values:\n")
cat(" Analytic p-value: ", x[["analytic_p-value"]], "\n")
cat(" Numeric p-value: ", x[["numeric_p-value"]], "\n")
cat(" Tabular p-value: ", x[["tabular_p-value"]], "\n")
p_values <- x[["p_values"]]
cat(
sprintf(
paste0(
" Chacko Test for Order-restriction with Permutation Test\n\n",
"Null hypothesis : %s\n",
"Alternative hypothesis: %s\n\n",
"Test statistic (chisq_bar): %f\n",
"p-values:\n",
" Analytic p-value: %f\n",
" Numeric p-value: %f (%d permutations)\n",
" Tabular p-value: %f\n\n"
),
paste0("p", seq_along(x$observed_data), collapse = " == "),
paste0("p", seq_along(x$observed_data), collapse = " <= "),
x[["statistic"]], p_values[["analytic"]],
p_values[["numeric"]], x[["n_perm"]], p_values[["tabular"]]
)
)
}

0 comments on commit 470e35d

Please sign in to comment.