Learn R Programming

NPsimex (version 0.2-1)

simex.density: Estimating probability density function from data with homoscedastic measurement error using SIMEX

Description

To compute the probability density function from data contaminated with homoscedastic measurement error using SIMEX.

Usage

simex.density(W, msigma, x, from, to, n.user=128, n.lambda=50, lambda="SJ", span=8, adjust=1, na.rm = FALSE, ...)

Arguments

W
The observed data. It is a vector of length at least 10.
msigma
The standard deviation $\sigma$ of measurement error. It is a single positive numeric value.
x
x is user-defined grids where the PDF will be evaluated.
from
the starting point where the PDF is to be evaluated.
to
the starting point where the PDF is to be evaluated.
n.user
number of points where the PDF is to be evaluated.
n.lambda
number of points of lambda's.
lambda
Specifies the first lambda. It can be a single numeric value which has been pre-determined; or computed with the specific density bandwidth selector: 'nrd0', 'nrd', 'ucv', 'bcv', 'SJ'.
span
Specifies the span of lambda.
adjust
adjust the range there the PDF is to be evaluated. By default, $adjust=1$.
na.rm
is set to FALSE by default: no NA value is allowed.
...
control

Value

An object of class ``NPsimex''.

Details

References

Wang, X.F., Sun, J. and Fan, Z. (2011). Deconvolution density estimation with heteroscedastic errors using SIMEX.

See Also

simex.density, lambda.select, span.select.

Examples

Run this code

############### Homoscadestic error
N <- 1000
set.seed(123); X <- c(rnorm(N/2, mean=-2), rnorm(N/2,mean=2)); U <- rnorm(N,sd=1)
msigma <- 0.5
W <- X + msigma*U

plot.simex.density <- function(X.simex,X,...){
	plot(X.simex$x, X.simex$y, type="l", xlab="x", ylab="density", lwd=3, lty=2, col=2,...)
	lines(density(X, bw="SJ"), lwd=3)
	}

par(mfrow=c(2,2))
X.simex1 <- simex.density(W, msigma=msigma, adjust=1, n.lambda=50, span=1)
plot.simex.density(X.simex1, X, ylim=c(0,0.25))

X.simex2 <- simex.density(W, msigma=msigma, adjust=1, n.lambda=50, span=3)
plot.simex.density(X.simex2, X, ylim=c(0,0.25))

X.simex3 <- simex.density(W, msigma=msigma, adjust=1, n.lambda=50, span=8)
plot.simex.density(X.simex3, X, ylim=c(0,0.25))

X.simex4 <- simex.density(W, msigma=msigma, adjust=1, n.lambda=50, span=35)
plot.simex.density(X.simex4, X, ylim=c(0,0.25))

Run the code above in your browser using DataLab