I have a Model Y= X+e and need the density of X. The deamer package deconvolves the density for X, but if I use the simpsons rule to integrate this density, I get values which are above 1. The following example gives me a density which integral is 1.173454:
library(deamer) # deconvolution library(Bolstad) # simpson rule # The Y's I have are inv-Weibull distributed and the error's are inv-normal distributed. # As the deconvolution of those would take a long time, i used runif in my example # to simplify the problem. The following uncommented lines are what I like to deconvolve: #library(actuar) # for rinvweibull #y <- rinvweibull(30000, shape=5.53861156, scale=488)/1000 #y <- y[y<1.5] #e <- 1/rnorm(30000, mean=0.0023853421, sd=0.0004784688)/1000 #e <- e[e<1.5] #decon <- deamerSE(y, error=e, from=-0.1, to=0.3) y <- runif(1000, min = 0.8, max=1.2) e <- runif(1000, min = 0.1, max=0.5) decon <- deamerSE(y, error=e, from=0.4, to=1) plot(decon) # following line gives me integral of density (with simpsons rule) sintegral(decon$supp, decon$f)$value
I am not sure if this is just an estimation error or if I should consider downscaling the density so that the integrated density is 1:
# Downscaling yValsScaled <- decon$f/area plot(decon$supp, yValsScaled, type="l") (areaScaled <- sintegral(decon$supp, yValsScaled)$value)
What do you think?
btw: If you use a larger intervall with the from and to argments in deamerSE function, the integrated density will be even greater (because of the periodicity of the density). Usually I thought that with deamerSE I would get a density which integral (from -inf to inf) is approximately 1. Therefore I thougt that integrating the density using a smaller intervall (e.g. with from=0.4 and to=1 in the deamerSE function) should give me a density which integral is less than 1. But as you can see it doesn't. So I am rather confused.