Skip to content

Commit

Permalink
added data set
Browse files Browse the repository at this point in the history
  • Loading branch information
Happ Martin committed Oct 1, 2018
1 parent 232feac commit 306774d
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
useDynLib(pseudorank, .registration=TRUE)
export(psrank, pseudorank, hettmansperger_norton_test, kruskal_wallis_test, kepner_robinson_test)
export(psrank, pseudorank, hettmansperger_norton_test, kruskal_wallis_test)
S3method(pseudorank, numeric)
S3method(pseudorank, formula)
S3method(print, pseudorank)
Expand Down
5 changes: 1 addition & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# pseudorank 0.3.6
* Changed function name ''psrank'' to ''pseudorank'' and set ''psrank'' as deprecated.

# pseudorank 0.3.5
* Added the Kepner-Robinson test for one-sample problems in repeated measures designs with compound symmetry covariance structure.

* Added a data set which can be used to show paradoxical results from rank tests.

# pseudorank 0.3.0

Expand Down
6 changes: 3 additions & 3 deletions R/S3method.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ kruskal_wallis_test.formula <- function(formula, data, na.rm = FALSE, pseudorank
#' @return Returns an object of class 'pseudorank'
#' @example R/example_4.txt
#' @references James L. Kepner & David H. Robinson (1988) Nonparametric Methods for Detecting Treatment Effects in Repeated-Measures Designs, Journal of the American Statistical Association, 83:402, 456-461.
#' @keywords export
#' @keywords internal
kepner_robinson_test <- function(x, ...) {
UseMethod("kepner_robinson_test")
}

#' @method kepner_robinson_test numeric
#' @rdname kepner_robinson_test
#' @keywords export
#' @keywords internal
kepner_robinson_test.numeric <- function(x, time, subject, na.rm = FALSE, distribution = c("Chisq", "F"), ...) {
distribution = match.arg(distribution)
return(kepner_robinson_test_internal(data=x, time=as.factor(time), subject=as.factor(subject), na.rm = na.rm, distribution = distribution, formula = NULL, ...))
}

#' @method kepner_robinson_test formula
#' @rdname kepner_robinson_test
#' @keywords export
#' @keywords internal
kepner_robinson_test.formula <- function(formula, data, subject, na.rm = FALSE, distribution = c("Chisq", "F"), ...) {
stopifnot(is.character(subject))
distribution = match.arg(distribution)
Expand Down
24 changes: 24 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
################################################################################
### File: data.R
### Description: data object
###
################################################################################

#' Artifical data of 54 subjects
#'
#' An artificial dataset containing data of 54 subjects where where a substance was administered in three different concentrations (1,2 and 3).
#' This data set can be used to show the paradoxical results obtained from rank tests, i.e., the Hettmansperger-Norton test.
#'
#' The columns are as follows:
#' \itemize{
#' \item conc. Grouping variable specifying which concentration was used. This factor is ordered, i.e., 1 < 2 < 3.
#' \item score. The response variable.
#' }
#'
#' @docType data
#' @keywords datasets
#' @name ParadoxicalRanks
#' @usage data(ParadoxicalRanks)
#' @format A data frame with 54 rows and 2 variables.
#' @example R/example_paradoxical_results.txt
"ParadoxicalRanks"
20 changes: 20 additions & 0 deletions R/example_paradoxical_results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
data("ParadoxicalRanks")
dat <- ParadoxicalRanks

set.seed(1)
n <- c(60, 360, 120)
x1 <- sample(subset(dat, dat$conc == 1)$score, n[1], replace = TRUE)
x2 <- sample(subset(dat, dat$conc == 2)$score, n[2], replace = TRUE)
x3 <- sample(subset(dat, dat$conc == 3)$score, n[3], replace = TRUE)


dat <- data.frame(score = c(x1, x2, x3),
conc = factor(c( rep(1,n[1]), rep(2,n[2]), rep(5,n[3]) ), ordered=T) )

# Hettmansperger-Norton test with ranks (pseudorannks = FALSE) returns a small p-value (0.011).
# In contrast, the pseudo-rank test returns a large p-value (0.42). By changing the ratio of
# group sizes, we can also obtain a significant decreasing trend with ranks.
hettmansperger_norton_test(score ~ conc, data = dat, pseudoranks = FALSE,
alternative = "increasing")
hettmansperger_norton_test(score ~ conc, data = dat, pseudoranks = TRUE,
alternative = "increasing")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pseudorank 0.3.5
# pseudorank 0.3.6

[![CRANstatus](https://www.r-pkg.org/badges/version/pseudorank)](https://cran.r-project.org/package=pseudorank)
[![](https://cranlogs.r-pkg.org/badges/pseudorank)](https://cran.r-project.org/package=pseudorank)
Expand Down
Binary file added data/ParadoxicalRanks.rda
Binary file not shown.
44 changes: 44 additions & 0 deletions man/ParadoxicalRanks.Rd

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

2 changes: 1 addition & 1 deletion man/kepner_robinson_test.Rd

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

0 comments on commit 306774d

Please sign in to comment.