BookmarkSubscribeRSS Feed
desireatem
Pyrite | Level 9

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

 

4 REPLIES 4
Rick_SAS
SAS Super FREQ

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.

 

 

 

 

desireatem
Pyrite | Level 9

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

Rick_SAS
SAS Super FREQ

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;
desireatem
Pyrite | Level 9

Thank Rick, Thanks a lot!!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3170 views
  • 1 like
  • 2 in conversation