R - fitting a mixture distribution with fitdistrplus

心不动则不痛 提交于 2019-12-11 18:36:01

问题


I have defined a mixture of a LogNormal and a Generalised Pareto (actuar) as follows:

dlnormgenpar<-function(x,
               w_lnorm,
               meanlog=0,
               sdlog=1,
               par_shape1=1,
               par_shape2=1,
               par_scale=1) {
  w_par=1-w_lnorm
  dln=dlnorm(x,meanlog = meanlog,sdlog = sdlog)
  dpar=dgenpareto(x,shape1=par_shape1,shape2=par_shape2,scale=par_scale)
  return(w_lnorm*dln+w_par*dpar)
}

I am trying to fit it to some data using fistdistrplus:

dist<-fitdist(data,"lnormgenpar")

However I receive the error:

Unknown starting values for distribution lnormgenpar.

If I expand the fitting function in the usual fitdistrplus way the error remains:

dist<-fitdist(data,"lnormgenpar",dparams=list(
  w_lnorm=0.5,
  meanlog=0,
  sdlog=1,
  par_shape1=1,
  par_shape2=1,
  par_scale=1
  ))

How should I pass my parameters in to the fitting function?

Thanks

Simon

来源:https://stackoverflow.com/questions/33942202/r-fitting-a-mixture-distribution-with-fitdistrplus

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