input parameter in program

sorry, I want to ask,
I have a program, but there is a problem in understanding the program. 13 parameters are included in my program is obtained from where?

This is partially my initial program:

 

/* yt= muSt + fi * yt-1 + et avec et suit N(0, ht)*/

new;
library optmum,PGRAPH;
#include optmum.ext;
/*optset;
_opstmth = "bfgs stepbt";*/

format /m1 /rd 9,5;
load y[3888,2] = C:\gausslt14\log_return.txt;
yy_d=y[.,1];

t0=rows(yy_d);
LAG_AR=1;
NO_ST=LAG_AR+1; @ NUMBER OF STATES TO BE CONSIDERED@
DMNSION=2^NO_ST;

 

st_mat=zeros(DMNSION,NO_ST);

j=1;

st1=0; do until st1>1;
st=0; do until st>1;

st_mat[j,.]=st1~st;

j=j+1;
st=st+1;endo;
st1=st1+1;endo;

yy=yy_d[lag_ar+1:t0,1];

x_mat= yy_d[Lag_ar:T0-1,1] ;

T=rows(yy);
output file=SandrPTF.out reset;
output off;

@================= Initialize Global Variables============@

START=1;
prmtr_in={4.767376 4.987379 0.0024269 0.08740 -0.0020319 -0.0045147
0.0084271 0.0010101 -0.0071791 -0.0010549 0.0016770 -0.0026814 -0.00600 };
PRMTR_IN=PRMTR_IN';

3 Answers



0



We need more information to provide a meaningful answer. We need to see how the variable prmtr_in is used. If you can show more code, that will be helpful. We may just need to see the objective function code.

aptech

1,773


0



this is all my program, 13 parameters on "prmtr_in"  included in my program is obtained from where? Thank

 

new;
library optmum,PGRAPH;
optset;
_opstmth = "bfgs stepbt";

format /m1 /rd 9,5;

load y[3888,2] = C:\gausslt14\log_return.txt;
yy_d=y[.,1];

t0=rows(yy_d);
LAG_AR=1;
NO_ST=LAG_AR+1; @ NUMBER OF STATES TO BE CONSIDERED@
DMNSION=2^NO_ST;

 

st_mat=zeros(DMNSION,NO_ST);

j=1;

st1=0; do until st1>1;
st=0; do until st>1;

st_mat[j,.]=st1~st;

j=j+1;
st=st+1;endo;
st1=st1+1;endo;

yy=yy_d[lag_ar+1:t0,1];

x_mat= yy_d[Lag_ar:T0-1,1] ;

T=rows(yy);
output file=SandrPTF.out reset;
output off;

@================= Initialize Global Variables============@

START=1;

prmtr_in={4.767376 4.987379 0.0024269 0.08740 -0.0020319 -0.0045147
0.0084271 0.0010101 -0.0071791 -0.0010549 0.0016770 -0.0026814 -0.00600 };
PRMTR_IN=PRMTR_IN';

@ Maximum Likelihood Estimation @
@==================================================@

{xout,fout,gout,cout}=optmum(&lik_fcn,PRMTR_in);
PRM_FNL=TRANS(xout); @ Estimated coefficients, constrained@
prm_11=prm_fnl; save prm_11;
output on;

 

 

"==FINAL OUTPUT========================================================";

"initial values of prmtr is";
prmtr_in';
"==============================================================";
"code is--------";;cout;
"likelihood value is ";; -1*fout;
"Estimated parameters are:";
prm_fnl'; " ";
output off;
"Calculating Hessian..... Please be patient!!!!";

SD_fnl = sqrt(diag(invpd(_opfhess)));

/*hout0=hessp(&lik_fcn,xout);
hout0=(hout0+hout0')./2;
hout=inv(hout0);

grdn_fnl=gradfd(&TRANS,xout);
Hsn_fnl=grdn_fnl*hout*grdn_fnl';
SD_fnl =sqrt(diag(Hsn_fnl));*/

waj=prm_fnl./SD_fnl;

@Standard errors of the estimated coefficients@

output on;
"Standard errors of parameters are:";
sd_fnl';
"===============================================================";
"T-Student of parameters are:";
waj';
"===============================================================";
output off;
/* Don't forget to delete the following line when you estimate the
parameters....

xout=prmtr_in; prm_fnl=trans(xout);
*/

 

{pr_tt0,pr_tl0}=FILTER(XOUT); @Pr[S_t=0|Y_t] and Pr[S_t=0|Y_{t-1}]@

smooth0=SMOOTH(pr_tt0,pr_tl0); @Pr[S_t=0|Y_T], Smoothed probabilities@

res=filter1(prmtr_in);

 

/*FLTR=pr_tt0~pr_tl0~smooth0;
format /m1 /rd 8,4;
output file=hmt4_kim.dta reset; FLTR; output off;*/
xy(seqa(1,1,rows(pr_tt0)),pr_tt0);
xy(seqa(1,1,rows(smooth0)),smooth0);
end;

@ end OF MAIN PROGRAM @

 
@========================================================================@
@========================================================================@
proc LIK_FCN(PRMTR1);
local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;
PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

/* DEFINE PARAMETERS */

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/*VAR_L=ST_MAT*VAR1 + (ONES(DMNSION,NO_ST)-ST_MAT)*VAR0;
VAR_L=VAR_L[.,2];*/
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T;

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;
h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,1]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

PROB_DD=PR_TRF .* PROB__;
/* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1)]*/

r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];
PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;
/* 2^5x1 */
/* Joint density of y_t,S_t,..,S_{t-4} given
past information : */

PR_VAL=SUMC(PR_VL); /* f(y_t|I(t-1)), density of y_t given past
information: This is weighted average of
2^5 conditional densities */

LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; /* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1),y_t]*/
/* Updating of prob. with new information, y_t */
PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
/* Integrate out S_{t-4}: then you get
Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t] */
/* 2^4x1*/

PROB__=VECR(PROB__T~PROB__T);
/* 2^5x1 */

LIKV = LIKV+LIK;
J_ITER = J_ITER+1;

endo;

LOCATE 2,35;"LIKV=";;LIKV;
retp(LIKV);
endp;
@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@
proc (2) = FILTER(PRMTR1);
local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,PR_STL0,PR_STT0,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,TMP,OUT_MAT,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;

PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T; @2^5 x 1@

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;
h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

PR_STT0=ZEROS(T,1); @WILL save Pr[S_t=0|Y_{t}@
PR_STL0=ZEROS(T,1); @WILL save Pr[S_t=0|Y_{t-1}@

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,.]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

 

PROB_DD=PR_TRF .* PROB__;

@-----------------------------------------------------@
TMP=PROB_DD;

TMP=TMP[1:2]+TMP[3:4];

PR_STL0[J_ITER,1]=TMP[1,1]; @Pr[S_t=0|Y_t]@
@------------------------------------------------------@

r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];

PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;

 

PR_VAL=SUMC(PR_VL); @f(y_t| Y_{t-1})@
LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; @Pr[S_t, S_{t-1},S_{t-2},S_{t-3},S_{t-4} | Y_t]@
@-------------------------------------------------------@
TMP=PRO_;

TMP=TMP[1:2]+TMP[3:4];

PR_STT0[J_ITER,1]=TMP[1,1]; @Pr[S_t=0|Y_t]@
@-------------------------------------------------------@

PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
@Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t]@

PROB__=VECR(PROB__T~PROB__T);
J_ITER = J_ITER+1;
endo;

retp(PR_STT0,PR_STL0);
endp;
@======================================================================@
@======================================================================@
proc SMOOTH(pr_tt0,pr_tl0);

@pr_TT0 contains Pr[S_t|Y_t]@
@pr_TL0 contains Pr[S_t|Y_{t-1}]@
local ppr, qpr, pr_sm0,pr_sm1, j_iter,pr_sm00,pr_sm01,pr_sm10,pr_sm11,
pr_tt1,pr_tl1;

PPR=PRM_fnl[1,1]; @Pr[St=1/St-1=1]@
QPR=PRM_fnl[2,1]; @Pr[St=0/St-1=0]@

pr_tt1=1-pr_tt0;
pr_tl1=1-pr_tl0;

pr_sm0=pr_tt0; @ pr_sm0 will contain Pr[S_t|Y_T]@
pr_sm1=pr_tt1;
j_iter=T-1;
do until j_iter < 1;

@The followings are P[S_t, S_t+1|Y_T] @

pr_sm00=pr_sm0[j_iter+1,1]*qpr* pr_tt0[j_iter,1]/ pr_tl0[j_iter+1,1];

pr_sm01=pr_sm1[j_iter+1,1]*(1-qpr)*pr_tt0[j_iter,1]/ pr_tl1[j_iter+1,1];

pr_sm10=pr_sm0[j_iter+1,1]*(1-ppr)*pr_tt1[j_iter,1]/ pr_tl0[j_iter+1,1];

pr_sm11=pr_sm1[j_iter+1,1]*ppr* pr_tt1[j_iter,1]/ pr_tl1[j_iter+1,1];

pr_sm0[j_iter,1]=pr_sm00+pr_sm01;
pr_sm1[j_iter,1]=pr_sm10+pr_sm11;

j_iter=j_iter -1;
endo;
retp(pr_sm0); @This proc returns Pr[S_t=0|Y_T]@
endp;

 

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

proc filter1(PRMTR1);

local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,r,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;
PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

/* DEFINE PARAMETERS */

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/*VAR_L=ST_MAT*VAR1 + (ONES(DMNSION,NO_ST)-ST_MAT)*VAR0;
VAR_L=VAR_L[.,2];*/
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T;

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;

 

h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

r=zeros(T,1);

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,1]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

PROB_DD=PR_TRF .* PROB__;
/* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1)]*/
r[J_ITER,1]=sumc(F_CAST1.*PROB_DD);
r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];
PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;
/* 2^5x1 */
/* Joint density of y_t,S_t,..,S_{t-4} given
past information : */

PR_VAL=SUMC(PR_VL); /* f(y_t|I(t-1)), density of y_t given past
information: This is weighted average of
2^5 conditional densities */

LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; /* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1),y_t]*/
/* Updating of prob. with new information, y_t */
PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
/* Integrate out S_{t-4}: then you get
Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t] */
/* 2^4x1*/

PROB__=VECR(PROB__T~PROB__T);
/* 2^5x1 */

LIKV = LIKV+LIK;
J_ITER = J_ITER+1;
endo;

LOCATE 2,35;"LIKV=";;LIKV;

retp(r);
endp;

 

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

 
proc TRANS(c0); @ constraining values of reg. coeff.@
local c1,m,u,d1,d2,d3,d4,d5,d6;

c1=c0;

c1[1:2,.]=exp(c0[1:2,.])./ (1+exp(c0[1:2,.]));
/*c1[10:11,.]=2*(exp(c0[10:11,.])./ (1+exp(c0[10:11,.])))-1;*/
c1[10:11,.]=c0[10:11,.]./ ( 1 + abs(c0[10:11,.]));
retp(c1);
endp;

 



0



As is stated in the documentation for the function optmum, the second input to the function optmum is a vector of start values. The start values are the initial parameter values used in the optimization routine.

aptech

1,773

Your Answer

3 Answers

0

We need more information to provide a meaningful answer. We need to see how the variable prmtr_in is used. If you can show more code, that will be helpful. We may just need to see the objective function code.

0

this is all my program, 13 parameters on "prmtr_in"  included in my program is obtained from where? Thank

 

new;
library optmum,PGRAPH;
optset;
_opstmth = "bfgs stepbt";

format /m1 /rd 9,5;

load y[3888,2] = C:\gausslt14\log_return.txt;
yy_d=y[.,1];

t0=rows(yy_d);
LAG_AR=1;
NO_ST=LAG_AR+1; @ NUMBER OF STATES TO BE CONSIDERED@
DMNSION=2^NO_ST;

 

st_mat=zeros(DMNSION,NO_ST);

j=1;

st1=0; do until st1>1;
st=0; do until st>1;

st_mat[j,.]=st1~st;

j=j+1;
st=st+1;endo;
st1=st1+1;endo;

yy=yy_d[lag_ar+1:t0,1];

x_mat= yy_d[Lag_ar:T0-1,1] ;

T=rows(yy);
output file=SandrPTF.out reset;
output off;

@================= Initialize Global Variables============@

START=1;

prmtr_in={4.767376 4.987379 0.0024269 0.08740 -0.0020319 -0.0045147
0.0084271 0.0010101 -0.0071791 -0.0010549 0.0016770 -0.0026814 -0.00600 };
PRMTR_IN=PRMTR_IN';

@ Maximum Likelihood Estimation @
@==================================================@

{xout,fout,gout,cout}=optmum(&lik_fcn,PRMTR_in);
PRM_FNL=TRANS(xout); @ Estimated coefficients, constrained@
prm_11=prm_fnl; save prm_11;
output on;

 

 

"==FINAL OUTPUT========================================================";

"initial values of prmtr is";
prmtr_in';
"==============================================================";
"code is--------";;cout;
"likelihood value is ";; -1*fout;
"Estimated parameters are:";
prm_fnl'; " ";
output off;
"Calculating Hessian..... Please be patient!!!!";

SD_fnl = sqrt(diag(invpd(_opfhess)));

/*hout0=hessp(&lik_fcn,xout);
hout0=(hout0+hout0')./2;
hout=inv(hout0);

grdn_fnl=gradfd(&TRANS,xout);
Hsn_fnl=grdn_fnl*hout*grdn_fnl';
SD_fnl =sqrt(diag(Hsn_fnl));*/

waj=prm_fnl./SD_fnl;

@Standard errors of the estimated coefficients@

output on;
"Standard errors of parameters are:";
sd_fnl';
"===============================================================";
"T-Student of parameters are:";
waj';
"===============================================================";
output off;
/* Don't forget to delete the following line when you estimate the
parameters....

xout=prmtr_in; prm_fnl=trans(xout);
*/

 

{pr_tt0,pr_tl0}=FILTER(XOUT); @Pr[S_t=0|Y_t] and Pr[S_t=0|Y_{t-1}]@

smooth0=SMOOTH(pr_tt0,pr_tl0); @Pr[S_t=0|Y_T], Smoothed probabilities@

res=filter1(prmtr_in);

 

/*FLTR=pr_tt0~pr_tl0~smooth0;
format /m1 /rd 8,4;
output file=hmt4_kim.dta reset; FLTR; output off;*/
xy(seqa(1,1,rows(pr_tt0)),pr_tt0);
xy(seqa(1,1,rows(smooth0)),smooth0);
end;

@ end OF MAIN PROGRAM @

 
@========================================================================@
@========================================================================@
proc LIK_FCN(PRMTR1);
local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;
PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

/* DEFINE PARAMETERS */

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/*VAR_L=ST_MAT*VAR1 + (ONES(DMNSION,NO_ST)-ST_MAT)*VAR0;
VAR_L=VAR_L[.,2];*/
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T;

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;
h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,1]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

PROB_DD=PR_TRF .* PROB__;
/* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1)]*/

r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];
PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;
/* 2^5x1 */
/* Joint density of y_t,S_t,..,S_{t-4} given
past information : */

PR_VAL=SUMC(PR_VL); /* f(y_t|I(t-1)), density of y_t given past
information: This is weighted average of
2^5 conditional densities */

LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; /* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1),y_t]*/
/* Updating of prob. with new information, y_t */
PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
/* Integrate out S_{t-4}: then you get
Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t] */
/* 2^4x1*/

PROB__=VECR(PROB__T~PROB__T);
/* 2^5x1 */

LIKV = LIKV+LIK;
J_ITER = J_ITER+1;

endo;

LOCATE 2,35;"LIKV=";;LIKV;
retp(LIKV);
endp;
@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@
proc (2) = FILTER(PRMTR1);
local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,PR_STL0,PR_STT0,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,TMP,OUT_MAT,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;

PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T; @2^5 x 1@

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;
h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

PR_STT0=ZEROS(T,1); @WILL save Pr[S_t=0|Y_{t}@
PR_STL0=ZEROS(T,1); @WILL save Pr[S_t=0|Y_{t-1}@

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,.]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

 

PROB_DD=PR_TRF .* PROB__;

@-----------------------------------------------------@
TMP=PROB_DD;

TMP=TMP[1:2]+TMP[3:4];

PR_STL0[J_ITER,1]=TMP[1,1]; @Pr[S_t=0|Y_t]@
@------------------------------------------------------@

r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];

PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;

 

PR_VAL=SUMC(PR_VL); @f(y_t| Y_{t-1})@
LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; @Pr[S_t, S_{t-1},S_{t-2},S_{t-3},S_{t-4} | Y_t]@
@-------------------------------------------------------@
TMP=PRO_;

TMP=TMP[1:2]+TMP[3:4];

PR_STT0[J_ITER,1]=TMP[1,1]; @Pr[S_t=0|Y_t]@
@-------------------------------------------------------@

PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
@Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t]@

PROB__=VECR(PROB__T~PROB__T);
J_ITER = J_ITER+1;
endo;

retp(PR_STT0,PR_STL0);
endp;
@======================================================================@
@======================================================================@
proc SMOOTH(pr_tt0,pr_tl0);

@pr_TT0 contains Pr[S_t|Y_t]@
@pr_TL0 contains Pr[S_t|Y_{t-1}]@
local ppr, qpr, pr_sm0,pr_sm1, j_iter,pr_sm00,pr_sm01,pr_sm10,pr_sm11,
pr_tt1,pr_tl1;

PPR=PRM_fnl[1,1]; @Pr[St=1/St-1=1]@
QPR=PRM_fnl[2,1]; @Pr[St=0/St-1=0]@

pr_tt1=1-pr_tt0;
pr_tl1=1-pr_tl0;

pr_sm0=pr_tt0; @ pr_sm0 will contain Pr[S_t|Y_T]@
pr_sm1=pr_tt1;
j_iter=T-1;
do until j_iter < 1;

@The followings are P[S_t, S_t+1|Y_T] @

pr_sm00=pr_sm0[j_iter+1,1]*qpr* pr_tt0[j_iter,1]/ pr_tl0[j_iter+1,1];

pr_sm01=pr_sm1[j_iter+1,1]*(1-qpr)*pr_tt0[j_iter,1]/ pr_tl1[j_iter+1,1];

pr_sm10=pr_sm0[j_iter+1,1]*(1-ppr)*pr_tt1[j_iter,1]/ pr_tl0[j_iter+1,1];

pr_sm11=pr_sm1[j_iter+1,1]*ppr* pr_tt1[j_iter,1]/ pr_tl1[j_iter+1,1];

pr_sm0[j_iter,1]=pr_sm00+pr_sm01;
pr_sm1[j_iter,1]=pr_sm10+pr_sm11;

j_iter=j_iter -1;
endo;
retp(pr_sm0); @This proc returns Pr[S_t=0|Y_T]@
endp;

 

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

proc filter1(PRMTR1);

local prmtr, ppr,qpr,prob__0,prob__1,QQ, lik, j_iter, pr__0_l,pr__1_l,
F_cast, var_L, pr_val,likv,phi,PSIX,
vecp,st,st1,st2,st3,st4,ST5,ST6,ST7,ST8,ST9,ST10,ST11,ST12,ST13,
pr_tr,pr_trf1,pr_trf,prob__t,prob__,pro_,pr_vl,j,psi1,psi2,var_c,
delta0,DELTA1,MU0,MU1,st_k,st_k1,st_k2,st_k3,st_k4,
f_cast1,f_cast2,PR_VL1,PR_VL2,pr_trf7,pr_trf0,
PR_TRF2,PR_TRF3,PR_TRF4,PR_TRF5,PR_TRF6,psic,psiL,
TMPRY1,TMPRY2,SM_PRL,TMP_P0,SM_PR0,JJJ,MU_MAT,D_MAT,FLT_PRN,r,
F1,F2,TMP00,TMP0,SM_PR00,prob_dd,VAR0,VAR1,A,EN,var,w0,w1,a10,a11,b0,b1,c0,c1,u0,u1,h0,h1,h_L,h,r0,r1;
PRMTR=TRANS(PRMTR1);

LOCATE 15,1; PRMTR';

/* DEFINE PARAMETERS */

PPR=PRMTR[1,1]; @Pr[St=1/St-1=1]@
QPR=PRMTR[2,1]; @Pr[St=0/St-1=0]@

PHI=PRMTR[3,1];

MU0=PRMTR[4,1]; @ recession, vs. boom@
MU1=PRMTR[5,1]; @ recession, vs. boom@

w0=prmtr[6,1];
w1=prmtr[7,1];

a10=prmtr[8,1];
a11=prmtr[9,1];
b0=prmtr[10,1];
b1=prmtr[11,1];
c0=prmtr[12,1];
c1=prmtr[13,1];
MU_MAT=ST_MAT*MU1 + (ONES(DMNSION,NO_ST)-ST_MAT)*MU0;
/*VAR_L=ST_MAT*VAR1 + (ONES(DMNSION,NO_ST)-ST_MAT)*VAR0;
VAR_L=VAR_L[.,2];*/
/* A MATRIX OF TRANSITION PROBABILITIES */

PR_TR=(QPR~ (1-PPR))|
((1-QPR)~ PPR);

/* INITIALIZING THE FILTER WITH STEADY-STATE PROBABILITIES */

A = (eye(2)-pr_tr)|ones(1,2);
EN=(0|0|1);
PROB__T = INV(A'A)*A'EN; @PR[S_t=0]|PR[S_t=1],
2x1 steady-state PROBABILITIES@

PR_TRF0=VEC(PR_TR);

PR_TRF =PR_TRF0;
PROB__T=VECR(PROB__T~PROB__T);
PROB__=PROB__T;

var = vcx(yy); /*initialisation de ht*/
h0 = zeros(T,1);
h1 = zeros(T,1);
h = zeros(T,1);

r0 = zeros(T,1);
r1 = zeros(T,1); /* vecteur des variances*/
r0[1] = w0 + (a10+b0)*var; /* premi�re variance*/
r1[1] = w1 + (a11+b1)*var;

 

h0[1] = exp(r0[1]); /* premi�re variance*/
h1[1] = exp(r1[1]);

h[1] = qpr.*(mu0^2+h0[1])+(1-qpr).*(mu1^2+h1[1])-(qpr.*mu0+(1-qpr).*mu1)^2;

u0= zeros(T,1); /*cr�ation des vecteurs des r�sidus*/
u1= zeros(T,1);
u0[1]=YY[1,1]-mu0-X_MAT[1,1]*phi;
u1[1]=YY[1,1]-mu1-X_MAT[1,1]*phi;

r=zeros(T,1);

LIKV=0.0;
J_ITER=2;
do until J_ITER>T;
F_CAST1=(YY[J_ITER,1]-X_MAT[J_ITER,1]*PHI)*ONES(DMNSION,1)-MU_MAT[.,2];

PROB_DD=PR_TRF .* PROB__;
/* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1)]*/
r[J_ITER,1]=sumc(F_CAST1.*PROB_DD);
r0[J_ITER]= w0 + a10*(abs(u0[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b0.*ln(h[J_ITER-1]) + c0.*(u0[J_ITER-1]./SQRT(h[J_ITER-1] ));

h0[J_ITER]=exp(r0[J_ITER]);

r1[J_ITER]= w1 + a11*(abs(u1[J_ITER-1]./SQRT h[J_ITER-1])-SQRT(2./PI))+ b1.*ln(h[J_ITER-1]) + c1.*(u1[J_ITER-1]./SQRT(h[J_ITER-1] ));

h1[J_ITER]=exp(r1[J_ITER]);

h[J_ITER] = qpr.*(mu0^2+h0[J_ITER])+(1-qpr).*(mu1^2+h1[J_ITER])-(qpr.*mu0+(1-qpr).*mu1)^2;

h_L=h0[J_ITER]|h1[J_ITER]|h0[J_ITER]|h1[J_ITER];
PR_VL=(1./SQRT(2.*PI.*h_L)).*EXP(-0.5*F_CAST1.*F_CAST1./h_L).*PROB_DD;
/* 2^5x1 */
/* Joint density of y_t,S_t,..,S_{t-4} given
past information : */

PR_VAL=SUMC(PR_VL); /* f(y_t|I(t-1)), density of y_t given past
information: This is weighted average of
2^5 conditional densities */

LIK=-1*LN(PR_VAL);

PRO_=PR_VL/PR_VAL; /* Pr[S_t,S_{t-1},S_{t-2},S_{t-3},S_{t-4} | I(t-1),y_t]*/
/* Updating of prob. with new information, y_t */
PROB__T=PRO_[1:DMNSION/2,1]+PRO_[DMNSION/2+1:DMNSION,1];
/* Integrate out S_{t-4}: then you get
Pr[S_t, S_{t-1},S_{t-2},S_{t-3}| Y_t] */
/* 2^4x1*/

PROB__=VECR(PROB__T~PROB__T);
/* 2^5x1 */

LIKV = LIKV+LIK;
J_ITER = J_ITER+1;
endo;

LOCATE 2,35;"LIKV=";;LIKV;

retp(r);
endp;

 

@++++++++++++++++++++++++++++++++++++++++++++++++++++++++@

 
proc TRANS(c0); @ constraining values of reg. coeff.@
local c1,m,u,d1,d2,d3,d4,d5,d6;

c1=c0;

c1[1:2,.]=exp(c0[1:2,.])./ (1+exp(c0[1:2,.]));
/*c1[10:11,.]=2*(exp(c0[10:11,.])./ (1+exp(c0[10:11,.])))-1;*/
c1[10:11,.]=c0[10:11,.]./ ( 1 + abs(c0[10:11,.]));
retp(c1);
endp;

 

0

As is stated in the documentation for the function optmum, the second input to the function optmum is a vector of start values. The start values are the initial parameter values used in the optimization routine.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.