checkHistogram: Check any estimator by means of the multiscale confidence set

Description Usage Arguments Value Note References See Also Examples

View source: R/checkHistogram.R

Description

Give the locations (i.e. intervals) where the multiscale constraint is violated, and the change-points that are removable.

Usage

1
2
checkHistogram(h, y, alpha = 0.1, q = NA, plot = TRUE, verbose = TRUE,
               xlim = range(y), ylim = NULL, xlab = "", ylab = "", yaxt = "n", ...)

Arguments

h

a numeric vector specifying values of a histogram at sample points or a hitogram class object (i.e. the return value of hist).

y

a numeric vector containing the data.

alpha

significance level; if q is missing, q is chosen as the (1-alpha)-quantile of the null distribution of the multiscale statistic via Monte Carlo simulation, see also msQuantile.

q

threshold of the multiscale constraint.

plot

logical. If TRUE, the input estimator is potted, together with evaluation information. More precisely, at the very bottom, intervals where local constaints are violated are plotted. In the middle short vertical lines that indicate possibly removable change-points are drawn above a light blue horizontal line. Right below the light blue line, it plots a horizontal gray scale strap, the darkness of which reflects the number of violation intervals covering a given location, as a summary of violation information.

verbose

logical. If TRUE (default) it prints some details about the computation; otherwise nothing is printed.

xlim, ylim

numeric vectors of length 2 (default xlim = range(y), ylim = NULL): see plot.

xlab

a title for the x axis (default empty string): see title and plot.

ylab

a title for the y axis (default empty string): see title and plot.

yaxt

A character which specifies the y axis type (default "n"): see par.

...

further arguments and graphical parameters passed to plot (if plot = TRUE).

Value

A data frame provides the intervals where the corresponding local side constraint is violated; an empty data frame if there is no violation. The data frame constains the following four columns

leftIndex

left index of an interval

rightIndex

right index of an interval

leftEnd

left end point of an interval

rightEnd

right end point of an interval

Note

Only the intervals on which the input histogram is constant will be checked!

References

Li, H., Munk, A., Sieling, H., and Walther, G. (2016). The essential histogram. arXiv:1612.07216.

See Also

msQuantile, essHistogram

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(123)
# Data: mixture of Gaussians 1/3 N(0,0.5) + 1/3 N(5,1) + 1/3 N(15,2)
n  = 500
y  = rmixnorm(n, mean = c(0, 5, 15), sd = c(0.5, 1, 2))

# Oracle density
sy = sort(y)
ho = dmixnorm(sy, mean = c(0, 5, 15), sd = c(0.5, 1, 2))

# R default histogram
h  = hist(y, plot = FALSE)

# Check R default histogram to local multiscale constriants
b = checkHistogram(h, y)
lines(sy, ho, col = "red")
legend("topright", c("R-Histogram", "Truth"), col = c("black", "red"), lty = c(1,1))

essHist documentation built on April 9, 2018, 5:04 p.m.