I am trying to calculate the MLE of a 3-parameter Gumbell. The vector f[1], f[2], f[3] are partial derivative equations with respect to the three parameters delta, omega, and tau. I have attached the paper on the 3-parameter Gumbell. The data set extra consists of a 1X73 vector of continuous values that represent a distribution that I am trying to fit with the Gumbell. Error messages indicate that matrices somewhere are not conformable for multiplications, but I do not see how to fix the problem. Creating sumfactor variables was my attempt, but that did not work.
proc iml;
use extra;
read all var{extra} into x;
start Fun(var) global(x,omega,tau,delta);
delta = var[1]; omega= var[2]; tau = var[3];
n=73;
w=exp(-(x - omega)/tau); u=exp(omega/tau);
p=1 - (1 -delta)*(1 - exp(w) + exp(-u)); factor1= (x - omega)*(exp(-w))*w + omega*(exp(-u))*u ;
sumfactor1=sum(factor1);
q=-(2*(1 - delta)*sumfactor1)/(tau*tau*p);
f = j(1, 3, .);
factor2=( ( 1 - exp(w) + exp(-u) ) /p ) ;
sumfactor2=sum(factor2);
f[1] = n/delta -2*sumfactor2;
factor3=(1 -w);
sumfactor3=sum(factor3);
factor4= exp(-w)*w - u*exp(-u) ;
sumfactor4=sum(factor4);
f[2] = (1/tau)*sumfactor3 +2*(1 - delta)*sumfactor4/(p*tau);;
factor5=x - omega;
sumfactor5=sum(factor5);
f[3] = (-n/tau) + (1/(tau*tau))*sumfactor5*(1 - w) + q;
return (f);
finish;
blc=j(1,3,.);
con = {1e-6 1e-6 1e-6, . . .};
x0 = {0.2 1.3 0.2};
optn = {3 1};
call nlphqn(rc, Soln, "Fun", x0, optn, blc=con); /* or use NLPLM or nlphqn*/
print Soln;
run;
Yes, the paper says that the parameters are estimated by using MLE. So, you should specify the loglikelihood (LL) equation (Eqn 1.4) in a module and then use nonlinear optimization to obtain the parameter values that maximize the LL objective function. The maximum likelihood estimates will satisfy equations 1.5-1.7, but you do not use those equations to solve the problem. Equations 1.5-1.7 \just state that the gradient of the LL is zero at the optimal parameter value.
Error messages indicate that matrices somewhere are not conformable for multiplications, but I do not see how to fix the problem. Creating sumfactor variables was my attempt, but that did not work.
Whenever you get error messages, show us the log; in this case we need to see the entire log for this PROC IML. We need you to copy the log as text and then paste it into the window that appears when you click on the </> icon.
@die_walkurie wrote:
Attached is the requested log output. Thanks for your help.
Please try again. The Log didn't make it.
@die_walkurie wrote:
Attached is the requested log output. Thanks for your help.
The request was for you to paste the response into your reply following specific instructions that I gave; we did not want you to attach the log in any way.
I'll look at your program more carefully, but my first impression is that it doesn't look like you are using the log-likelihood function. It looks like you are summing the (raw) likelihood.
Yes, the paper says that the parameters are estimated by using MLE. So, you should specify the loglikelihood (LL) equation (Eqn 1.4) in a module and then use nonlinear optimization to obtain the parameter values that maximize the LL objective function. The maximum likelihood estimates will satisfy equations 1.5-1.7, but you do not use those equations to solve the problem. Equations 1.5-1.7 \just state that the gradient of the LL is zero at the optimal parameter value.
Usually, I use the NLPNRA routine, but I suspect you can use almost any of the NLP* functions in SAS IML because there are few constraints on the parameters. I think there is only the boundary constraint that scale > 0 [and maybe shape > 0? I didn't see any constraints in the paper.]
I've written several articles about MLE. The following might be helpful:
1. Maximum likelihood estimation in SAS/IML - The DO Loop
2 Two ways to compute maximum likelihood estimates in SAS - The DO Loop
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.