R: unexpected behavior of the fdwm() function (evmix package)

青春壹個敷衍的年華 提交于 2020-01-25 20:40:53

问题


I am trying to fit a dynamic mixture model (Weibull for the bulk, Pareto for the tail) using the fdwm() function from the evmix package:

library(repmis)
library(evmix)
data=source_data("https://www.dropbox.com/s/r7i0ctl1czy481d/test.csv?dl=0")[,1]
test=fdwm(data,c(0.9150062,75.4699181,quantile(data,0.98),11.21,87.41,0.05))

I am experiencing a weird behavior: the function first returns an error...:

Error in integrate(rx, wshape, wscale, cmu = cmu, ctau = ctau, sigmau = sigmau, : non-finite function value

...but continues to function and finally returns some values:

test$mle
[1] 1.212213e+00 5.877943e+01 5.160288e+02 8.364144e-04 1.206929e+02 8.952331e-02

Further,

xeval=seq(min(data),max(data)+sd(data),length=length(data))
test.distr=ddwm(xeval,test$mle[1],test$mle[2],test$mle[3],test$mle[4],test$mle[5],test$mle[6])
hist(data,probability=TRUE)
lines(xeval,test.distr,col="red")

gives:

So, it seems that the estimated parameters are valid. Therefore, should I ignore the error returned by the fdwm() function? Can I use the estimated parameter values?

Some info about my R session:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

I am using the version 2.5 of evmix.


回答1:


This error message is entirely as expected. When you run this program it provides a followup warning message:

"numerical integration failed, ignore previous messages, optimisation will try again"

which implies you can simply ignore this error from the "integrate" function.

Why is this normal? Well that explanation needs some background on this model. The DWM includes a renormalisation constant, to ensure a proper density function (make it integrate to one). There is no closed form solution to the integral of the un-normalised density. Hence, numerical integration is used to approximate this integral (using the integrate function).

In most circumstances the integrate function works well for the DWM, as the density is usually smooth. However, when maximising the likelihood the optimisation algorithm will occasionally try silly sets of values for the parameters (using optim function), which can lead to weird behaviour in the density (e.g. discontinuities) and so the numerical integration can fail. This leads to the original error message you received. The following warning message is given to convey that you can ignore the error message from the integrate function.

If the optimisation algorithm is really struggling to get out of the space of silly parameter sets, then you will get these error and warning messages many times. In this case you should thoroughly check the resulting fit (you should always do this in any case, e.g. using evmix.diag function.



来源:https://stackoverflow.com/questions/30463052/r-unexpected-behavior-of-the-fdwm-function-evmix-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!