Dear NMUsers,
I would like to implement a truncated normal distribution for weight for
use in a simulation, with a pre-specified mean and standard deviation.
What works so far is this (w.o. truncation, which I found in the NONMEM
user guides):
$PK
IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
CALL RANDOM(5,R)
ENDIF
IF (ICALL.EQ.4) WT=70+10*R; mean of 70 with SD 10
$SIM (12345) (...) (...) (...) (54676 NORMAL); I have a total of five
random number generators i.e. 4 different covariates, which I want to
simulate distributions for.
Adding a DOWHILE loop does not seem to work (either I get error messages
or NONMEM stagnates after performing the sims and never finishes) - I think
it's a coding issue on my part, in regard to the IF THEN ELSE statements
and DOWHILE statement:
IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
CALL RANDOM(5,R)
ENDIF
IF (ICALL.EQ.4) WT=70+10*R;
DOWHILE (WT.GT.50.OR.WT.LT.100); truncation limits of 50 and 100
ENDDO
Other ways to generate a normal truncated distribution can be coded as
(from Metrum Institute course 210):
$PK
IF (ICALL.EQ.4) THEN
WT=THETA(1) + ETA(1)
DOWHILE (WT.LT.20.OR.WT.GT.100)
CALL SIMETA(ETA)
WT=THETA(1) + ETA(1)
ENDDO
ENDIF
$SIM (2345 NEW)
Yet, I am unsure of how to incorporate my known mean and standard deviation
using this approach.
Hope you can help. Thanks in advance.
Best regards,
Yassine
Truncated normal distribution for continuous covariate with known mean and standard error
3 messages
2 people
Latest: Dec 10, 2015
Dear Yassine,
I prefer the second option, where you simulate new ETAs until they fulfill your
requirements. THETA(1) is the mean value of WT while ETA(1) is a random
variable with variance OMEGA. You should just add the known mean value of WT
(e.g. 70) as the initial estimate of THETA(1) and the known variance of weight
(stdev^2; e.g. 100) as the initial estimate of OMEGA for ETA(1). The
simulations will always be based on your initial estimates so there is no need
to specify the actual values (i.e. mean 70 and standard deviation 10) directly
in the code. By the way, I think you might need to add a .AND.NEWIND.NE.2 to
the IF-statement (IF(ICALL.EQ.4.AND.NEWIND.NE.2).
If you anyhow want to use the first option (simulate random numbers from a
normal distribution), the CALL RANDOM(5, R) needs to be specified in the
DOWHILE-loop. You want to simulate a new random variable if the first one
doesn’t fulfill your requirements. This code could look something like this:
IF(ICALL.EQ.4.AND.NEWIND.NE.2) THEN
R = 0
WT =70+10*R
DOWHILE (WT.LT.50.OR.WT.GT.100)
CALL RANDOM(5,R)
ENDDO
ENDIF
IF(ICALL.EQ.4) WT=70+10*R
If the simulated weight is outside the specified limits (i.e. less than 50 or
greater than 100), a new random value will be simulated until the weight is
between these limits. I have not tried the code myself but I’m pretty sure it
should work.
You write in your question that you have 4 different covariates which you want
to simulate. Be aware that the simulated covariates need to be correlated in
the same way as your original data to give valid results.
Kind regards,
Åsa
Quoted reply history
From: [email protected] [mailto:[email protected]] On
Behalf Of Yassine Kamal Lyauk
Sent: den 8 december 2015 13:14
To: [email protected]
Subject: [NMusers] Truncated normal distribution for continuous covariate with
known mean and standard error
Dear NMUsers,
I would like to implement a truncated normal distribution for weight for use in
a simulation, with a pre-specified mean and standard deviation.
What works so far is this (w.o. truncation, which I found in the NONMEM user
guides):
$PK
IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
CALL RANDOM(5,R)
ENDIF
IF (ICALL.EQ.4) WT=70+10*R; mean of 70 with SD 10
$SIM (12345) (...) (...) (...) (54676 NORMAL); I have a total of five random
number generators i.e. 4 different covariates, which I want to simulate
distributions for.
Adding a DOWHILE loop does not seem to work (either I get error messages or
NONMEM stagnates after performing the sims and never finishes) - I think it's a
coding issue on my part, in regard to the IF THEN ELSE statements and DOWHILE
statement:
IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
CALL RANDOM(5,R)
ENDIF
IF (ICALL.EQ.4) WT=70+10*R;
DOWHILE (WT.GT.50.OR.WT.LT.100); truncation limits of 50 and 100
ENDDO
Other ways to generate a normal truncated distribution can be coded as (from
Metrum Institute course 210):
$PK
IF (ICALL.EQ.4) THEN
WT=THETA(1) + ETA(1)
DOWHILE (WT.LT.20.OR.WT.GT.100)
CALL SIMETA(ETA)
WT=THETA(1) + ETA(1)
ENDDO
ENDIF
$SIM (2345 NEW)
Yet, I am unsure of how to incorporate my known mean and standard deviation
using this approach.
Hope you can help. Thanks in advance.
Best regards,
Yassine
________________________________
Confidentiality Notice: This message is private and may contain confidential
and proprietary information. If you have received this message in error, please
notify us and remove it from your system and note that you must not copy,
distribute or take any action in reliance on it. Any unauthorized use or
disclosure of the contents of this message is not permitted and may be unlawful.
Dear Åsa,
Thank you very much for your suggestions.
I have tried both approaches and the one you prefer (using CALLSIMETA) is
more intuitive I also think. It seems to work fine.
In the code you suggest (using CALL RANDOM) a 70 kg weight for all subjects
is attained. I think this is due to R = 0 - when I remove it, I start
getting different weight values that are within the truncation limits.
Lastly, I am very interested in hearing more regarding your end comment on
correlation of the simulated covariates. Could you briefly specify what you
mean/how to implement this (i.e. how to preserve the same correlation
patern as in the original data set). I am simulating distributions for both
continuous (e.g. weight, age) and categorical (e.g. SEX, SNPs) covariates.
It is for the categorical covariates that I use separate CALL RANDOM blocks
while drawing from UNIFORM distributions.
Best regards,
Yassine
Quoted reply history
2015-12-08 14:22 GMT+01:00 Johansson, Åsa <[email protected]>:
> Dear Yassine,
>
>
>
> I prefer the second option, where you simulate new ETAs until they fulfill
> your requirements. THETA(1) is the mean value of WT while ETA(1) is a
> random variable with variance OMEGA. You should just add the known mean
> value of WT (e.g. 70) as the initial estimate of THETA(1) and the known
> variance of weight (stdev^2; e.g. 100) as the initial estimate of OMEGA for
> ETA(1). The simulations will always be based on your initial estimates so
> there is no need to specify the actual values (i.e. mean 70 and standard
> deviation 10) directly in the code. By the way, I think you might need to
> add a .AND.NEWIND.NE.2 to the IF-statement (IF(ICALL.EQ.4.AND.NEWIND.NE.2).
>
>
>
> If you anyhow want to use the first option (simulate random numbers from a
> normal distribution), the CALL RANDOM(5, R) needs to be specified in the
> DOWHILE-loop. You want to simulate a new random variable if the first one
> doesn’t fulfill your requirements. This code could look something like this:
>
>
>
> IF(ICALL.EQ.4.AND.NEWIND.NE.2) THEN
>
> R = 0
>
> WT =70+10*R
>
> DOWHILE (WT.LT.50.OR.WT.GT.100)
>
> CALL RANDOM(5,R)
>
> ENDDO
>
> ENDIF
>
> IF(ICALL.EQ.4) WT=70+10*R
>
>
>
> If the simulated weight is outside the specified limits (i.e. less than 50
> or greater than 100), a new random value will be simulated until the weight
> is between these limits. I have not tried the code myself but I’m pretty
> sure it should work.
>
>
>
> You write in your question that you have 4 different covariates which you
> want to simulate. Be aware that the simulated covariates need to be
> correlated in the same way as your original data to give valid results.
>
>
>
> Kind regards,
>
> Åsa
>
>
>
>
>
> *From:* [email protected] [mailto:[email protected]]
> *On Behalf Of *Yassine Kamal Lyauk
> *Sent:* den 8 december 2015 13:14
> *To:* [email protected]
> *Subject:* [NMusers] Truncated normal distribution for continuous
> covariate with known mean and standard error
>
>
>
> Dear NMUsers,
>
>
>
> I would like to implement a truncated normal distribution for weight for
> use in a simulation, with a pre-specified mean and standard deviation.
>
>
>
> What works so far is this (w.o. truncation, which I found in the NONMEM
> user guides):
>
>
>
> $PK
>
> IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
>
> CALL RANDOM(5,R)
>
> ENDIF
>
> IF (ICALL.EQ.4) WT=70+10*R; mean of 70 with SD 10
>
>
>
> $SIM (12345) (...) (...) (...) (54676 NORMAL); I have a total of five
> random number generators i.e. 4 different covariates, which I want to
> simulate distributions for.
>
>
>
> Adding a DOWHILE loop does not seem to work (either I get error messages
> or NONMEM stagnates after performing the sims and never finishes) - I think
> it's a coding issue on my part, in regard to the IF THEN ELSE statements
> and DOWHILE statement:
>
>
>
> IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN
>
> CALL RANDOM(5,R)
>
> ENDIF
>
> IF (ICALL.EQ.4) WT=70+10*R;
>
> DOWHILE (WT.GT.50.OR.WT.LT.100); truncation limits of 50 and 100
>
> ENDDO
>
>
>
> Other ways to generate a normal truncated distribution can be coded as
> (from Metrum Institute course 210):
>
>
>
> $PK
>
> IF (ICALL.EQ.4) THEN
>
> WT=THETA(1) + ETA(1)
>
> DOWHILE (WT.LT.20.OR.WT.GT.100)
>
> CALL SIMETA(ETA)
>
> WT=THETA(1) + ETA(1)
>
> ENDDO
>
> ENDIF
>
>
>
> $SIM (2345 NEW)
>
>
>
> Yet, I am unsure of how to incorporate my known mean and standard
> deviation using this approach.
>
>
>
> Hope you can help. Thanks in advance.
>
>
>
> Best regards,
>
>
>
> Yassine
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------
>
> *Confidentiality Notice: *This message is private and may contain
> confidential and proprietary information. If you have received this message
> in error, please notify us and remove it from your system and note that you
> must not copy, distribute or take any action in reliance on it. Any
> unauthorized use or disclosure of the contents of this message is not
> permitted and may be unlawful.
>
>
--
Best regards / Med venlig hilsen
Yassine Kamal Lyauk