我正在努力寻找一份发行版。通过使用mledist函数。但每次我使用它我都会收到一条错误消息:
[1] "Error in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data, : \n non-finite finite-difference value [2]\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data, ddistnam = ddistname, hessian = TRUE, method = meth, lower = lower, upper = upper, ...): non-finite finite-difference value [2]>
事情就是我知道,“Alae”有一个帕累托分布,但我无法理解我的错误在哪里。请帮忙:)这是我的代码
library(fitdistrplus)
library(CASdatasets)
data(lossalae)
pertes<-lossalae
Alae <- pertes$ALAE
Alae_par <- mledist(Alae, 'pareto',start=c(shape=5,scale=2))
TNX
答案 0 :(得分:0)
鉴于CASdatasets的来源是加拿大保险作者,我猜测dpareto
- 函数应该来自pkg:actuar
:
> library(actuar)
Attaching package: ‘actuar’
The following object is masked from ‘package:grDevices’:
cm
> library(fitdistrplus)
> library(CASdatasets)
> data(lossalae)
> pertes<-lossalae
> Alae <- pertes$ALAE
> Alae_par <- mledist(Alae, 'pareto',start=c(shape=5,scale=2))
Warning messages:
1: In dpareto(c(3806L, 5658L, 321L, 305L, 758L, 8768L, 1805L, 78L, :
NaNs produced
snipped 6 other warnings
> Alae_par
$estimate
shape scale
2.221351 15106.971534
$convergence
[1] 0
$loglik
[1] -15413.45
$hessian
shape scale
shape 303.98838362 -3.083551e-02
scale -0.03083551 3.637979e-06
$optim.function
[1] "optim"
$fix.arg
NULL