On May 16, 2012, at 6:37 AM, 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)

I get a better match to those values with:
distrib <- rlnorm(500000,1.682,0.47071)

(Bad practice to use 'c' as an object name.)


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?

You need to review your resources on statistical distributions. The Wikipedia article has the needed transformations for parameters between the log and untransformed scales under the section entitled Arithmetic moments.

So that was the basis for this test:

# mu for LN
> log(6) - 0.5*log(1+9/6^2)
[1] 1.680188
# sigma for LN
> sqrt( log( 1 +9/6^2))
[1] 0.4723807
> c <- rlnorm(500000,1.680188,0.4723807)
> d <- exp(c)
# Expected value
> mean(c)
[1] 5.99303
# SD
> sd(c)
[1] 2.996532

So my half-assed approximation was in better agreement with theory than your "other software". On the other hand you haven't really given us much background for this estimation process so its not possible to offer a solid value judgment. R has package that do distribution fitting, MASS has fitdistr and there is a fitdistrplus package .... and others I believe. There's a monograph out about R's facilities but at the moment I cannot put my hands on my copy. There is a Distributions TaskView:
http://cran.r-project.org/web/views/Distributions.html

--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to