Skip to main content
formatting
Source Link
Yves
  • 5.7k
  • 1
  • 23
  • 38

First remind that the fitdistrfitdistr function (from the MASS package) is a very general function that can work with nearly any distribution. The warnings come from non-allowed parameter values (e.g. negative scale or shape) met during the optimisation unconstrained by default.

It seems a good idea here to try a specific MLE for the Weibull distribution. A quite well-known fact is that the ML estimation of the two-parameter Weibull can be rely on a concentration of the log-likelihood, leading to an easier one-dimensional optimisation. Moreover, the concentrated log-likelihood is concave, so there is a unique ML estimate.

The problem here is that the log-likelihood is quite flat near the optimum, so different optimisations lead to different results as reported by @Glen_b. Moreover, the data scaling is prone to numerical problems. After rescaling, similar results are obtained with or without concentration. A general practical finding about MLE is that using poorly scaled data can be enough to ruin the estimation.

> library(Renext)            ## for concentrated log-lik
> try(fweibull(Y))           ## error (numerical pb with information matrix)
> fit <- fweibull(Y / 1000)  ## works
> ## set parameters and logLik back to original scale
> fit$est * c(1, 1000)
      shape       scale 
   2.126225 1563.094460

> fit$sd * c(1, 1000)
      shape       scale 
  0.2444308 114.1293266

> fit$loglik - length(Y) * log(1000)
[1] -362.2237

> library(MASS)
> ## set parameters and logLik back to original scale
> fit2 <- fitdistr(Y / 1000, "weibull")
> fit2$est * c(1, 1000)
      shape       scale 
   2.126231 1563.095165 

> fit2$sd * c(1, 1000)
      shape       scale 
  0.2288605 114.9071653 

> fit2$loglik - length(Y) * log(1000)
[1] -362.2237

First remind that the fitdistr function (from the MASS package) is a very general function that can work with nearly any distribution. The warnings come from non-allowed parameter values (e.g. negative scale or shape) met during the optimisation unconstrained by default.

It seems a good idea here to try a specific MLE for the Weibull distribution. A quite well-known fact is that the ML estimation of the two-parameter Weibull can be rely on a concentration of the log-likelihood, leading to an easier one-dimensional optimisation. Moreover, the concentrated log-likelihood is concave, so there is a unique ML estimate.

The problem here is that the log-likelihood is quite flat near the optimum, so different optimisations lead to different results as reported by @Glen_b. Moreover, the data scaling is prone to numerical problems. After rescaling, similar results are obtained with or without concentration. A general practical finding about MLE is that using poorly scaled data can be enough to ruin the estimation.

> library(Renext)            ## for concentrated log-lik
> try(fweibull(Y))           ## error (numerical pb with information matrix)
> fit <- fweibull(Y / 1000)  ## works
> ## set parameters and logLik back to original scale
> fit$est * c(1, 1000)
      shape       scale 
   2.126225 1563.094460

> fit$sd * c(1, 1000)
      shape       scale 
  0.2444308 114.1293266

> fit$loglik - length(Y) * log(1000)
[1] -362.2237

> library(MASS)
> ## set parameters and logLik back to original scale
> fit2 <- fitdistr(Y / 1000, "weibull")
> fit2$est * c(1, 1000)
      shape       scale 
   2.126231 1563.095165 

> fit2$sd * c(1, 1000)
      shape       scale 
  0.2288605 114.9071653 

> fit2$loglik - length(Y) * log(1000)
[1] -362.2237

First remind that the fitdistr function (from the MASS package) is a very general function that can work with nearly any distribution. The warnings come from non-allowed parameter values (e.g. negative scale or shape) met during the optimisation unconstrained by default.

It seems a good idea here to try a specific MLE for the Weibull distribution. A quite well-known fact is that the ML estimation of the two-parameter Weibull can be rely on a concentration of the log-likelihood, leading to an easier one-dimensional optimisation. Moreover, the concentrated log-likelihood is concave, so there is a unique ML estimate.

The problem here is that the log-likelihood is quite flat near the optimum, so different optimisations lead to different results as reported by @Glen_b. Moreover, the data scaling is prone to numerical problems. After rescaling, similar results are obtained with or without concentration. A general practical finding about MLE is that using poorly scaled data can be enough to ruin the estimation.

> library(Renext)            ## for concentrated log-lik
> try(fweibull(Y))           ## error (numerical pb with information matrix)
> fit <- fweibull(Y / 1000)  ## works
> ## set parameters and logLik back to original scale
> fit$est * c(1, 1000)
      shape       scale 
   2.126225 1563.094460

> fit$sd * c(1, 1000)
      shape       scale 
  0.2444308 114.1293266

> fit$loglik - length(Y) * log(1000)
[1] -362.2237

> library(MASS)
> ## set parameters and logLik back to original scale
> fit2 <- fitdistr(Y / 1000, "weibull")
> fit2$est * c(1, 1000)
      shape       scale 
   2.126231 1563.095165 

> fit2$sd * c(1, 1000)
      shape       scale 
  0.2288605 114.9071653 

> fit2$loglik - length(Y) * log(1000)
[1] -362.2237
Source Link
Yves
  • 5.7k
  • 1
  • 23
  • 38

First remind that the fitdistr function (from the MASS package) is a very general function that can work with nearly any distribution. The warnings come from non-allowed parameter values (e.g. negative scale or shape) met during the optimisation unconstrained by default.

It seems a good idea here to try a specific MLE for the Weibull distribution. A quite well-known fact is that the ML estimation of the two-parameter Weibull can be rely on a concentration of the log-likelihood, leading to an easier one-dimensional optimisation. Moreover, the concentrated log-likelihood is concave, so there is a unique ML estimate.

The problem here is that the log-likelihood is quite flat near the optimum, so different optimisations lead to different results as reported by @Glen_b. Moreover, the data scaling is prone to numerical problems. After rescaling, similar results are obtained with or without concentration. A general practical finding about MLE is that using poorly scaled data can be enough to ruin the estimation.

> library(Renext)            ## for concentrated log-lik
> try(fweibull(Y))           ## error (numerical pb with information matrix)
> fit <- fweibull(Y / 1000)  ## works
> ## set parameters and logLik back to original scale
> fit$est * c(1, 1000)
      shape       scale 
   2.126225 1563.094460

> fit$sd * c(1, 1000)
      shape       scale 
  0.2444308 114.1293266

> fit$loglik - length(Y) * log(1000)
[1] -362.2237

> library(MASS)
> ## set parameters and logLik back to original scale
> fit2 <- fitdistr(Y / 1000, "weibull")
> fit2$est * c(1, 1000)
      shape       scale 
   2.126231 1563.095165 

> fit2$sd * c(1, 1000)
      shape       scale 
  0.2288605 114.9071653 

> fit2$loglik - length(Y) * log(1000)
[1] -362.2237