-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-7' into develop (close #7)
- Loading branch information
Showing
9 changed files
with
107 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method(print,chacko_test) | ||
S3method(print,reduced_vector) | ||
export(chacko63_tab1) | ||
export(chacko66_sec3) | ||
export(chacko66_sec5) | ||
export(permChacko) | ||
export(reduceVector) | ||
export(ruxton221207) | ||
importFrom(stats,pchisq) | ||
importFrom(stats,weighted.mean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' @export | ||
print.chacko_test <- function(x, ...) { | ||
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"]] | ||
) | ||
) | ||
} | ||
|
||
#' @export | ||
print.reduced_vector <- function(x, details = TRUE, ...) { | ||
if (x[["verbose"]] >= 1L) { | ||
cat(sprintf("Original vector has been reduced %d times", x[["reductions"]])) | ||
} else { | ||
cat( | ||
sprintf( | ||
paste0( | ||
"Original vector: %s\n", | ||
"Reduced vector : %s\n", | ||
"Final weights : %s\n", | ||
"Original vector has been reduced %d times\n\n", | ||
"Run reduceVector() with verbosity > 1) to see the reduction process" | ||
), | ||
paste0(x[["original_vector"]], collapse = "\t"), | ||
paste0(x[["reduced_vector"]], collapse = "\t"), | ||
paste0(x[["weights"]], collapse = "\t"), | ||
x[["reductions"]] | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
test_that("Examples from Chacko (1966) produce correct vectors", { | ||
expect_equal(reduceVector(chacko66_sec3)[, "x"], c(10, 14, 18)) | ||
expect_equal(reduceVector(chacko66_sec3)[, "t"], c(1, 3, 1)) | ||
expect_equal(reduceVector(chacko66_sec5)[, 1], c(12, 14, 17, 20, 24, 26, 30)) | ||
expect_equal(reduceVector(chacko66_sec5)[, 2], c(1, 1, 2, 3, 1, 1, 1)) | ||
expect_equal(permChacko(chacko66_sec3)[["chisq_bar"]], 2.2857143) | ||
expect_equal(permChacko(chacko66_sec5)[["chisq_bar"]], 13.5) | ||
test_that("Vector reduction procedure works well", { | ||
c66s3 <- reduceVector(chacko66_sec3) | ||
c66s5 <- reduceVector(chacko66_sec5) | ||
expect_equal(c66s3[["x_t"]][, "x"], c(10, 14, 18)) | ||
expect_equal(c66s3[["x_t"]][, "t"], c(1, 3, 1)) | ||
expect_equal(c66s5[["x_t"]][, 1], c(12, 14, 17, 20, 24, 26, 30)) | ||
expect_equal(c66s5[["x_t"]][, 2], c(1, 1, 2, 3, 1, 1, 1)) | ||
}) | ||
|
||
test_that("Examples from Chacko (1966) produce correct statistics", { | ||
set.seed(3174) | ||
c66s3 <- permChacko(chacko66_sec3) | ||
c66s5 <- permChacko(chacko66_sec5) | ||
expect_output( | ||
print(c66s3), | ||
"Chacko Test for Order-restriction with Permutation Test" | ||
) | ||
expect_equal(c66s3[["statistic"]], 2.2857143) | ||
expect_equal(c66s5[["statistic"]], 13.5) | ||
expect_equal( | ||
permChacko(chacko66_sec3)[["numeric_p-value"]], | ||
permChacko(chacko66_sec3)[["tabular_p-value"]], | ||
c66s3[["p_values"]][["numeric"]], | ||
c66s3[["p_values"]][["tabular"]], | ||
tolerance = 1e-1 | ||
) | ||
expect_equal( | ||
permChacko(chacko66_sec5)[["numeric_p-value"]], | ||
permChacko(chacko66_sec5)[["tabular_p-value"]], | ||
c66s5[["p_values"]][["numeric"]], | ||
c66s5[["p_values"]][["tabular"]], | ||
tolerance = 1e-1 | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters