On 05-Aug-03 [EMAIL PROTECTED] wrote: > Here is a numerical vector test >> test > [1] 206 53 124 112 92 77 118 75 48 176 90 74 107 126 99 84 > ... > 89 94 69 74 99 97 91 92 > > Assuming it follows a lognormal distribution I'd like to determine the > mean and the sd thanks to maximum likelihood estimation > >> fitdistr(test,"lognormal",start=list(200,10)) > Error in print.fitdistr(structure(list(estimate = c(4.54666263736726, >: > more elements supplied than there are to replace > > I chose the parameter start randomly > > I don't understand the error message. Has anybody ever encountered such > one?
Hmmm. Not being practised with "fitdist", this took me a moment to track down. However, the clues are: 1. In ?fitdist :: fitdistr(x, densfun, start, ...) start: A named list giving the parameters to be optimized with initial values. This can be omitted for some of the named distributions (see Details) [not lognormal]. 2. Hence start must be a _named_ list, i.e. its components must have names. So the question is: what to call them? For this you need to know what the names are for the parameters in your designated distribution. So: 3. help.search("lognormal") -> Lognormal(base) 4. ?Lognormal :: dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE) So it looks as though you need names "meanlog" and "sdlog", so now try fitdistr(test,"lognormal",start=list(meanlog=4,sdlog=0.4)) with results meanlog sdlog 4.55316203 0.38990402 (0.02866631) (0.02026545) and it works! The starting values "4" and "0.4" were chosen because mean(log(test)) [1] 4.553205 sd(log(test)) [1] 0.3910148 and of course it works if you start elsewhere; but this also shows that the naive estimate, in this case, was very good. Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 167 1972 Date: 05-Aug-03 Time: 13:00:07 ------------------------------ XFMail ------------------------------ ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help