[R] Estimating parameters of 3 parameters lognormal distribution

peter dalgaard pdalgd at gmail.com
Sat Jan 18 18:20:00 CET 2014


Offhand, I'd say that the issue isn't so much the starting values as the risk of hitting the upper bound on gamma. If you get gamma set to min(x) at any point during the iteration, the density at the corresponding point is zero, the log-likelihood is -Inf, and <poof>, the magic smoke escapes. 

Perhaps try min(x)-1e-7 or so?

-pd

On 17 Jan 2014, at 22:46 , Rolf Turner <r.turner at auckland.ac.nz> wrote:

> 
> Can you please tell us (me!) how you chose starting values?
> 
> Out of curiosity I tried the following:
> 
> set.seed(42)
> x <- rlnorm(100,1,2) + 3
> require(MASS)
> strt <- list(mu=1,sigma=2,gamma=3)
> fit  <- fitdistr(x,densfun=function(x,mu,sigma,gamma)
>                                  {dlnorm(x-gamma,mu,sigma)
>                          },
>               start=strt,lower=c(0,0,-Inf),
>               upper=c(Inf,Inf,min(x)))
> 
> and it ran just fine and gave sensible answers.  But when I took:
> 
> strt <- list(mu=0.9,sigma=1.9,gamma=2.9)
> 
> (not very different from the previous starting values)
> 
> I got an error:
> 
>> Error in stats::optim(x = c(45.178764955739, 3.87862565957867, 8.61957940802123,  :
>>  L-BFGS-B needs finite values of 'fn'
> 
> 
> On 18/01/14 01:00, Vito Ricci wrote:
>> OK. It runs fine! Many thanks Frede.
>> Regards.
>> Vito
>> 
>> 
>> 
>> Se non ora, quando?
>> Se non qui, dove?
>> Se non tu, chi?
>> 
>> 
>> 
>> Il Venerdì 17 Gennaio 2014 12:38, Frede Aakmann Tøgersen <frtog at vestas.com> ha scritto:
>> 
>> 
>>> In package MASS there is the fitdistr function using maximum likelihood estimation to infer on the parameters of distributions based on observed data.
>>> 
>>> 
>>> One of the arguments of fitdistr () allows you to specify the probability density function.
>>> 
>>> 
>>> You only know how the parametrization of your three parameters lognormal distribution is defined since you really haven't told us much.
>>> 
>>> 
>>> Please have a look at fitdistr() and tell us if fit your needs.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com




More information about the R-help mailing list