[R] Lognormal distribution

Petr Pikal petr.pikal at precheza.cz
Tue Dec 10 13:47:03 CET 2002


Hallo

On 10 Dec 2002 at 12:24, Dr Andrew Wilson wrote:

> I am trying to fit a lognormal distribution to a set of data and test
> its goodness of fit with regard to predicted values.
> 
> I managed to get so far:
> 
> > y <- c(2,6,2,3,6,7,6,10,11,6,12,9,15,11,15,8,9,12,6,5)
> > library(MASS)
> > fitdistr(y,"lognormal",start=list(meanlog=0.1,sdlog=0.1))
>     meanlog       sdlog   
>   1.94810515   0.57091032 
>  (0.12765945) (0.09034437)

I think that you can use distribution generator 
in this case

mydistr<-rlnorm(n, meanlog = 1.94810515, sdlog = 0.57091032)

where n is number of points you would like to generate.

see
?rlnorm



> 
> But I would now also like to generate the predicted values, so that I
> can make a comparison using e.g. the Cramer test in the cramer
> package.
> 
> I'd also like to plot the curves for both sets of values.

something like histogram(mydist) or lines(density(mydist))

or if you want the fitted distribution curve

plot(0:100,dlnorm(0:100, meanlog = 1.94810515, sdlog = 
0.57091032),type="l")

> 
> Could anyone help me with these two points?
> 
> Many thanks,
> Andrew Wilson
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Hope it helps
Cheers
Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz




More information about the R-help mailing list