2

I am trying to run the following for Gumbel distribtuion:

    (gdist<-fitdist(z1,dgumbel,start=list(mu=22.147,sd=38.372)))
    summary(gdist)

The following error comes up:

    Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg,  
    :  'start' must specify names which are arguments to 'distr'.

My data head looks like:

    > head(data)
   Year No     z1   SOI
 1 1900  1  11.05  14.6
 2 1901  2   9.23  14.7
 3 1902  3  39.48  -1.6
 4 1903  4 -43.41   1.9
 5 1904  5  -8.26  -5.1
 6 1905  6 -33.97 -20.1
  • please provide your dataframe by using `dput` or something [similar](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – mischva11 Apr 24 '19 at 13:44
  • I have now added into the original question, Thanks – user9645302 Apr 24 '19 at 13:49
  • 2
    What implementation of `dgumbel` are you using? It's not in base nor exported from `fitdistrplus`. I'm assuming that the names of its parameters are not "mu" and "sd". – Gregor Thomas Apr 24 '19 at 13:58

1 Answers1

2

Your input of the start parameter is wrong. Since there are a lot of different packages which have gumbel you have to check which one you use and see the parameters. You need to give the parameters of dgumbel to the start value. For ordinal package:

dgumbel(x, location = 0, scale = 1, log = FALSE, max = TRUE)

So your start=list() has to provide location and scale.

for extraDistr (documentation)

dgumbel(x, mu = 0, sigma = 1, log = FALSE)

So the start=list() needs to include the parameters mu and sigma

here an example how to use it accordingly:

 gdist<-fitdist(df$z1,dgumbel,start=list(mu=22.147, sig= 38.372))

This gives you an output. The error message is fixed by calling the correct names of the start values for the dgumbel function. Since i can't figure out which package you use i recommend checking the documentation or using ?dgumbel to see it in your IDE if you use one.

Change the parameter names to the used ones in the documentation.

mischva11
  • 2,811
  • 3
  • 18
  • 34
  • 1
    Unless OP is using `evd::dgumbel`, then the first parameter is `loc` not `location`. Or `extraDistr::dgumbel`, which uses `mu` and `sigma`. Or the `dgumbel` defined in several `fitdistrplus` examples, which use `x` and `a`.... – Gregor Thomas Apr 24 '19 at 14:07
  • 1
    @Gregor you are correct, i checked another package (ordinal)... i correct my answer – mischva11 Apr 24 '19 at 14:08
  • Thank you for your answer - I don't mind using any package, I just need it to work. Sorry I am very new to this and I don't really understand what to do – user9645302 Apr 25 '19 at 05:30
  • 1
    @user9645302 that's what i was trying to explain. It doesn't matter which package you use. You just have to know how the parameters of your used function are called. Then use the same names in your `list()` – mischva11 Apr 25 '19 at 06:55
  • Thank you @mischva11 How come this still provides the same error? gdist<-fitdist(z1,dgumbel,start=list(scale=38.372,location=22.147)) I have also tried Extradist and the parameters you suggested. What am I doing wrong? – user9645302 Apr 25 '19 at 11:49
  • 1
    @user9645302 for `library(ordinal)` `gdist<-fitdist(df$z1,dgumbel,start=list(location=22.147, scale= 38.372))` works for me. Did you provide the `df$z1` accordingly? so did you save z1 in another vector? If not make sure you add the `df$`. Also is it the exact same error message? – mischva11 Apr 25 '19 at 11:54
  • I think I see the problem, when I try library(ordinal) I get: Error in library(ordinal) : there is no package called ‘ordinal’. Could this be a version issue? – user9645302 Apr 25 '19 at 12:41
  • 1
    @user9645302 that means you have to install it first. Use `install.packages("ordinal")` first in the console. Another way is using the graphical interface, but just google for that. Can't explain it properly in the commentary – mischva11 Apr 25 '19 at 13:02
  • Thanks so much - that works now! I now need to also do: gofstat(gdist,discrete=TRUE,scale=38.372,location=22.14) and get the error: Error in gofstat(gdist, discrete = TRUE, scale = 38.372, location = 22.14) : unused arguments (scale = 38.372, location = 22.14) Would you know about this one for goodness-of-fit test? – user9645302 Apr 25 '19 at 13:37
  • @user9645302 same here: check the [documentary](https://www.rdocumentation.org/packages/Imap/versions/1.32/topics/gdist) first and think about how to use the function of gdist. – mischva11 Apr 25 '19 at 13:41