@Rick_SAS
Hi
I am working on a very simple problem that I have addressed several times before, and I always receive good estimates. For some reason, this time I am failing miserably; the maximum likelihood estimates (MLE) are so HUGE. I’m not sure where I went wrong. I need help, please.
Proc iml;
seed=0; theta= 1.5 ; beta= 1; m=50;
print theta beta m ;
**** MLE ***;
start MLE_func(y) global (m,X);
func=0;
theta=y[1];
beta=y[2];
Log_X=log(1+x#beta);
func=func + m*log(theta*beta) - (theta+1) * Log_X[+] ;
Return(func);
finish;
call randseed(seed);
call randgen(U, "Uniform");
Call sort(U);
X =( (1-U)##(-1/theta) - 1 )/ beta;
************* Constrain MLE ***********************;
con={.001 .001, . . };
x0={1,1};
opt={2 0};
tc={10000 16000};
Call nlpqn(rc, MLE_ret, "MLE_func", x0, opt, con,tc);
Theta_hat = MLE_ret[1];
Beta_hat = MLE_ret[2];
print Theta_hat Beta_hat;
quit;
Thank you
When posting an example, please use a seed value that is nonzero so that we can reproduce your results. In the following, I use
seed=10;
You can't perform a MLE on a single datum. You need a sample size greater than 1. I suspect you know this and just forgot to allocate an array for U. This should address your immediate problem:
Proc iml;
seed=10; theta= 1.5 ; beta= 1; m=50;
print theta beta m ;
**** MLE ***;
start MLE_func(y) global (m,X);
theta=y[1];
beta=y[2];
Log_X=log(1+x#beta);
func = m*log(theta*beta) - (theta+1) * Log_X[+] ;
Return(func);
finish;
call randseed(seed);
N = 100;
U = j(N, 1);
call randgen(U, "Uniform");
Call sort(U);
X =( (1-U)##(-1/theta) - 1 )/ beta;
************* Constrain MLE ***********************;
x0={1,1};
con={.001 .001, . . };
opt={2 0};
tc={10000 16000};
Call nlpqn(rc, MLE_ret, "MLE_func", x0, opt, con,tc);
Theta_hat = MLE_ret[1];
Beta_hat = MLE_ret[2];
print Theta_hat Beta_hat;
Thank you so much!!!
I am sorry, I thought that I closed it by just hitting the thumb up.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!