npMeanSingle: A test for the mean of a bounded random variable based on a...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This test requires that the user knows upper and lower bounds before gathering the data such that the properties of the data generating process imply that all observations will be within these bounds. The data input consists of a sequence of observations, each being an independent realization of the random variable. No further distributional assumptions are made.

Usage

1
2
3
npMeanSingle(x, mu, lower = 0, upper = 1, alternative = "two.sided",
  iterations = 5000, alpha = 0.05, epsilon = 1 * 10^(-6),
  ignoreNA = FALSE, max.iterations = 100000)

Arguments

x

a (non-empty) numeric vector of data values.

mu

threshold value for the null hypothesis.

lower, upper

the theoretical lower and upper bounds on the data outcomes known ex-ante before gathering the data.

alternative

a character string describing the alternative hypothesis, can take values "greater", "less" or "two.sided".

iterations

the number of iterations used, should not be changed if the exact solution should be derived

alpha

the type I error.

epsilon

the tolerance in terms of probability of the Monte Carlo simulations.

ignoreNA

if TRUE, NA values will be omitted. Default: FALSE

max.iterations

the maximum number of iterations that should be carried out. This number could be increased to achieve greater accuracy in cases where the difference between the threshold probability and theta is small. Default: 10000

Details

For any μ that lies between the two bounds, under alternative = "greater", it is a test of the null hypothesis H_0 : E(X) ≤ μ against the alternative hypothesis H_1 : E(X) > μ.

Using the known bounds, the data is transformed to lie in [0, 1] using an affine transformation. Then the data is randomly transformed into a new data set that has values 0, mu and 1 using a mean preserving transformation. The exact randomized binomial test is then used to calculate the rejection probability of this under new data when level is theta*alpha. This random transformation is repeated iterations times. If the average rejection probability is greater than theta, one can reject the null hypothesis. If however the average rejection probability is too close to theta then the iterations are continued. The values of theta and a value of mu in the alternative hypothesis is found in an optimization procedure to maximize the set of parameters in the alternative hypothesis under which the type II error probability is below 0.5. Please see the cited paper below for further information.

Value

A list with class "nphtest" containing the following components:

method

a character string indicating the name and type of the test that was performed.

data.name

a character string giving the name(s) of the data.

alternative

a character string describing the alternative hypothesis.

estimate

the estimated mean or difference in means depending on whether it was a one-sample test or a two-sample test.

probrej

numerical estimate of the rejection probability of the randomized test, derived by taking an average of iterations realizations of the rejection probability.

bounds

the lower and upper bounds of the variables.

null.value

the specified hypothesized value of the correlation between the variables.

alpha

the type I error

theta

the parameter that minimizes the type II error.

pseudoalpha

theta*alpha, this is the level used when calculating the average rejection probability during the iterations.

rejection

logical indicator for whether or not the null hypothesis can be rejected.

iterations

the number of iterations that were performed.

Author(s)

Karl Schlag, Peter Saffert and Oliver Reiter

References

Schlag, Karl H. 2008, A New Method for Constructing Exact Tests without Making any Assumptions, Department of Economics and Business Working Paper 1109, Universitat Pompeu Fabra. Available at https://ideas.repec.org/p/upf/upfgen/1109.html.

See Also

https://homepage.univie.ac.at/karl.schlag/statistics.php

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## test whether Americans gave more than 5 dollars in a round of
## the Ultimatum game
data(bargaining)
us_offers <- bargaining$US
npMeanSingle(us_offers, mu = 5, lower = 0, upper = 10, alternative =
"greater", ignoreNA = TRUE) ## no rejection

## test if the decrease in pain before and after the surgery is smaller
## than 50
data(pain)
pain$decrease <- with(pain, before - after)
without_pc <- pain[pain$pc == 0, "decrease"]
npMeanSingle(without_pc, mu = 50, lower = 0, upper = 100,
alternative = "less")

zauster/npExact documentation built on May 4, 2019, 9:12 p.m.