Learn R Programming

MKinfer (version 1.3)

h0plot: Visualize Distribution of Test Statistic.

Description

The function visualizes the distribution of the test statistic.

Usage

h0plot(x, ...)

# S3 method for default h0plot(x, statistic, pval, alternative = "two.sided", sig.level = 0.05, hist.alpha = 0.2, stat.col = "darkgreen", dens.col = "black", dens.alpha = 0.5, cval.col = "darkred", lwd = 1, breaks = NULL, digits = 3, ...)

# S3 method for htest h0plot(x, sig.level = 0.05, hist.alpha = 0.2, stat.col = "darkgreen", dens.col = "black", dens.alpha = 0.5, cval.col = "darkred", lwd = 1, breaks = NULL, digits = 3, qtail = 1e-3, n = 501, ...)

# S3 method for perm.htest h0plot(x, sig.level = 0.05, hist.alpha = 0.2, stat.col = "darkgreen", dens.col = "black", dens.alpha = 0.5, cval.col = "darkred", lwd = 1, breaks = NULL, digits = 3, ...)

# S3 method for boot.htest h0plot(x, sig.level = 0.05, hist.alpha = 0.2, stat.col = "darkgreen", dens.col = "black", dens.alpha = 0.5, cval.col = "darkred", lwd = 1, breaks = NULL, digits = 3, ...)

Value

ggplot object

Arguments

x

bootstrap/permuation results of the test statistic or result of class htest, perm.htest, or boot.htest.

statistic

test statistic of the test on the original data.

pval

p value of the test.

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.

sig.level

significance level of the test.

hist.alpha

opacity used for geom_histogram.

stat.col

color used for line representing the (final) test statistic.

dens.col

color used for the density line.

dens.alpha

opacity used for geom_area to color the rejection region.

cval.col

color used for rejection region (area under the density beyond the critical value).

lwd

line width used for line representing the (final) test statistic as well ase for geom_density.

breaks

argument breaks of geom_histogram.

digits

number of significant digits used for p values.

qtail

tail quantile to determine plot limits of x-axis.

n

integer; the number of x values at which to evaluate.

...

further arguments that may be passed through.

Author

Matthias Kohl Matthias.Kohl@stamats.de

Details

The function can be used to plot the distribution of the test statistic under H0.

In case of class htest the implementation so far covers t.test, oneway.test, and var.test. In principle, the function should work for all tests of class htest returning a t or F statistic.

References

B. Efron, R.J. Tibshirani. An Introduction to the Bootstrap. Chapman and Hall/CRC 1993.

A. Janssen (1997). Studentized permutation tests for non-i.i.d, hypotheses and the generalized Behrens-Fisher problem. Statistics and Probability Letters, 36, 9-21.

E. Chung, J.P. Romano (2013). Exact and asymptotically robust permutation tests. The Annals of Statistics, 41(2), 484-507.

Examples

Run this code
## Welch t-Test
h0plot(t.test(extra ~ group, data = sleep))
h0plot(t.test(extra ~ group, data = sleep, alternative = "less"))

## Hsu t-Test
h0plot(hsu.t.test(extra ~ group, data = sleep))
h0plot(hsu.t.test(extra ~ group, data = sleep, alternative = "less"))

## Welch 1-Way ANOVA
h0plot(oneway.test(extra ~ group, data = sleep))

## F test to compare two variances 
h0plot(var.test(extra ~ group, data = sleep))

## Bootstrap based Welch t-Test
h0plot(boot.t.test(extra ~ group, data = sleep, bootStat = TRUE))
h0plot(boot.t.test(extra ~ group, data = sleep, bootStat = TRUE, 
                   alternative = "less"))

## Permutation based Welch t-Test
h0plot(perm.t.test(extra ~ group, data = sleep, permStat = TRUE))
h0plot(perm.t.test(extra ~ group, data = sleep, permStat = TRUE, 
                   alternative = "less"))

Run the code above in your browser using DataLab