R:fdwm()函数的异常行为(evmix程序包) [英] R: unexpected behavior of the fdwm() function (evmix package)

查看:185
本文介绍了R:fdwm()函数的异常行为(evmix程序包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

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

进一步

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")

给予:

因此,似乎估计的参数是有效的. 因此,我应该忽略fdwm()函数返回的错误吗?我可以使用估计的参数值吗?

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?

有关我的R会话的一些信息:

Some info about my R session:

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

我正在使用evmix的2.5版本.

I am using the version 2.5 of evmix.

推荐答案

此错误消息完全符合预期.当您运行该程序时,它会提供后续警告消息:

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

数字积分失败,忽略以前的消息,优化将重试"

这意味着您可以从集成"功能中忽略此错误.

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

为什么这很正常?很好的解释需要这个模型有一定的背景知识. DWM包含一个重新规格化常数,以确保适当的密度函数(使其集成为一个).对于非归一化密度的积分,没有封闭形式的解决方案.因此,使用数值积分来近似该积分(使用积分函数).

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).

在大多数情况下,积分功能对于DWM而言效果很好,因为密度通常很平滑.但是,当使可能性最大化时,优化算法有时会尝试使用参数的愚蠢值集(使用优化函数),这可能导致密度出现怪异行为(例如不连续性),因此数值积分可能会失败.这将导致您收到原始错误消息.给出以下警告消息表示您可以忽略来自集成功能的错误消息.

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.

如果优化算法确实很难摆脱愚蠢的参数集的空间,那么您将多次收到这些错误和警告消息.在这种情况下,您应该彻底检查结果拟合度(在任何情况下都应始终这样做,例如,使用evmix.diag函数.

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.

这篇关于R:fdwm()函数的异常行为(evmix程序包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆