turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-13-2017 09:01 AM - edited 11-13-2017 09:02 AM

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
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Mina_Juli

11-13-2017 09:13 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

11-13-2017 12:36 PM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Mina_Juli

11-13-2017 01:28 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

11-15-2017 09:43 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Mina_Juli

11-12-2017 11:47 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Mina_Juli

11-12-2017 07:47 PM

Please share the full code.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobPratt

11-13-2017 08:31 AM

Thank you for the response.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Mina_Juli

11-13-2017 08:14 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

11-13-2017 08:32 AM

Thank you so much. I will.