fitting a Rayleigh distribution

I am using Rstudio (release 1.2.5019 running R 4.05) on a Windows 10 machine to follow the instructions on this page:

It's quite simple: load two libraries, create a small data set in vector x, fit to a Rayleigh distribution with this command:

fit <- fitdist(x, "rayleigh", start = list(sigma = 1))

When I do this in RStudio, I get this error:
Error in fitdistr(x, "rayleigh", start = list(sigma = 1)) :
unsupported distribution

When I type exactly the same commands into a command window started from the R 4.05 installation running on this machine, the fitting works.

Any thoughts as to why it fails inside RStudio but not in the terminal window?

Thanks in advance...

are you using library(extraDistr) in addition to library(fitdistrplus) ?

Yes, those are the two libraries in the example I'm following.

ok, please provide the results you receive when you run.

packageVersion("fitdistrplus")
packageVersion("extraDistr")

I get 1.1.8 for fitdistrplus and 1.9.1 for extraDistr. Those versions are identical when run inside RStudio (where the fitting fails) and in the R command window (where it works).

in the library(MASS) there is a function fitdistr that can complain 'unsupported distribution'
I am not aware that fitdist would throw that.
Is there any possibility you have a typo in the code you are trying for Rstudio, but not in R command ?

No. I cut and pasted across the two. I also just tested whether also loading MASS had any effect on whether the R terminal window works or not. It still works even when MASS is loaded.

When I have a bit more time, I will look to see exactly which packages are loaded in the two environments.

Its quite curious.
I wonder what happens when you try binom instead of rayleigh
i.e.

fit <- fitdist(x, "binom", start = list(sigma = 1))
fit <- fitdistr(x, "binom", start = list(sigma = 1))

I get errors on both, but they are quite different :

# fitdistrplus:
> fit <- fitdist(x, "binom", start = list(sigma = 1))
Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg,  : 
  'start' must specify names which are arguments to 'distr'.

# MASS
> fit <- fitdistr(x, "binom", start = list(sigma = 1))
Error in fitdistr(x, "binom", start = list(sigma = 1)) : 
  unsupported distribution
>

I haven't had time to check that the packages are comparable and won't get to that today. I don't know whether package order matters, but I have both MASS and fitdistrplus loaded in both RStudio and my R terminal. I get different results:

RStudio

fit2 <- fitdistr( x, "rayleigh", start = list(sigma = 1) )
Error in fitdistr(x, "rayleigh", start = list(sigma = 1)) :
unsupported distribution
fit2 <- fitdistr( x, "binom", start = list(sigma = 1) )
Error in fitdistr(x, "binom", start = list(sigma = 1)) :
unsupported distribution

R terminal:

fit2 <- fitdist(x, "rayleigh", start = list(sigma = 1))
fit2 <- fitdist(x, "binom", start = list(sigma = 1))
Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, :
'start' must specify names which are arguments to 'distr'.

Whatever that means...

According to this post, in rstudio you tested fitdistr twice whereas in the terminal you tested fitdist twice

When I saw your note late yesterday, I assumed that I had simply been an idiot and my problem really was as simple as a typo. However, when I had a chance to test it, I find:

RStudio:

fit2 <- fitdistr( x, "rayleigh", start = list(sigma = 1) )
Error in fitdistr(x, "rayleigh", start = list(sigma = 1)) :
unsupported distribution
fit2 <- fitdistr( x, "binom", start = list(sigma = 1) )
Error in fitdistr(x, "binom", start = list(sigma = 1)) :
unsupported distribution

fit2 <- fitdist( x, "rayleigh", start = list(sigma = 1) )
Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, :
'start' must specify names which are arguments to 'distr'.
fit2 <- fitdist( x, "binom", start = list(sigma = 1) )
Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, :
'start' must specify names which are arguments to 'distr'.

R terminal:

fit2 <- fitdistr( x, "rayleigh", start = list(sigma = 1) )
Error in fitdistr(x, "rayleigh", start = list(sigma = 1)) :
unsupported distribution
fit2 <- fitdistr( x, "binom", start = list(sigma = 1) )
Error in fitdistr(x, "binom", start = list(sigma = 1)) :
unsupported distribution

fit2 <- fitdist( x, "rayleigh", start = list(sigma = 1) )
fit2 <- fitdist( x, "binom", start = list(sigma = 1) )
Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, :
'start' must specify names which are arguments to 'distr'.

Again, the R Terminal can do the Rayleigh fit using fitdist while RStudio cannot...

And thanks for your help and patience.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.