Help using Base SAS procedures

NLMIXED Execution error for observation 34.

Reply
Super Contributor
Posts: 297

NLMIXED Execution error for observation 34.

Hello Please, I simulated the data below, ran NLMIXED but had execution error. Any correction. 

 

data tes;
seed=-1;
alpha1 = 1.00;
beta1 = 0.50;
do i = 1 to 500;
lambdaT = 0.25;
lambdaC= 2.00;
er=0+(1)*rannor(1);
t = rand("WEIBULL", 0.75, lambdaT);
c = rand("WEIBULL", 1.00, lambdaC);

time = min(t, c);
censored = (c lt t);
obs=(t lt c);
y= alpha1+beta1*t+ er;
output;
end;
run;

 

proc NLMIXED data=tes;
parms mux=1 sigmax=1 sigma=0.00003 alpha=1 beta=1 ;
Q=sqrt(1/sigmax**2+beta**2/sigma**2);
e=y-alpha-beta*time; emu=y-alpha-beta*mux;
if censored=0 then LL=(-e**2/sigma**2/2-log(sigma**2*sigmax**2)/2
-(time-mux)**2/sigmax**2/2);

if censored=1 then LL=log(1-probnorm(Q*(time-mux-sigma**- (beta*emu/sigma**2*Q**2))))-log(sigma**2+beta**2*sigmax**2) -(emu**2/2**sigma**2)*(1-(beta**2/sigma**2*Q**2));

model y~general(LL);
run;

 

LOG FILE

 

proc NLMIXED data=tes;
24 parms mux=1 sigmax=1 sigma=0.00003 alpha=1 beta=1 ;
25 Q=sqrt(1/sigmax**2+beta**2/sigma**2);
26 e=y-alpha-beta*time; emu=y-alpha-beta*mux;
27 if censored=0 then LL=(-e**2/sigma**2/2-log(sigma**2*sigmax**2)/2
28 -(time-mux)**2/sigmax**2/2);
29
30 if censored=1 then LL=log(1-probnorm(Q*(time-mux-sigma**-
30 ! (beta*emu/sigma**2*Q**2))))-log(sigma**2+beta**2*sigmax**2)
30 ! -(emu**2/2**sigma**2)*(1-(beta**2/sigma**2*Q**2));
31
32 model y~general(LL);
33 *ods output ParameterEstimates=ML;
34 run;

NOTE: Execution error for observation 34.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE NLMIXED used (Total process time):
real time 0.22 seconds
cpu time 0.20 seconds

 

SAS Super FREQ
Posts: 3,476

Re: NLMIXED Execution error for observation 34.

We cannot reproduce your problem that occurs "for observation 34" because you have not set a seed value for the simulation step. Currently the data are different every time you run the program. To obtain reproducible results, put

call streaminit(12345);

as the first line of the program. Also get rid of the call to RANNOR and use RAND("Normal") so that you are using a common stream of random numbers.

 

With these changes, the "execution error" occurs for observation 4.

 

I think the problem is numerical overflow.  Obs 4 has censored=1, so look at that LL formula.

The initial values imply that the expression

-(beta*emu/Sigma**2*Q**2) evaluates to -2E17.

When you try raise Sigma (which is less than 1) to this huge negative power, the result is too large to fit in a double.

 

I suggest that you recheck your formulas.

 

 

 

 

Super Contributor
Posts: 297

Re: NLMIXED Execution error for observation 34.

Thanks Rick, Thank you for your help.

I verified the error in the formula but still having issue as shown below.

 

 data tes;
 call streaminit(12345);
 alpha1 = 1.00;
 beta1 = 0.50;
 do i = 1 to 500;
 lambdaT = 0.25;
 lambdaC= 2.00;
 er=RAND("Normal");
 t = rand("WEIBULL", 0.75, lambdaT);
 c = rand("WEIBULL", 1.00, lambdaC);

 time = min(t, c);
 censored = (c lt t);
 obs=(t lt c);
 y= alpha1+beta1*t+ er;
 output;
 end;
 run;

 

NOTE: The data set WORK.TES has 500 observations and 12 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


 proc NLMIXED data=tes;
 parms mux=1 sigmax=1 sigma=0.03 alpha=1 beta=1 ;
 Q=sqrt(1/sigmax**2+beta**2/sigma**2);
 e=y-alpha-beta*time; emu=y-alpha-beta*mux;
 if censored=0 then LL= -log(sigma**2*sigmax**2)/2
 -e**2/sigma**2/2
 -(time-mux)**2/(2*sigmax**2);

 if censored=1 then LL=-log(sigma**2+beta**2*sigmax**2)
 -emu**2*(1-(beta**2)/(sigma**2*Q**2))/(2*sigma**2)
 + log(1-probnorm(Q*(time-mux-(beta*emu/sigma**2*Q**2))));
 model y~general(LL);
 run;

 

NOTE: Execution error for observation 5.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE NLMIXED used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

SAS Super FREQ
Posts: 3,476

Re: NLMIXED Execution error for observation 34.

Similar problem. The argument to the PROBNORM function is huge, so  1 - probnorm(...) = 0.

Consequently, the LOG function is producing an error.

 

You can debug the problem yourself, by using SAS/IML (or the DATA step) to find out where the errors are occurring. The following program reads Obs 5, then computes the same quantities that you are defining in PROC NLMIXED.  The log tells you which expressions are failing, and then you can figure out why:

 

proc iml;
use tes;
read point 5 var _NUM_ ;
close;

mux=1; Sigmax=1; Sigma=0.00003; alpha=1; beta=1 ;
Q=sqrt(1/sigmax**2+beta**2/sigma**2);
e=y-alpha-beta*time; 
emu=y-alpha-beta*mux;
t1 = -log(sigma**2+beta**2*sigmax**2);
t2 = emu**2 * (1-(beta**2)/(sigma**2*Q**2)) / (2*sigma**2);
a1 = Q*(time-mux-(beta*emu/sigma**2*Q**2));
print a1;
t3 = log( 1 - probnorm(a1) );

LL= t1 - t2 + t3;
Super Contributor
Posts: 297

Re: NLMIXED Execution error for observation 34.

Thank Rick, Thanks a lot!!!

Ask a Question
Discussion stats
  • 4 replies
  • 888 views
  • 1 like
  • 2 in conversation