Package 'fuzzyRankTests'

Title: Fuzzy Rank Tests and Confidence Intervals
Description: Does fuzzy tests and confidence intervals (following Geyer and Meeden, Statistical Science, 2005, <doi:10.1214/088342305000000340>) for sign test and Wilcoxon signed rank and rank sum tests.
Authors: Charles J. Geyer <[email protected]>
Maintainer: Charles J. Geyer <[email protected]>
License: MIT + file LICENSE
Version: 0.4
Built: 2025-02-04 03:22:47 UTC
Source: https://github.com/cran/fuzzyRankTests

Help Index


Fuzzy P-value, Decision, or Confidence Interval for the Rank Sum Test

Description

Calculate the fuzzy P-value, the fuzzy decision, or the fuzzy confidence interval associated with the Mann-Whitney-Wilcoxon rank sum test.

Usage

fuzzy.ranksum.test(x, y, alternative = c("two.sided", "less", "greater"),
    mu = 0, tol = sqrt(.Machine$double.eps), alpha)
fuzzy.ranksum.ci(x, y, alternative = c("two.sided", "less", "greater"),
    tol = sqrt(.Machine$double.eps), conf.level = 0.95)

Arguments

x

numeric vector of data values.

y

numeric vector of data values.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number specifying the value of the median of the data distribution hypothesized under the null hypothesis.

tol

data values within tol of mu are considered equal to mu.

alpha

if missing, calculate the fuzzy P-value. If provided, must be between zero and one, then calculate the fuzzy decision.

conf.level

confidence level.

Details

The fuzzy P-value is a random variable taking values in the interval (0,1)(0, 1). Its cumulative distribution function (CDF) is continuous and piecewise linear. Hence its probability density function (PDF) is piecewise constant (a step function). If PP is the fuzzy P-value, considered as a random variable, then the randomized test that rejects the null hypothesis at significance level α\alpha when P<αP < \alpha is an exact (randomized) test.

The fuzzy confidence interval is a fuzzy set, whose “membership function” is a function on the parameter space taking values in the interval [0,1][0, 1]. For rank tests, it is piecewise constant (a step function). In the regular case, it is one on a narrow interval and some number between zero and one on the part of some wider interval not contained in the narrower interval, zero outside the wider interval, and the values at jumps are the average of left and right limits. In this case, the fuzzy interval can be easily interpreted as a mixture of two confidence intervals (the narrow and the wide). When no ties are possible, the values at the jumps do not matter. Otherwise, they do. With ties, any or all of the intervals can be degenerate, and the values at the jumps are not related to left and right limits. If I(μ)I(\mu) is the membership function of the fuzzy confidence interval, then the randomized test that rejects the null hypothesis that μ\mu is the true parameter value with probability 1I(μ)1 - I(\mu) is an exact (randomized) test.

Value

A list with class "fuzzyranktest" or class "fuzzyrankci" containing some of the following components:

knots

the vector of points at which the CDF of the fuzzy P-value, which is continuous and piecewise linear, has discontinuous derivative or the vector of points at which the membership function of the fuzzy confidence is discontinuous and also -Inf or Inf if the fuzzy confidence interval is unbounded.

values

the values of the CDF of the fuzzy P-value at the knots.

knot.values

the values of the membership function of the fuzzy confidence interval at the knots.

interval.values

the values of the membership function of the fuzzy confidence interval between the knots.

reject.prob

if alpha is specified, the probability the randomized test rejects the null hypothesis, which is the same as the probability the fuzzy P-value is less than alpha.

alpha

the argument alpha.

null.value

the argument mu.

alternative

a character string describing the alternative hypothesis.

method

the type of test applied.

data.name

a character string giving the names of the data.

conf.level

the argument conf.level.

tol

the argument tol.

References

Charles J. Geyer (submitted).
Fuzzy P-values and Ties in Nonparametric Tests.
http://www.stat.umn.edu/geyer/fuzz/ties.pdf

Charles J. Geyer and Glen D. Meeden (2005).
Fuzzy and Randomized Confidence Intervals and P-values.
To appear in Statistical Science (with discussion).
http://www.stat.umn.edu/geyer/fuzz/fuzz5.pdf

See Also

plot.fuzzyrankci, plot.fuzzyranktest, print.fuzzyrankci, print.fuzzyranktest.

Examples

#### make up data ####
x <- c(1, 2, 3, 4, 4, 4, 5, 6, 7)
y <- c(4, 5, 7, 7, 8, 9, 10, 11)
fuzzy.ranksum.test(x, y)
plot(fuzzy.ranksum.test(x, y))
fuzzy.ranksum.ci(x, y)
plot(fuzzy.ranksum.ci(x, y))

Fuzzy P-value, Decision, or Confidence Interval for the Sign Test

Description

Calculate the fuzzy P-value, the fuzzy decision, or the fuzzy confidence interval associated with the sign test.

Usage

fuzzy.sign.test(x, alternative = c("two.sided", "less", "greater"),
    mu = 0, tol = sqrt(.Machine$double.eps), alpha)
fuzzy.sign.ci(x, alternative = c("two.sided", "less", "greater"),
    tol = sqrt(.Machine$double.eps), conf.level = 0.95)

Arguments

x

numeric vector of data values.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number specifying the value of the median of the data distribution hypothesized under the null hypothesis.

tol

data values within tol of mu are considered equal to mu.

alpha

if missing, calculate the fuzzy P-value. If provided, must be between zero and one, then calculate the fuzzy decision.

conf.level

confidence level.

Details

The fuzzy P-value is a random variable taking values in the interval (0,1)(0, 1). Its cumulative distribution function (CDF) is continuous and piecewise linear. Hence its probability density function (PDF) is piecewise constant (a step function). If PP is the fuzzy P-value, considered as a random variable, then the randomized test that rejects the null hypothesis at significance level α\alpha when P<αP < \alpha is an exact (randomized) test.

The fuzzy confidence interval is a fuzzy set, whose “membership function” is a function on the parameter space taking values in the interval [0,1][0, 1]. For rank tests, it is piecewise constant (a step function). In the regular case, it is one on a narrow interval and some number between zero and one on the part of some wider interval not contained in the narrower interval, zero outside the wider interval, and the values at jumps are the average of left and right limits. In this case, the fuzzy interval can be easily interpreted as a mixture of two confidence intervals (the narrow and the wide). When no ties are possible, the values at the jumps do not matter. Otherwise, they do. With ties, any or all of the intervals can be degenerate, and the values at the jumps are not related to left and right limits. If I(μ)I(\mu) is the membership function of the fuzzy confidence interval, then the randomized test that rejects the null hypothesis that μ\mu is the true parameter value with probability 1I(μ)1 - I(\mu) is an exact (randomized) test.

Value

A list with class "fuzzyranktest" or class "fuzzyrankci" containing some of the following components:

knots

the vector of points at which the CDF of the fuzzy P-value, which is continuous and piecewise linear, has discontinuous derivative or the vector of points at which the membership function of the fuzzy confidence is discontinuous and also -Inf or Inf if the fuzzy confidence interval is unbounded.

values

the values of the CDF of the fuzzy P-value at the knots.

knot.values

the values of the membership function of the fuzzy confidence interval at the knots.

interval.values

the values of the membership function of the fuzzy confidence interval between the knots.

reject.prob

if alpha is specified, the probability the randomized test rejects the null hypothesis, which is the same as the probability the fuzzy P-value is less than alpha.

alpha

the argument alpha.

statistic

the value of the test statistic with a name describing it.

null.value

the argument mu.

alternative

a character string describing the alternative hypothesis.

method

the type of test applied.

data.name

a character string giving the names of the data.

conf.level

the argument conf.level.

tol

the argument tol.

References

Charles J. Geyer (submitted).
Fuzzy P-values and Ties in Nonparametric Tests.
http://www.stat.umn.edu/geyer/fuzz/ties.pdf

Charles J. Geyer and Glen D. Meeden (2005).
Fuzzy and Randomized Confidence Intervals and P-values.
To appear in Statistical Science (with discussion).
http://www.stat.umn.edu/geyer/fuzz/fuzz5.pdf

See Also

plot.fuzzyrankci, plot.fuzzyranktest, print.fuzzyrankci, print.fuzzyranktest.

Examples

#### make up data ####
x <- c(-1.2, -0.7, 0.2, 0.2, 0.2, 0.3, 0.4, 0.9, 0.9, 1.0, 1.0,
    1.1, 1.5, 1.7, 1.9, 3.5, 5.1)
fuzzy.sign.test(x)
plot(fuzzy.sign.test(x))
fuzzy.sign.ci(x)
plot(fuzzy.sign.ci(x))

Fuzzy P-value, Decision, or Confidence Interval for the Rank Sum Test

Description

Calculate the fuzzy P-value, the fuzzy decision, or the fuzzy confidence interval associated with the Mann-Whitney-Wilcoxon rank sum test.

Usage

fuzzy.signrank.test(x, alternative = c("two.sided", "less", "greater"),
    mu = 0, tol = sqrt(.Machine$double.eps), alpha)
fuzzy.signrank.ci(x, alternative = c("two.sided", "less", "greater"),
    tol = sqrt(.Machine$double.eps), conf.level = 0.95)

Arguments

x

numeric vector of data values.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number specifying the value of the median of the data distribution hypothesized under the null hypothesis.

tol

data values within tol of mu are considered equal to mu.

alpha

if missing, calculate the fuzzy P-value. If provided, must be between zero and one, then calculate the fuzzy decision.

conf.level

confidence level.

Details

The fuzzy P-value is a random variable taking values in the interval (0,1)(0, 1). Its cumulative distribution function (CDF) is continuous and piecewise linear. Hence its probability density function (PDF) is piecewise constant (a step function). If PP is the fuzzy P-value, considered as a random variable, then the randomized test that rejects the null hypothesis at significance level α\alpha when P<αP < \alpha is an exact (randomized) test.

The fuzzy confidence interval is a fuzzy set, whose “membership function” is a function on the parameter space taking values in the interval [0,1][0, 1]. For rank tests, it is piecewise constant (a step function). In the regular case, it is one on a narrow interval and some number between zero and one on the part of some wider interval not contained in the narrower interval, zero outside the wider interval, and the values at jumps are the average of left and right limits. In this case, the fuzzy interval can be easily interpreted as a mixture of two confidence intervals (the narrow and the wide). When no ties are possible, the values at the jumps do not matter. Otherwise, they do. With ties, any or all of the intervals can be degenerate, and the values at the jumps are not related to left and right limits. If I(μ)I(\mu) is the membership function of the fuzzy confidence interval, then the randomized test that rejects the null hypothesis that μ\mu is the true parameter value with probability 1I(μ)1 - I(\mu) is an exact (randomized) test.

Value

A list with class "fuzzyranktest" or class "fuzzyrankci" containing some of the following components:

knots

the vector of points at which the CDF of the fuzzy P-value, which is continuous and piecewise linear, has discontinuous derivative or the vector of points at which the membership function of the fuzzy confidence is discontinuous and also -Inf or Inf if the fuzzy confidence interval is unbounded.

values

the values of the CDF of the fuzzy P-value at the knots.

knot.values

the values of the membership function of the fuzzy confidence interval at the knots.

interval.values

the values of the membership function of the fuzzy confidence interval between the knots.

reject.prob

if alpha is specified, the probability the randomized test rejects the null hypothesis, which is the same as the probability the fuzzy P-value is less than alpha.

alpha

the argument alpha.

null.value

the argument mu.

alternative

a character string describing the alternative hypothesis.

method

the type of test applied.

data.name

a character string giving the names of the data.

conf.level

the argument conf.level.

tol

the argument tol.

References

Charles J. Geyer (submitted).
Fuzzy P-values and Ties in Nonparametric Tests.
http://www.stat.umn.edu/geyer/fuzz/ties.pdf

Charles J. Geyer and Glen D. Meeden (2005).
Fuzzy and Randomized Confidence Intervals and P-values.
To appear in Statistical Science (with discussion).
http://www.stat.umn.edu/geyer/fuzz/fuzz5.pdf

See Also

plot.fuzzyrankci, plot.fuzzyranktest, print.fuzzyrankci, print.fuzzyranktest.

Examples

#### make up data ####
x <- c(-3, -2, -2, 0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 5, 6, 7)
fuzzy.signrank.test(x, alt = "less")
plot(fuzzy.signrank.test(x, alt = "less"))
fuzzy.signrank.ci(x)
plot(fuzzy.signrank.ci(x))

Helper Functions for Fuzzy Rank Stuff

Description

Plot or Print Fuzzy Rank Objects.

Usage

## S3 method for class 'fuzzyrankci'
plot(x, y, add = FALSE, verticals = FALSE,
    col.hor = par("col"), col.vert = par("col"), lty.vert = 2,
    pch.vert = 19, full.ylim = TRUE, extra.xlim = 0.2, main, ...)
## S3 method for class 'fuzzyranktest'
plot(x, y, type = c("pdf", "cdf"), add = FALSE,
    col.hor = par("col"), col.vert = par("col"), lty.vert = 2,
    extra.xlim = 0.2, main, ...)
## S3 method for class 'fuzzyrankci'
print(x, digits = 4, ...)
## S3 method for class 'fuzzyranktest'
print(x, digits = 4, ...)

Arguments

x

object of class "fuzzyrankci" or "fuzzyranktest".

y

not used (required because plot is generic.

type

if "pdf" plot the probability density function of the fuzzy P-value, if "cdf" plot the cumulative distribution function. You can specify just the initial letter.

add

if TRUE add to existing plot, otherwise make new plot.

verticals

if TRUE, put in vertical lines at jumps.

col.hor

color for horizontal lines of step functions.

col.vert

color for vertical lines of step functions (if requested).

lty.vert

line type for vertical lines of step functions (if requested).

pch.vert

point type (see argument pch of points) for values at jumps of step functions.

full.ylim

use ylim = c(0, 1) in the plot.

extra.xlim

make flat parts of the graph to either side of the interesting parts at least extra.xlim times the range of the interesting parts, where “interesting parts” means the part where the PDF of the fuzzy P-value or the membership function of the fuzzy confidence interval is nonzero.

main

main title for plot. Usually missing, in which case standard titles are used.

...

extra arguments passed internally to plot functions.

digits

supplied to format and print internally.

See Also

plot, print, fuzzy.sign.ci, fuzzy.sign.test.