BookmarkSubscribeRSS Feed
Mina_Juli
Fluorite | Level 6
 

Hello!

I have a code to obtain MLE. In my code NLPTR is used and I get the correct answers when I implement the code using some of the datasets I have; however, for one of the datasets with 268 subjects, I get zeros for all parameters. I run the same code with the first 75 subjects and get the estimates without any problem but it works with just the first 75 subjects in the dataset I have. I don't see any problem with my data. My function is a complicated function and my data is longitudinal with 4 specific time points. I need to estimate 35 parameters. The Error is "Overflow error in *. I also try to resolve the problem by controlling overflow but cannot.

Thanks

 

con = { .  .  .  .  .  .  .  .  .  .  1e-4  1e-4    1e-4      1e-4      1e-4        . . . . . . . . . . . . . . . . . . . .  ,  /* lower bounds */
        .  .  .  .  .  .  .  .  .  .    .     .     0.99     0.99      0.48        . . . . . . . . . . . . . . . . . . . .  }; /* upper bounds */
p   = { 6.46 0.65 0.34 0.2 0.13 5 0.2 0.3 0.2 0.1  1     1     0.5       0.6       0.4         0 0 0 0 6 9 0.4 0.4 1.09 0.5 0.2 0.5 0.5 0.3 0.06 0.1 0.9 0.7 0.3 1.1  };/* initial guess for solution*/ 
opt = {1  4};  

tc=repeat(.,1,13);
*tc[1] = 2;
tc[12]=1E-3;
par=repeat(.,1,10);
par[2]=1E-3;

DO MC=1 TO N_MC;
call NLPTR(rc, result, "LogLik", p, opt, con, tc, par) ;
print result;
*print rc;
Results_all[MC,]=result;
END 

 

9 REPLIES 9
Rick_SAS
SAS Super FREQ

Since the program works for some data but not for other data, we can assume it is the data.

Most likely the objective function has either an exponential function call (EXP(v)) or a ratio (1/v) that is overflowing when v is either large or close to zero.  You need to trap and cap the bad value before you attempt to evaluate the function.

 

Since you are performing MLE, make sure you are working with the log-likelihood function. Never work directly with the likelihood function since it tends to overflow.

 

Lastly, you can debug your problem by removing the loop and concentrating on the single set of data that is causing the problem. Follow the tips in the article "Ten tips before you run an optimization," especially #6, #7, #9, and #10.

Mina_Juli
Fluorite | Level 6

Thanks for the quick response. I appreciate it.

I am working with log-likelihood but it cannot be simplified so much. The following shows how it is:

 

tmp_final = -log( w_0 * tmp_0 + w_1 * tmp_1 + w_2 * tmp_2 + w_3 * tmp_3 + w_4 * tmp_4 );
        f = f + tmp_final;
        end;
   return ( f );

tmp's contain exponential. 

 

I am not sure why par[2] and tc[1] do not work either. Specifically par[2] should control this overflow problem!

 

 

Rick_SAS
SAS Super FREQ

There's not much else I can say without having seeing the LogLik function and data. Can you describe the distribution that you are trying to fit? Have you tried a different optimization algorithm, such as quasi-Newton (NLPQN)? 

 

Your code that shows the log-likelihood seems to have been cut off. There is an END statement, but not DO statement. 

The quantity inside the LOG function looks like the matrix product T*w, where 

T = tmp_0 || tmp_1 || ... || tmp_4

and

w = w0 // w1 // ... // w_4

 

 

Mina_Juli
Fluorite | Level 6

Thank you so much for the response.

I had NLPNRA in my basic codes that I changed to NLPTR. I will continue working on code to find the problem. 

Best regards

Mina_Juli
Fluorite | Level 6

I have a code to obtain MLE. In my code NLPTR is used and I get the correct answers when I implement the code using some of the datasets I have; however, for one of the datasets with 268 subjects, I get zeros for all parameters. I run the same code with the first 75 subjects and get the estimates without any problem but it works with just the first 75 subjects in the dataset I have. I don't see any problem with my data. My function is a complicated function and my data is longitudinal with 4 specific time points. I need to estimate 35 parameters. The Error is "Overflow error in *.". I also try to resolve the problem by controlling overflow but cannot.

con = { .  .  .  .  .  .  .  .  .  .  1e-4  1e-4    1e-4      1e-4      1e-4        . . . . . . . . . . . . . . . . . . . .  ,  /* lower bounds */
        .  .  .  .  .  .  .  .  .  .    .     .     0.99     0.99      0.48        . . . . . . . . . . . . . . . . . . . .  }; /* upper bounds */
p   = { 6.46 0.65 0.34 0.2 0.13 5 0.2 0.3 0.2 0.1  1     1     0.5       0.6       0.4         0 0 0 0 6 9 0.4 0.4 1.09 0.5 0.2 0.5 0.5 0.3 0.06 0.1 0.9 0.7 0.3 1.1  };/* initial guess for solution*/ 
optn = {1    /* maximum   */
      4};   
tc=repeat(.,1,13);
*tc[1] = 2;
tc[12]=1E-3;
par=repeat(.,1,10);
par[2]=1E-3;
DO MC=1 TO N_MC;
call NLPTR(rc, result, "LogLik", p, optn, con,tc,par) ;
print result;
*print rc;
Results_all[MC,]=result;

 Thank you

 

RobPratt
SAS Super FREQ
Please share the full code.
Mina_Juli
Fluorite | Level 6

Thank you for the response.

Ksharp
Super User

It looks like IML code. Post it at IML forum. Rick is there .

Mina_Juli
Fluorite | Level 6

Thank you so much. I will.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 9 replies
  • 1909 views
  • 4 likes
  • 4 in conversation