[R] Fitdistrplus and Custom Probability Density

Eric Berger ericjberger at gmail.com
Tue Nov 7 15:58:53 CET 2017

Why not define your own functions based on d?
myCumDist <- function(x) { integrate(d, lower=-Inf, upper=x)$value  }
myQuantile <- function(x) { uniroot(f=function(y) { h(y) - x },
interval=c(-5,5)) }  # limits -5,5 should be replaced by your own which
might require some fiddling

d <- function(x) { exp(-x^2/2)/(sqrt(2*pi)) }  # just an example for you to
test with; use your own density d(x) in your case

Then define myCumDist, myQuantile as above and compare with pnorm, qnorm.


On Tue, Nov 7, 2017 at 4:22 PM, Lorenzo Isella <lorenzo.isella at gmail.com>

> Dear All,
> Apologies for not providing a reproducible example, but if I could, then I
> would be able to answer myself my question.
> Essentially, I am trying to fit a very complicated custom probability
> distribution to some data.
> Fitdistrplus does in principle everything which I need, but if require me
> to specify not only the density function d, but also the cumulative p and
> and inverse cumulative function q (see for instance
> http://www.stat.umn.edu/geyer/old/5101/rlook.html
> to understand what these quantities are in the case of a normal
> distribution).
> The analytical calculation of p and q is a big task in my case, so my
> question is if there is a workaround for this, i.e. a way to fit the
> unknown parameters of my probability distribution without specifying (at
> least analytically) p and q, but only the density d.
> Many thanks
> Lorenzo
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list