[R] finding mean and SD for a log-normal distribution
peter dalgaard
pdalgd at gmail.com
Wed May 16 22:35:17 CEST 2012
On May 16, 2012, at 12:37 , Andras Farkas wrote:
> Dear R Expert
>
> allow me to ask a quick qestion: I have a mean value of 6 and a SD of 3 describing my distribution. I would like to "convert" this distribution into a log normal distribution that would best describe it when resimulated using log normal distribution. Currently I am using another software to estimate the respective mean and SD on the log scale and the results are: 1.6667 and SD 0.47071. Then, to best reproduce my original distribution in R, I use the following commands:
>
> c <- rlnorm(5000,1.6667,0.47071)
> d <- exp(c)
> mean(c)
> sd(c)
>
> and the results for mean and SD are 5.92 and 2.94 (original 6 and 3), respectively, which I am reasonably happy with. I would like to grow independent of the another software I use, but am unable to figure out how to generate the values of 1.6667 and 0.47071 using R. could someone please help me with this question?
Perhaps this was what you were looking for:
> d <- log(c)
> mean(d)
[1] 1.675003
> sd(d)
[1] 0.4656469
Taking exp() of a log-normal rarely makes much sense. More commonly, you take log() to get a normal distribution.
--
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