Programming the statistical procedures from SAS

PROC NLMIXED and coding a Likelihook function

Posts: 0

PROC NLMIXED and coding a Likelihook function

Hey is anyone has an idea about how to code or spot the mistake in the statement below in coding a mixed negative binomial distribution .The code has two data col1 and new_data_1 and in the proc nlmixed a likelihood function is created with those different parameters and it supposed to return me the maximum
proc NLMIXED data=call.Merging;
parms gam0=.1,gam1=0.1,gam2=0.1,gam3=0.1,
array gamma{5};
array oldg{5};
array sigma{5};
array omega{5};
array beta{5};
gamma{1} = gam0; sigma{1} = sig0; omega{1} = ome0; beta{1} = bet0;
gamma{2} = gam1; sigma{2} = sig1; omega{2} = ome1; beta{2} = bet1;
gamma{3} = gam2; sigma{3} = sig2; omega{3} = ome2; beta{3} = bet2;
gamma{4} = gam3; sigma{4} = sig3; omega{4} = ome3; beta{4} = bet3;
gamma{5} = gam4; sigma{5} = sig4; omega{5} = ome4; beta{5} = bet4;
do i=2 to 5;
temp = gamma{i};
gamma{i} = temp + gamma{i-1};
do j=1 to 5;
do k =j to 5;
model new_data_1~General(logII);
********************************log message error***************************
The log message is a note :

NOTE: Execution error for observation 1.
NOTE: PROCEDURE NLMIXED used (Total process time):
real time 1.19 seconds
cpu time 0.18 seconds
Regular Contributor
Posts: 171

Re: PROC NLMIXED and coding a Likelihook function

Posted in reply to deleted_user
I'm not going to try to look at all of your code. However, I would note that it is much easier to debug problems like "Execution error for observation 1" if you write a data step version of your code. In the data step version, you have to change the PARMS statement to a RETAIN statement and eliminate the equal sign between the parameter and the initial value. You also have to get rid of the commas between parameter assignments.

(Parenthetical note 1: your PARMS statement could be written just as easily as

parms gam0-gam4 sig0-sig4 ome0-ome4 bet0-bet4 phi p 0.1;

If you had written your PARMS statement that way, all you would need to do is change the keyword PARMS to RETAIN for that part of the code to work in a data step.)

(Parenthetical note 2: the string THO is not actually named on your PARMS statement and will be treated as a variable in your NLMIXED code rather than as a parameter. Is that what you want? It would appear that you wanted that on the PARMS statement, but placed a semicolon before the assignment of THO=.1Smiley Wink

In addition to changing the PARMS statement to a RETAIN statement, you have to eliminate (or comment out) the MODEL statement. The data step would not know what to do with that line of code.

After you have made appropriate modifications of your code so that it can be executed in a data step, you will get more informative errors regarding the cause of the execution error reported by the NLMIXED procedure.
Posts: 0

Re: PROC NLMIXED and coding a Likelihook function

thanks for the reply but can you be more specific with the data step version of the code ??
Regular Contributor
Posts: 171

Re: PROC NLMIXED and coding a Likelihook function

Posted in reply to deleted_user
You mean, can I write the data step for you? I could do that - but I really don't want to have to do that. I have told you exactly what modifications you need to make to your code in order to convert it from NLMIXED to data step code. Everything in your code is data step code except the invocation statement (how would you change PROC NLMIXED data=call.Merging; into data step code?) , the PARMS statement (which I covered in considerable detail previously), and the MODEL statement (which I discussed previously). Modify or remove each of these as necessary for the code to be a legitimate data step.
Posts: 0

Re: PROC NLMIXED and coding a Likelihook function

Posted in reply to deleted_user
I understand now what you meant by data step version of it .when i put the code into a data step mode it appears that the log has negative arguments which makes the data step failing to execute all the iterations.This is one problem and the other i cant make sense of it is the note
NOTE: DELETE statement executed.
I googled it but i dont see any such log message on the web .
Anyone has an idea??thanks
Posts: 40

Re: PROC NLMIXED and coding a Likelihook function

Posted in reply to deleted_user

I got this error when I was using SEX variable whose values are F and M rather than numeric values! Once I chnage SEX to a numeric  variable, I didn't get this error anymore...

Ask a Question
Discussion stats
  • 5 replies
  • 3 in conversation