BookmarkSubscribeRSS Feed
m_hojai82
Calcite | Level 5

Hi there

I wanted to apply proc nlmixed on real data but I got this error:  Execution error for observation 97.

Is there any body here to help me how to solve it?

Best wish 

proc nlmixed data=data qpoints=10 gconv=1e-2;
bounds 0 <=sigma2;
/* Initail Values ---------------- */
parms a0=5.3 a1=1.3
b0=14.3 b1=0.01 b2=0.2 b3=2.5
g1=1.1 g2=-0.1 g3=0.5
sigma2=1
l1=1 l2=2 l3=3 k=0.01;

/* Log Likelihood ---------------- */
if t=0 then do;
lam = exp(g1*GENDER + g2*AGE +g3*CITY + l2*a + l3*b);
loglik=(censored=0)*(log(lam)-lam * time) + (censored=1)*(-lam * time);
end;
else do;
pi = 1/(1 + exp(-(a0 + a1*ADTYPE + a)));
eta = abs(k)**(-2);
mu = b0 + b1*ADTYPE +b2*AGE +b3*GENDER - log(pi)-sigma2*log(k**2)/k-lgamma(eta*(k+k*sigma2))+lgamma(eta) + l1*a + b;
u = sign(k)*(log(Y) - mu)/sigma2;
if Y=0 then loglik=log(1-pi);
else if Y>0 then loglik=log(pi)- lgamma(eta) + eta*log(eta) - log(sigma2) - log(Y) + u*sqrt(eta) - eta*exp(abs(k)*u);
else if Y = . then loglik=0;
end;

model ID ~ general(loglik);
random a b ~ normal([0,0], [1, 0, 1]) subject=ID;
run;

 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Typically, this means that the procedure can't perform the math. Example: you can't use the LOG() function on a negative number or a zero value.

--
Paige Miller
m_hojai82
Calcite | Level 5
Thank you for reply? So where is the problem? In formula or initial parameters or both?
Thank you again.
PaigeMiller
Diamond | Level 26

You have the data. 

 

You need to trace through the code using data from observation 97 to see where a problem could happen. I can't do that for you.

--
Paige Miller
m_hojai82
Calcite | Level 5
Actually I applied this code for log-normal distribution before and I wanted to use generalized gamma distribution instead of LN. As you know LN is a special case of GG when 𝑘 → 0. I applied different amount of K and I got the same error but in different observation. for K near 0 I got this error for observation 97 (Y=0) but for K=500 I got this error for observation 1. I applied LN before on my data so it supposed to get the same result when 𝑘 → 0. anyway thank you for your response. As you said I need to track.
FreelanceReinh
Jade | Level 19

Hello @m_hojai82 and welcome to the SAS Support Communities!


@m_hojai82 wrote:
So where is the problem? In formula or initial parameters or both?

[and earlier:]

...

u = sign(k)*(log(Y) - mu)/sigma2;
if Y=0 then ...



I guess the term log(Y) in the definition of u is a good candidate since you consider the case Y=0 immediately afterwards.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 532 views
  • 1 like
  • 3 in conversation