BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Salah
Quartz | Level 8

Hello

 

I am working on an optimization problem inside a bootstrap. I found out that I get the same result for each bootstrap. I checked my data as I was worried that it might be degenerated data which is not the case. I don't know what causes the nlpnra to return the same MLE? I also tried different functions like nlpqn but that didn't change anything. 

 


proc iml;


m=40; B=10;
alpha =1; Lambda=1.5;

** Data simulation  **;
************************;
start Data(alpha,lambda,m) ;
seed=0;
U=ranuni(repeat(seed,m,1));
X=( 1-(1-U)##(1/alpha) )##(1/lambda);
return(X);
finish;
*******************************************************;
start MLE_func(y) global(X,X1);
m=nrow(x);
func=0;
alpha=y[1];
lambda=y[2];

Sum_log=J(m,1,0);
Sum_log=log(x);
Sum_log_1=J(m,1,0);
Sum_log_1=log(1-X##lambda);

func=func + m*log(alpha*lambda)+(lambda-1)* Sum_log[+] + (alpha-1) * Sum_log_1[+] ;
Return(func);
finish;


con = {1e-6 1e-6, . .};
optn = {2 0};
tc={10000 14000};

********************************************;
*** Bootstrap Steps ***;
********************************************;

Step1:

X=Data(alpha,lambda,m);
x0_MLE= {0.05, 0.05};
call nlpnra(rc, MLE_ret, "MLE_func", x0_MLE, optn, con,tc);
alpha_mle = MLE_ret[1];
lambda_mle = MLE_ret[2];

*****************************************************************;
Step2:

B_alpha1 = J(B,1,0); B_Lambda1 = J(B,1,0);

Do i=1 to B;

X1=Data(alpha_mle,lambda_mle,m);
x0_MLE = MLE_ret[1] || MLE_ret[2];

call nlpnra(rc, MLE_ret, "MLE_func", x0_MLE, optn, con,tc);
B_alpha1[i] = MLE_ret[1];
B_lambda1[i] = MLE_ret[2];

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

 

end;

print B_alpha1 B_lambda1 ;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

This is a duplicate of 

Solved: Re: Bootstrap with maximization problem - SAS Support Communities

where I answered the question. The answer is that the MLE_func function uses the global variable X, which is always has the same value inside the loop DO i=1 to B.

 

Change the line

X1=Data(alpha_mle,lambda_mle,m);

to 

X=Data(alpha_mle,lambda_mle,m);

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

This is a duplicate of 

Solved: Re: Bootstrap with maximization problem - SAS Support Communities

where I answered the question. The answer is that the MLE_func function uses the global variable X, which is always has the same value inside the loop DO i=1 to B.

 

Change the line

X1=Data(alpha_mle,lambda_mle,m);

to 

X=Data(alpha_mle,lambda_mle,m);

 

Salah
Quartz | Level 8

I should not use X, X1, and X2 for my data. Just use X

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!
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
  • 2 replies
  • 355 views
  • 1 like
  • 2 in conversation