parametrization of R function rlnorm [🇷 for BE/BA]

posted by ElMaestro  – Denmark, 2013-07-26 23:42 (3920 d 14:01 ago) – Posting: # 11065
Views: 47,040

Hi Martin and all,

Sorry to embark on archaelogy.

❝ When you want to generate log-normal distributed random variables with a given mean and CV on the observed scale - I suggest to use meanlog=log(mean)-0.5*log(1+cv^2) instead of meanlog=log(mean).


# example

set.seed(020510)

n <- 1E6

mue <- 5

cv <- 0.5


x <- rlnorm(n=n, meanlog=log(mue)-0.5*log(1+cv^2), sdlog=sqrt(log(1+cv^2)))

y <- rlnorm(n=n, meanlog=log(mue), sdlog=sqrt(log(1+cv^2)))


mean(x); sd(x)/mean(x)

mean(y); sd(y)/mean(y)


Well.... Is that really something anyone wants to do?
When we simulate BE, like in crossover trials, we most likely want to simulate with a known geometric mean ratio on the observed scale and a known CV on the observed scale.
I could have misunderstood rlnorm entirely, but otherwise:

GeoMean=function(a)
{
return (exp(mean(log(a))))
}


set.seed(020510)
n <- 1E6
GMR <- 0.95
cv <- 0.5

x <- rlnorm(n=n, meanlog=log(GMR)-0.5*log(1+cv^2), sdlog=sqrt(log(1+cv^2)))
y <- rlnorm(n=n, meanlog=log(GMR), sdlog=sqrt(log(1+cv^2)))

mean(x); sd(x)/mean(x)
mean(y); sd(y)/mean(y)

GeoMean(x)
GeoMean(y)


Stuff like that really hurts.
I would any day prefer to use rnorm to avoid the confusion:

logTRratios=rnorm(n=1e6, mean=log(0.95), sd=sqrt(log(1+cv^2)))
TRratios=exp(logTRratios)

GeoMean(TRratios) ##Geometric mean observed scale
mean(TRratios) ##useless?
mean(logTRratios) ## close to log(0.95)
sd(TRratios)/mean(TRratios)


Let me add that for those who simulate Test and Ref data individually (yes, there are still backward people who do that:-D), the subtraction of something like 0.5*log(1+cv^2) will cancel out as long as a common variance term is used and balance is present because log(T)-log(R)=log(T/R).

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
22,988 posts in 4,825 threads, 1,656 registered users;
91 visitors (0 registered, 91 guests [including 5 identified bots]).
Forum time: 13:44 CEST (Europe/Vienna)

The whole purpose of education is
to turn mirrors into windows.    Sydney J. Harris

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5