4

I am trying to fit a compound distribution (Normal - Poisson) to a given data:

d2<-c(5,2,1,3,0,0,8,0,4,0,9,1,0,3,15,0,0,0,10,10,16,10,5,10,10,5,5,0,0,0,0,0,0,0,0,0,0,0)

My R code is as follows:

library("fitdistrplus")
library("Compounding")
cc <- c("geometric","poisson","negativebinomial","binomial","logarithmic","binomialbinomial","binomialpoisson","poissonbinomial","neymantypea","polyaaeppli","poissonpascal","pascalpoisson","logarithmicbinomial","logarithmicpoisson","poissonlindley","hyperpoisson","yule","waring","kattitypeh1","kattitypeh2","neymantypeb","neymantypec","hypergeometric","thomas")
dd<-fitdist(d2,"Compound",fix.arg = list(parent="norm",compound="poisson",compoundDist=cc),start = list(params=3))

But I get an error message saying:

Error in mledist(data, distname, start, fix.arg, ...) : 
  'fix.arg' must specify names which are arguments to 'distr'.

I've tried all sorts of workarounds but nothing seems to work. I really don't understand what I'm missing here. Any help would be highly appreciated! Thanks in advance!

Meliodas
  • 41
  • 1
  • Can you explain in a little more detail what *you* mean by "compounding"? The definition I would assume, e.g. https://en.wikipedia.org/wiki/Compound_probability_distribution , would say that you have a continuous mixture of Poisson distributions with means drawn from a Normal distribution (which wouldn't make sense, by the way, since the domain of the Normal distribution isn't restricted to non-negative values ...) ... – Ben Bolker Jul 04 '18 at 14:14
  • 1
    It looks like the `Compounding` package https://link.springer.com/content/pdf/10.1007%2Fs00180-012-0336-y.pdf is instead creating a distribution that would be the *minimum* of a Poisson-distributed number of Normal deviates. I suspect you want the former, since your values are all discrete ... – Ben Bolker Jul 04 '18 at 14:14
  • Actually I'm trying to fit an appropriate distribution to the given data, which in reality is demand data. I've tried all standard distributions and none of them seem to fit. I found that in quite a number of literatures they talk about fitting compound distributions to this kind of data. So, I thought I'd give it a try. Also, you are correct in saying that what I really want is the former, as given by the definition of Wikipedia. The continuous distribution could actually be anything (not necessarily normal) but the discrete distribution is most likely Poisson as data is intermittent. – Meliodas Jul 05 '18 at 06:20
  • @Ben Bolker I wasn't aware of the exact backend functionality of the Compounding package. Thank you for pointing that out. Also, is there any way that I can achieve my goal? Does anything else come to mind? – Meliodas Jul 12 '18 at 09:40

0 Answers0