Thursday, May 7, 2009

Plot of Max Likelihood surface

> How can I plot the surface of a log likelihood function in GAMS.

Create a parameter that evaluates the log-likelihood function around the optimum. Lets use this example. We add the code:

set j /j1*j50/;
alias (j,jj);
scalar clo; clo = 0.8*c.l;
scalar cup; cup = 1.2*c.l;
scalar cstep; cstep = (cup-clo)/(card(j)-1);
scalar slo; slo = 0.95*sigma.l;
scalar sup; sup = 1.05*sigma.l;
scalar sstep; sstep = (sup-slo)/(card(j)-1);

scalar pc,psigma;

parameter surface(j,jj);
loop((j,jj),
   pc = clo + cstep*(ord(j)-1);
   psigma = slo + sstep*(ord(jj)-1);
   surface(j,jj) = m*log(pc) - m*pc*log(psigma)
                 + (pc-1)*sum(k,log(x(k)-theta))
                 - sum(i,((x(i)-theta)/psigma)**pc);
);
execute_unload "weibull",surface;

Now we can use Chart|Two dimensions|3D Charts|Surface.

weibull

No comments:

Post a Comment