BookmarkSubscribeRSS Feed
Mazen
Calcite | Level 5

Hi

I will be so  thankful to anyone who can help to figure out what is wrong with my code

attached is the code

It suppose to estimate the parameters using NLPQN

if I have one simulated data set, then there is no errors (but results are not good). If I ask for more than one simulation I get error and warnings messages such as

 

WARNING: Invalid argument resulted in missing value result.

that refers to this statement

do L=1 to n;

sum=sum+( X- 1/alpha*( -log(p)/gamma) **(-1/beta) )**2;

end;

and at the end I get this error message

 

ERROR: Overflow error in NLPQN.

I don't know exactly what is my mistake? I tried to change the initial values ...it works but then if I increase the sample size n then I get

the same error again

I will highly appreciate any advice

thank you

3 REPLIES 3
Hutch_sas
SAS Employee

I modified your code to save some of the intermediate values as it was evaluating the objective function, and it appears that you are getting an overflow sometimes when the algorithm computes the following in the objective function:

1/alpha*( -log(p)/gamma) **(-1/beta)      )**2;

Basically, with your constraints beta can be small (0.0001). When it is small and -log(p)/gamma is less than 1 you are trying to compute a very large power, say somthing like 0.8 ** -10000, equivalent to 1.25 ** 10000. My guess is that you really don't intend for beta to be that small? You either need to raise your lower bound for beta or do something special in your objective function to handle that situation.

Mazen
Calcite | Level 5

Thank you so much for your help

you were right about beta, beta shouldn't be small,  I was trying to play with initial values based on your recommendations before I reply

Now, I don't get any errors or warnings but I found that there is no optimizations,for instant whether I take the size of the data (n) 10 or 50, whether the number of simulations (k) =10 or 1000  results are the same don't change at all like if they were fixed no matter how many loops I execute or how big my data are

I also changed the true values of the parameter, the initial values the constrains...but nothing seems to matter, I wasn't sure exactly how to change the objective function.

I wilcome any suggestions or advices

thank you for your help

Hutch_sas
SAS Employee

I am not sure what you are trying to do, but looking at your code, if you are expecting to get the optimization to converge to alpha, beta, and gamma, I believe that you should set p to match the random number stream used in your simulation. Otherwise, I don't see how you could expect it to converge to the right answer. Try doing:

********************* Generating My Data ****************************************;                                                     

        do j=1 to n;                                                                                                                   

              p = Uniform(seed);                                                                                                    

              X=(1/alpha)*(-log(p)/gamma)**(-1/beta);                                                                            

        end;                                                                                                                           

********************************************************************************;                                                      

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!

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
  • 3 replies
  • 1137 views
  • 3 likes
  • 2 in conversation