# NOT RUN {
n1 <- 1500
x1 <- rnorm(n1, sd=1)
sig1 <- .5
u1 <- ifelse(runif(n1) > 0.5, 1, -1) * rexp(n1,rate=1/sig1)
w1 <- x1+u1
## The rule-of-thumb method may not be accurate,
## you may try the bootstrap method
bw1 <- bw.dnrd(w1,sig=sig1, error="laplacian")
(f1 <- DeconPdf(w1,sig1,error='laplacian',bw=bw1, fft=TRUE))
(f2 <- npdenest(w1, u1))
# plot the results
par(mfrow=c(1,1))
plot(f1, col="red", lwd=3, lty=2, xlab="x", ylab="f(x)", main="")
lines(density(x1, from=min(w1), to=max(w1)), lwd=3, lty=1)
lines(density(w1), col="blue", lwd=3, lty=3)
lines(f2, col='red', lty=1,lwd=3)
# }
Run the code above in your browser using DataLab