Search code examples
rmodel-fittingfitdistrplus

Fitting a Gumbel distribution with fitdistrplus


I'm trying to reproduce the code from this answer, however I have problems in doing so. I'm using the gumbel distribution from package VGAM and fitdistrplus. The problem emerges when doing:

fit   = fitdist(data1, 'gumbel', start = list(location = 0, scale = 1))
Error in mledist(data, distname, start, fix.arg, ...) : 
  'start' must specify names which are arguments to 'distr'.

As if location and scale were not arguments of *gumbel.

dgumbel, pgumbel, rgumbel and qgumbel are correctly provided by VGAM. However the package also provides a function called gumbel, with different syntax. May this be causing problems?

EDIT: yes indeed it is causing problems: using package FAdist instead works perfectly fine.


Solution

  • For reference, from the package vignette linked in comments:

    library(fitdistrplus)
    data(groundbeef)
    serving <- groundbeef$serving
    dgumbel <- function(x, a, b) 1/b*exp((a-x)/b)*exp(-exp((a-x)/b))
    pgumbel <- function(q, a, b) exp(-exp((a-q)/b))
    qgumbel <- function(p, a, b) a-b*log(-log(p))
    fitgumbel <- fitdist(serving, "gumbel", 
        start=list(a=10, b=10))
    

    Or with the functions from VGAM:

    rm(dgumbel) ## get rid of previous definition
    ## hack behaviour of VGAM::pgumbel() a little bit
    pgumbel <- function(x,...) {
      if (length(x)==0) numeric(0) else VGAM::pgumbel(x,...)
    }
    library(VGAM)
    fitgumbel <- fitdist(serving, "gumbel", 
           start=list(location=10, scale=10))