density.reflected: Kernel Density Estimation with Reflection In GoFKernel: Testing Goodness-of-Fit with the Kernel Density Estimator

Description

The function `density.reflected` computes kernel density estimates for univariate observations using reflection in the borders.

Usage

 ```1 2``` ```## S3 method for class 'reflected' density(x, lower = -Inf, upper = Inf, weights= NULL, ...) ```

Arguments

 `x` a numeric vector of data from which the estimate is to be computed. `lower` the lower limit of the interval to which x is theoretically constrained, default -Inf. `upper` the upper limit of the interval to which x is theoretically constrained, default, Inf. `weights` numeric vector of non-negative observation weights, hence of same length as x. The default NULL is equivalent to weights = rep(1/length(x), length(x)). `...` further `density` arguments.

Details

`density.reflected` is called by `dgeometric.test` and computes the density kernel estimate of a univariate random sample `x` of a random variable defined in the interval `(lower,upper)` using the default options of `density` and reflection in the borders. This avoids the density kernel estimate being underestimated in the proximity of `lower` or `upper`. For unbounded variables, `density.reflected` generates the same output as `density` with its default options.

Value

An object of the class `density` with borders correction, whose underlying structure is a list containing the following components.

 `x` the `n` coordinates of the points where the density is estimated. `y` the estimated density values. These will be non-negative. `bw` the bandwidth used. `n` the sample size after elimination of missing values. `call` the call which produced the result. `data.name` the deparsed name of the `x` argument. `has.na` logical, for compatibility (always `FALSE`).

The `print` method reports `summary` values on the `x` and `y` components.

Note

The function is based on `density`.

Jose M. Pavia

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) "The New S Language." Wadsworth & Brooks/Cole (for S version).

Scott, D. W. (1992) "Multivariate Density Estimation. Theory, Practice and Visualization." New York: Wiley.

Sheather, S. J. and Jones M. C. (1991) "A reliable data-based bandwidth selection method for kernel density estimation." J. Roy. Statist. Soc. B, 683–690.

Silverman, B. W. (1986) "Density Estimation." London: Chapman and Hall.

Venables, W. N. and Ripley, B. D. (2002) "Modern Applied Statistics with S." New York: Springer.

`dgeometric.test` and `density`

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```set.seed(234) x <- runif(2000) dx <- density.reflected(x,0,1) ## Plot of the density estimate with and without reflection par(mfcol=c(1,2)) plot(dx, xlim=c(-0.1,1.1), ylim=c(0,1.1)) abline(h=1, col="red") plot(density(x), xlim=c(-0.1,1.1), ylim=c(0,1.1)) abline(h=1, col="blue") ```

Example output

```Loading required package: KernSmooth