Ted,
 
thanks for the answer. I actually think I have it the other way around. Let me give you an example:
 
1. I know the mean parameter value of a variable (V), lets call it M with a value of 5, and I also know the SD, let us call it SD with a value of 3:
#V
M <-5
SD <-3
 
2. Usually in case there is no known covariance with another parameter and in order to avoid from negative values being generated I would do the following:
calculate mu and sigma:
mu <-log(M)-0.5*log(1+SD^2/(M^2))
sigma <-sqrt(log(1+SD^2/(M^2)))
 
3. then I would simulate:
Y <-rlnorm(5000,mu,sigma)
then do
mean(Y)
sd(Y)
 
with resulting values of 4.968 for mean and 2.923 for SD, which I am reasonably happy with. 
 
At times though I have a multivariate situation on my hands where I know V with M and SD from above and additional V1 with M1 and SD1, and V2 with M2 and SD2, example:
 
#VM <-5
SD <-3
 
#V1 
M1 <-8
SD <-4
 
#V2
M <-12
SD <-6
 
in addition to knowing this information I also have a covariance matrix available for these 3 parameters. Based on my previous experience with using mvrnorm, if I do what is suggested below then I will generate negative values, which is no good news for me. In the mean time simply calculating mu and sigma again and then simulate all 3 variables independently as above in 1. would not be apropriate because that would not take into consideration the known covariance between parameters. Hope this example makes my qestion more clear, and any thoughts would be apreciated
 
thanks,
 
Andras


________________________________
From: "Ted.Harding@wlandres.net" <Ted.Harding@wlandres.net>
To: "r-help@r-project.org" <r-help@r-project.org> 

Sent: Thursday, October 11, 2012 1:51 PM
Subject: RE: [R] Help on probability distribution question

On 11-Oct-2012 17:22:44 Andras Farkas wrote:
> Dear All,
> I have a questions I would like to ask about and wonder if you
> have any thoughts to make it work in R.
> 
> 1. I work in the field of medicine where physiologic variables
> are often simulated, and they can not have negative values.
> Most often the assumption is made to simulate this parameters
> with a normal distribution but in the "log-domain" to avoid from
> negative values to be generated. Since the expected mean and SD
> is usually known from the normal domain, using the methods described
> in the wikipedia article "Arithmetric moments" I generate Î¼and Ïƒ
> and simulate with rlnorm(). At times though the following issue
> comes up: I have the mean and SD for the parameters available
> from the normal domain, and the covariance matrix from the normal
> domain. Then I would like to simulate the values, but to avoid
> from negative values being generated I have to fall back on rlnorm
> in {compositions}. My issue is though that my covariance matrix is
> representing the covariance of the parameters in the normal domain,
> as opposed to in the lognormal domain. Any thoughts on how  to work
> around this?
> 
> apreciate the help,
> Andras

If I understand your question correctly, if Y is the variable being
simulated then you know the mean (M, say) and the variance (V, say)
of log(Y). So you can simulate X from a normal distribution with
mean M and variance V = S^2 (S = SD of X), and then Y = exp(X):

  Y <- exp(rnorm(n,M,S))

where n is the number of sampled values you want.

When Y is multivariate, with M the vector of means and V the
covariance matrix of log(Y), then use a similar approach with
the function mvrnorm() from the MASS package:

  library(MASS)
  Y <- mvrnorm(n,M,V)

Does this help?
Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding@wlandres.net>
Date: 11-Oct-2012  Time: 18:51:47
This message was sent by XFMail
-------------------------------------------------
	[[alternative HTML version deleted]]


