我有一个模型 Y= X+e 并且需要 X 的密度。deamer 包对 X 的密度进行反卷积,但是如果我使用 simpsons 规则来整合这个密度,我得到的值大于 1。下面的例子给了我积分为 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
我不确定这是否只是一个估计错误,或者我是否应该考虑缩小密度以使积分密度为 1:
# Downscaling
yValsScaled <- decon$f/area
plot(decon$supp, yValsScaled, type="l")
(areaScaled <- sintegral(decon$supp, yValsScaled)$value)
你怎么看?
顺便说一句:如果你在deamerSE函数中使用更大的间隔和from和to参数,集成密度会更大(因为密度的周期性)。通常我认为使用 deamerSE 我会得到一个积分(从 -inf 到 inf)大约为 1 的密度。因此我认为使用较小的间隔对密度进行积分(例如,在 deamerSE 函数中使用from=0.4和to=1 )应该给我一个积分小于 1 的密度。但正如你所看到的,它没有。所以我比较困惑。