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;
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);
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);
I should not use X, X1, and X2 for my data. Just use X
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.