10# zhangtao
new;
library optmum,PGRAPH;
format /m1/rd 9,5;
p=(1| 1.1| 1| 1.2| 0.9| 1| 1.05| 1| 1.04| 1);
T=rows(p);
START=1;
PRMTR_IN={0.057 1};
PRMTR_IN=PRMTR_IN';
{xout,fout,gout,cout}=optmum(&lik,PRMTR_in);
"likelihood value is ";
-fout;
"Estimated parameters are:";
xout';
end;
proc LIK(PRMTR1);
local prmtr,sigma, C, L,FORC, likv, J_ITER,lik;
PRMTR=PRMTR1;
sigma=PRMTR[1,.]^2;
C= PRMTR[2,.];
LIKV=0.0;
J_ITER=1;
do until J_ITER>10;
Forc=p[J_ITER,1]-C;
L=(1/SQRT(2*PI*sigma))*EXP((-0.5*FORC*FORC/sigma));
LIK=-LN(L);
LIKV = LIKV+LIK;
J_ITER = J_ITER+1;
endo;
retp(LIKV);
endp;
我用的是7.0版。结果是:
likelihood value is
11.76331
Estimated parameters are:
0.07463 1.02900