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

posted by ElMaestro  – Denmark, 2013-07-26 23:42 (3923 d 22:15 ago) – Posting: # 11065
Views: 47,045

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,993 posts in 4,828 threads, 1,652 registered users;
65 visitors (1 registered, 64 guests [including 12 identified bots]).
Forum time: 21:58 CEST (Europe/Vienna)

If you don’t like something change it;
if you can’t change it, change the way you think about it.    Mary Engelbreit

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