Dear all,
I am having a difficulty in writing a logic expression of accepting a
complex structure under $DATA session.
For example:
ACCEPT=c(A=1,A=2)
means that record of A equals to 1 or 2 would be accepted. However, for a
logic expression below:
(A=1 OR A=2) AND B<100
which would require A equals to 1 or 2 and in the mean time, B are less
than 100.
NONMEM manual VIII did not specify this type of acceptance. Could anybody
please tell me how to write this kind expression using ACCEPT, or IGNORE in
nonmem? Thanks a lot for your help.
Best Regards
--
Xinting
Logic Expression in $DATA: ACCEPT or IGNORE
5 messages
4 people
Latest: Nov 22, 2014
Hi Xinting,
I’ve worked with these types of statements a good bit, and my personal
preference is to add a column to the data set that makes the selection simpler
(e.g. set it to 1 if (A == 1 or A == 2) and B < 100). Last I knew, it wasn’t
possible to do an “AND” in an ignore statement (and checking the $data
documentation in NONMEM 7.2, that still appears to be the case).
Thanks,
Bill
Quoted reply history
From: [email protected] [mailto:[email protected]] On
Behalf Of Xinting Wang
Sent: Tuesday, November 18, 2014 2:10 PM
To: [email protected]
Subject: [NMusers] Logic Expression in $DATA: ACCEPT or IGNORE
Dear all,
I am having a difficulty in writing a logic expression of accepting a complex
structure under $DATA session.
For example:
ACCEPT=c(A=1,A=2)
means that record of A equals to 1 or 2 would be accepted. However, for a logic
expression below:
(A=1 OR A=2) AND B<100
which would require A equals to 1 or 2 and in the mean time, B are less than
100.
NONMEM manual VIII did not specify this type of acceptance. Could anybody
please tell me how to write this kind expression using ACCEPT, or IGNORE in
nonmem? Thanks a lot for your help.
Best Regards
--
Xinting
Hi Xinting,
You can separate the condition into several statements. For example, if you need to accept (A=1 OR A=2) AND B<100 you instead can have 2 or 3 IGNORE statements (depending on the values A can have), say
IGNORE=(B.GE.100) IGNORE=(A.GT.2) IGNORE=(A.LT.1)
Regards,
Katya
Ekaterina Gibiansky, Ph.D.
CEO&CSO, QuantPharm LLC
Web: www.quantpharm.com
Email: [email protected]
Quoted reply history
On 11/18/2014 3:24 PM, Denney, William S. wrote:
> Hi Xinting,
>
> I’ve worked with these types of statements a good bit, and my personal preference is to add a column to the data set that makes the selection simpler (e.g. set it to 1 if (A == 1 or A == 2) and B < 100). Last I knew, it wasn’t possible to do an “AND” in an ignore statement (and checking the $data documentation in NONMEM 7.2, that still appears to be the case).
>
> Thanks,
>
> Bill
>
> *From:* [email protected] [ mailto: [email protected] ] *On Behalf Of *Xinting Wang
>
> *Sent:* Tuesday, November 18, 2014 2:10 PM
> *To:* [email protected]
> *Subject:* [NMusers] Logic Expression in $DATA: ACCEPT or IGNORE
>
> Dear all,
>
> I am having a difficulty in writing a logic expression of accepting a complex structure under $DATA session.
>
> For example:
>
> ACCEPT=c(A=1,A=2)
>
> means that record of A equals to 1 or 2 would be accepted. However, for a logic expression below:
>
> (A=1 OR A=2) AND B<100
>
> which would require A equals to 1 or 2 and in the mean time, B are less than 100.
>
> NONMEM manual VIII did not specify this type of acceptance. Could anybody please tell me how to write this kind expression using ACCEPT, or IGNORE in nonmem? Thanks a lot for your help.
>
> Best Regards
>
> --
>
> Xinting
Dear Katya and Bill,
Thanks a lot for your suggestion. Multiple IGNORE, as suggested Katya,
actually worked.
Best Regards
Quoted reply history
On 18 November 2014 17:24, Ekaterina Gibiansky <[email protected]>
wrote:
> Hi Xinting,
>
> You can separate the condition into several statements. For example, if
> you need to accept (A=1 OR A=2) AND B<100
> you instead can have 2 or 3 IGNORE statements (depending on the values A
> can have), say
> IGNORE=(B.GE.100) IGNORE=(A.GT.2) IGNORE=(A.LT.1)
>
> Regards,
> Katya
>
> Ekaterina Gibiansky, Ph.D.
> CEO&CSO, QuantPharm LLC
> Web: www.quantpharm.com
> Email: [email protected]
>
>
> On 11/18/2014 3:24 PM, Denney, William S. wrote:
>
> Hi Xinting,
>
>
>
> I’ve worked with these types of statements a good bit, and my personal
> preference is to add a column to the data set that makes the selection
> simpler (e.g. set it to 1 if (A == 1 or A == 2) and B < 100). Last I knew,
> it wasn’t possible to do an “AND” in an ignore statement (and checking the
> $data documentation in NONMEM 7.2, that still appears to be the case).
>
>
>
> Thanks,
>
>
>
> Bill
>
>
>
> *From:* [email protected] [mailto:[email protected]
> <[email protected]>] *On Behalf Of *Xinting Wang
> *Sent:* Tuesday, November 18, 2014 2:10 PM
> *To:* [email protected]
> *Subject:* [NMusers] Logic Expression in $DATA: ACCEPT or IGNORE
>
>
>
> Dear all,
>
>
>
> I am having a difficulty in writing a logic expression of accepting a
> complex structure under $DATA session.
>
>
>
> For example:
>
>
>
> ACCEPT=c(A=1,A=2)
>
>
>
> means that record of A equals to 1 or 2 would be accepted. However, for a
> logic expression below:
>
>
>
> (A=1 OR A=2) AND B<100
>
>
>
> which would require A equals to 1 or 2 and in the mean time, B are less
> than 100.
>
>
>
> NONMEM manual VIII did not specify this type of acceptance. Could anybody
> please tell me how to write this kind expression using ACCEPT, or IGNORE in
> nonmem? Thanks a lot for your help.
>
>
>
> Best Regards
>
>
>
> --
>
> Xinting
>
>
>
--
Xinting
Xinting and others are correct. The syntax of ACCEPT/IGNORE is
limited and cannot handle an expression such as $DATA ACCEPT=((A ==
1.OR.A == 2).AND.B<100) In the NM-TRAN syntax, OR is implied. NOT and
AND cannot be coded.
Instead, the ACCEPT must be negated as IGNORE to change AND to OR:
IGNORE=(.NOT.(A==1.OR.A==2)).OR.B>=100
But (.NOT.(A==1.OR.A==2)) is (A.NE.1.AND.A.NE.2), which cannot be
coded because of the .AND.
Katya's workaround takes advantage of the fact that A takes numeric
values and there are no values between 1 and 2.
Thus, (A.NE.1.AND.A.NE.2) can be implemented with an "or":
(A<1.OR.A>2)
Katya's code is
IGNORE=(B.GE.100) IGNORE=(A.GT.2) IGNORE=(A.LT.1)
The following is equivalent, because NM-TRAN combines all the
IGNORE conditions, whether in one IGNORE list or in multiple ones:
IGNORE=(B.GE.100,A.GT.2,A.LT.1)
The above discussion also applies if the initial ACCEPT had been
IGNORE. NM-TRAN parses the right sides identically.
The intended and workaround code would be
IGNORE=((A == 1.OR.A == 2).AND.B<100) ; intended
ACCEPT=(B.GE.100,A.GT.2,A.LT.1) ; workaround
What if A takes all integer values and the acceptable values of A
are 1 and 6? Then you need something like this, in which all the
conditions are OR'd together: IGNORE=(B.GE.100) IGNORE=(A.GT.6)
IGNORE=(A.LT.1)
IGNORE=(A==2,A==3,A==4,A==5) It could get messy, and I don't think it
can be done at all for a
continuous valued A. At some point, an "and" is needed and the
syntax doesn't allow it.
Instead, Bill Denny's idea would have to be used:
... add a column to the data set that makes the selection simpler
(e.g. set it to 1 if (A == 1 or A == 2) and B < 100). You might do this
outside NONMEM, e.g. Excel.
With NONMEM, it can be done in two separate runs, one to create a
new data set with new data item and a separate run to use IGNORE/ACCEPT
to omit records based on the value in the new data item.
I implemented a simple example. Prob1.ctl sets ACC to 0/1
and ACC is used for ACCEPT in prob2.ctl.
But the NM=TRAN abbreviated code syntax for logical expressions
is also limited, so ACC had to be set in several statements.
I think the code in prob1.ctl can be modified for *any* logical
condition, however complex.
The data file is a fragment.
Attached files:
testab.dat
prob1.ctl
prob2.ctl
I plan to put this in Guide IV NM-TRAN and Guide VIII Help for
NONMEM 74. Comments and suggestions are welcome, especially from
those of you who teach NONMEM classes. Can all this be explained
more clearly and succinctly?
There is a feature in NONMEM 74 that makes it possible
to combine both problems into one NONMEM run:
$TABLE record option "EXCLUDE_BY list".
If any variable in list is non-0, the record is excluded from the
table file. This is implemented as probe.ctl and runs with nm74a. The
nm74a alpha version is available on request (ask Bob Bauer),
but it is not tested, and is for exploratory use only.
It has other new features of interest.
======= testab.dat
C NO A B ID DV MDV
1 1 100 1 0 0
2 2 100 1 0 0
3 3 100 1 0 0
4 1 101 1 0 0
5 2 101 1 0 0
6 3 101 1 0 0
7 1 99 1 0 0
8 2 99 1 0 0
9 3 99 1 0 0
======= prob1.ctl
$PROB test of accept Run #1
; Example of implementation of
; $DATA ACCEPT=((A == 1.OR.A == 2).AND.B<100)
$INPUT NO A B ID DV MDV
$DATA testab.dat IGNORE @
$PRED
; Implements:
; ACC=((A == 1.OR.A == 2).AND.B < 100)
; This cannot be coded directly in NM-TRAN abbreviated code.
; Instead:
; acc=1 if (a==1.or.a==2).and..not.b>=100
ACC=0
IF (A.EQ.1.OR.A.EQ.2) ACC=1
IF (B.GE.100) ACC=0
; The model for this run is unimportant. Keep it simple.
Y=THETA(1)+ETA(1)+EPS(1)
$THETA 1
$OMEGA 1
$SIGMA .4
$TABLE NO A B ID DV MDV ACC
NOPRINT NOAPPEND NOHEADER FILE=prob1.tab
======= prob2.ctl
$PROB test of accept Run #2
$INPUT NO A B ID DV MDV ACC
; Must do a numeric test for ACC==1, because it appears in
; table file as 1.0000E+00
$DATA prob1.tab ACCEPT=(ACC.EQN.1)
$PRED
; the model in this problem should be the model
; used for simulation, analysis, etc.
Y=THETA(1)+ETA(1)+EPS(1)
$THETA 1
$OMEGA 1
$SIGMA .4
$TABLE NO A B ID DV MDV
NOPRINT NOAPPEND FILE=prob2.tab
===== probe.ctl
$PROB test of NONMEM 7.4 exclude_by feature
$INPUT NO A B ID DV MDV
$DATA testab.dat IGNORE @
$PRED ; sets ACC=0 if ((a==1.or.a==2).and.b<100)
ACC=0
IF (A.NE.1.AND.A.NE.2) ACC=1
IF (B.GE.100) ACC=1
; this is the model for both problems.
; It may be more complicated than this.
Y=THETA(1)+ETA(1)+EPS(1)
$THETA 1
$OMEGA 1
$SIGMA .4
; probe.tab has only those records that have ACC=0.
$TABLE NO A B ID DV MDV EXCLUDE_BY ACC
NOPRINT NOAPPEND NOHEADER FILE=probe.tab $PROB test of exclude_by #2
$INPUT NO A B ID DV MDV
$DATA probe.tab (10F12.0) NOOPEN
$THETA 1
$OMEGA 1
$SIGMA .4
; This is the problem that should have $ESTIMATION or
; other tasks using the selected portion of the data set.
Quoted reply history
On Wed, Nov 19, 2014, at 03:14 AM, Xinting Wang wrote:
> Dear Katya and Bill,
>
> Thanks a lot for your suggestion. Multiple IGNORE, as suggested Katya,
> actually worked.
>
> Best Regards
>
> On 18 November 2014 17:24, Ekaterina Gibiansky
> <[email protected]> wrote:
>> Hi Xinting,
>>
>>
You can separate the condition into several statements. For example, if
you need to accept (A=1 OR A=2) AND B<100
>> you instead can have 2 or 3 IGNORE statements (depending on the
>> values A can have), say
>>
IGNORE=(B.GE.100) IGNORE=(A.GT.2) IGNORE=(A.LT.1)
>>
>>
Regards,
>>
Katya
>>
>> Ekaterina Gibiansky, Ph.D.
>>
CEO&CSO, QuantPharm LLC
>>
Web: www.quantpharm.com
>>
Email: [email protected]
>>
>>
>>
On 11/18/2014 3:24 PM, Denney, William S. wrote:
>>> Hi Xinting,
>>>
>>> I’ve worked with these types of statements a good bit, and my
>>> personal preference is to add a column to the data set that makes
>>> the selection simpler (e.g. set it to 1 if (A == 1 or A == 2) and B
>>> < 100). Last I knew, it wasn’t possible to do an “AND” in an ignore
>>> statement (and checking the $data documentation in NONMEM 7.2, that
>>> still appears to be the case).
>>>
>>> Thanks,
>>>
>>> Bill
>>>
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Xinting Wang
>>> Sent: Tuesday, November 18, 2014 2:10 PM To: [email protected]
>>> Subject: [NMusers] Logic Expression in $DATA: ACCEPT or IGNORE
>>>
>>> Dear all,
>>>
>>> I am having a difficulty in writing a logic expression of accepting
>>> a complex structure under $DATA session.
>>>
>>> For example:
>>>
>>> ACCEPT=c(A=1,A=2)
>>>
>>> means that record of A equals to 1 or 2 would be accepted. However,
>>> for a logic expression below:
>>>
>>> (A=1 OR A=2) AND B<100
>>>
>>> which would require A equals to 1 or 2 and in the mean time, B are
>>> less than 100.
>>>
>>> NONMEM manual VIII did not specify this type of acceptance. Could
>>> anybody please tell me how to write this kind expression using
>>> ACCEPT, or IGNORE in nonmem? Thanks a lot for your help.
>>>
>>> Best Regards
>>>
>>> --
>>> Xinting
>
>
>
--
> Xinting
--
Alison Boeckmann
[email protected]