Skip to content

Commit

Permalink
Merge branch 'issue-4' into develop (close #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Aug 1, 2023
2 parents 75a2a5a + 86c1f8e commit d5e776f
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: permChacko
Title: Chacko Test for Order-Restriction with Permutation
Version: 0.1.0.9000
Version: 0.1.0.9001
Authors@R:
c(
person(
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
@@ -1,5 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(chacko66_3)
export(chacko66_5)
export(permChacko)
export(reduceVector)
importFrom(stats,pchisq)
importFrom(stats,weighted.mean)
3 changes: 2 additions & 1 deletion NEWS.md
@@ -1,6 +1,7 @@
# permChacko (development version)

* Replaced `verbose` with `verbosity` in functions to allow for more control over the output (issue #3).
* Replaced `verbose` with `verbosity` in functions to allow for more control over the output ([issue #3](https://github.com/ocbe-uio/permChacko/issues/3)).
* Exported `reduceVector()` ([issue #4](https://github.com/ocbe-uio/permChacko/issues/4)).

# permChacko 0.1.0

Expand Down
2 changes: 2 additions & 0 deletions R/datasets.R
Expand Up @@ -29,6 +29,7 @@ chacko_1963_table_1 <- matrix(
#' Sankhyā: The Indian Journal of Statistics, Series B, 185-190.
#' @name chacko66_3
#' @docType data
#' @export
chacko66_3 <- c("x1" = 10L, "x2" = 16L, "x3" = 14L, "x4" = 12L, "x5" = 18L)

#' @title Chacko (1966), section 5
Expand All @@ -41,6 +42,7 @@ chacko66_3 <- c("x1" = 10L, "x2" = 16L, "x3" = 14L, "x4" = 12L, "x5" = 18L)
#' Sankhyā: The Indian Journal of Statistics, Series B, 185-190.
#' @name chacko66_5
#' @docType data
#' @export
chacko66_5 <- c(
"x1" = 12L, "x2" = 14L, "x3" = 18L, "x4" = 16L, "x5" = 22L,
"x6" = 20L, "x7" = 18L, "x8" = 24L, "x9" = 26L, "x10" = 30L
Expand Down
16 changes: 15 additions & 1 deletion R/reduceVector.R
Expand Up @@ -4,6 +4,20 @@
# values, then you have a 20% chance that this process that the order process
# results in a single value.

#' @title Reduce a vector using the ordering process
#' @description This function implements the ordering process described in
#' Chacko (1963) and Chacko (1966).
#' @param x a vector of numeric values
#' @param verbosity a natural number indicating the amount of output to print
#' @return A matrix with two columns: the first one is the reduced vector and
#' the second one is its weight
#' @author Waldir Leoncio
#' @export
#' @examples
#' reduceVector(c(10, 16, 14, 12, 18))
#' reduceVector(c(10, 8, 4, 2, 1))
#' reduceVector(chacko66_3)
#' reduceVector(chacko66_5)
reduceVector <- function(x, verbosity = 0L) {
x_t <- cbind("x" = unname(x), "t" = unname(x) ^ 0L)
while (nrow(x_t) > 1L && isMonotoneIncreasing(x_t[, "x"])) {
Expand All @@ -13,5 +27,5 @@ reduceVector <- function(x, verbosity = 0L) {
}
x_t <- orderingProcess(x_t, verbosity)
}
return(invisible(x_t))
return(x_t)
}
30 changes: 30 additions & 0 deletions man/reduceVector.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5e776f

Please sign in to comment.