Skip to content

Commit c35b356

Browse files
author
NightlordTW
committed
enhance output
1 parent fb91ab0 commit c35b356

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

R/helper.r

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,44 @@ print.simss <- function(x, ...) {
2323

2424
cat("Sample Size Calculation Results\n")
2525
cat("-------------------------------------------------------------\n")
26-
cat(paste0("Study Design: ", x$param.d$dtype, " trial targeting ",100*tpower,"% power with a ",100*alpha, "% type-I error.\n"))
27-
cat("Endpoints Tested:\n")
26+
cat(paste0("Study Design: ", x$param.d$dtype, " trial targeting ",100*tpower,"% power with a ",100*alpha, "% type-I error.\n\n"))
27+
cat("Comparisons:\n")
2828
for (i in 1:length(x$param$list_comparator)) {
2929
nendp <- length(x$param$list_y_comparator[[i]])
30-
str <- paste0(" - ", paste(x$param$list_comparator[[i]], collapse = " vs. "), ": ",
31-
paste(x$param$list_y_comparator[[i]], collapse = ", "))
30+
cat(" ", paste(x$param$list_comparator[[i]], collapse = " vs. "), "\n")
31+
cat(" - Endpoints Tested:", paste(x$param$list_y_comparator[[i]], collapse = ", "), "\n")
3232
if (nendp > 1 & x$param.d$k[i] < nendp) {
33-
str <- paste0(str, " (multiple primary endpoints, k = ", x$param.d$k[i], ")\n")
33+
cat(" (multiple primary endpoints, k = ", x$param.d$k[i], ")\n")
3434
} else if (nendp > 1 & x$param.d$k[i] == nendp) {
35-
str <- paste0(str, " (multiple co-primary endpoints, m = ", x$param.d$k[i], ")\n")
35+
cat(" (multiple co-primary endpoints, m = ", x$param.d$k[i], ")\n")
3636
}
37-
cat(str)
38-
}
39-
40-
cat("Multiplicity Correction:\n")
41-
for (i in 1:length(x$param$list_comparator)) {
42-
nendp <- length(x$param$list_y_comparator[[i]])
43-
str <- paste0(" - ", paste(x$param$list_comparator[[i]], collapse = " vs. "), ": ")
4437
if (x$param.d$adjust == "no") {
45-
str <- paste0(str, " no adjustment (alpha = ", x$param.d$alpha, ")\n")
38+
multiplicity_correction <- "No Adjustment"
39+
#cat(paste0(" no adjustment (alpha = ", x$param.d$alpha, ")\n"))
4640
} else if (x$param.d$adjust == "bon") {
41+
multiplicity_correction <- "Bonferroni"
4742
alphau <- x$param.d$alpha/nendp
48-
str <- paste0(str, " bonferroni (alpha = ", format(alphau, digits = 3, nsmall = 3), ")\n")
4943
} else if (x$param.d$adjust == "sid") {
44+
multiplicity_correction <- "Sidak"
5045
alphau <- 1-(1-x$param.d$alpha)^(1/nendp)
51-
str <- paste0(str, " sidak (alpha = ", format(alphau, digits = 3, nsmall = 3), ")\n")
5246
} else if (x$param.d$adjust == "k") {
47+
multiplicity_correction <- "k-adjustment"
5348
alphau <- x$param.d$k[i]*x$param.d$alpha/nendp
54-
str <- paste0(str, " k-adjustment (alpha = ", format(alphau, digits = 3, nsmall = 3), ")\n")
5549
} else if (x$param.d$adjust == "seq") {
56-
str <- paste0(str, " sequential (alpha = ", paste(x$param.d$alpha*x$param$weight_seq, collapse = "; "), ")\n")
50+
multiplicity_correction <- "Sequential"
51+
alphau <- x$param.d$alpha*x$param$weight_seq
5752
}
58-
cat(str)
53+
54+
cat(" - Multiplicity Correction:", multiplicity_correction, "\n")
55+
cat(" - Adjusted Significance Levels: α =", paste(format(alphau, digits = 3, nsmall = 3), collapse = "; "), "\n\n")
56+
5957
}
6058

59+
60+
6161
cat("-------------------------------------------------------------\n")
6262
print(output, row.names = FALSE) # Suppress row numbers
63+
cat("-------------------------------------------------------------\n")
6364
#cat("-------------------------------------------------------------\n")
6465
#print(x$response[,-1], row.names = FALSE)
6566
}

0 commit comments

Comments
 (0)