NONMEM Users Network Archive

Hosted by Cognigen

RE: [NMusers] Truncated normal distribution for continuous covariate with known mean and standard error

From: Johansson, Åsa <>
Date: Tue, 8 Dec 2015 13:22:01 +0000

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:

   R = 0
   WT =70+10*R
      CALL RANDOM(5,R)
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,

From: [] On Behalf Of Yassine Kamal Lyauk
Sent: den 8 december 2015 13:14
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):

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) WT=70+10*R;
DOWHILE (WT.GT.50.OR.WT.LT.100); truncation limits of 50 and 100

Other ways to generate a normal truncated distribution can be coded as (from Metrum Institute course 210):

WT=THETA(1) + ETA(1)
WT=THETA(1) + ETA(1)

$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,



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.
Received on Tue Dec 08 2015 - 08:22:01 EST

The NONMEM Users Network is maintained by ICON plc. Requests to subscribe to the network should be sent to: Once subscribed, you may contribute to the discussion by emailing: