Quartz | Level 8

## call nlpnra returns the same value each time ?

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
SAS Super FREQ

## Re: call nlpnra returns the same value each time ?

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);

2 REPLIES 2
SAS Super FREQ

## Re: call nlpnra returns the same value each time ?

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);

Quartz | Level 8

## Re: call nlpnra returns the same value each time ?

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

From The DO Loop