again I have go a question about the replication of the Filardo (1994) Paper using maximum likelihood.
The code is:
Code: Select all
****************************************************************************************
************************* Reading in and Transforming the Data *************************
****************************************************************************************
cal(m) 1948
open data filardo.dat
data(format=prn,org=cols) 1948:1 1992:8 year month ip cli dfi xli sp fed tspread
set ipgr = 100.0*log(ip/ip{1})
stats(noprint) ipgr * 1959:12
compute stdearly=sqrt(%variance)
stats(noprint) ipgr 1960:1 *
compute stdlate=sqrt(%variance)
set ipgradjust = %if(t<=1959:12,ipgr*stdlate/stdearly,ipgr)
set g = ipgradjust
set cligr = 100.0*log(cli/cli{1})
set spgr = 100.0*log(sp/sp{1})
set xlidiff = xli-xli{1}
set ffdiff = fed-fed{1}
set tspdiff = tspread-tspread{1}
set dfismooth = dfi+2*dfi{1}+2*dfi{2}+dfi{3}
* Center variabes to zero means
dofor s = cligr spgr xlidiff ffdiff tspdiff dfismooth
diff(center) s
end dofor s
*****************************************************************************************
**************************** Setting up the Markov Switching ****************************
*****************************************************************************************
source msvarsetup.src
compute nlags=4
compute gstart=1948:6,gend=1992:8
@MSVARSetup(lags=nlags, Switch=M)
# g
nonlin(parmset=common) mu phi sigma
nonlin(parmset=fixed) p
frml loglftp = log(%MSVarProb(t))
@MSVARInitial gstart gend
maximize(parmset=fixed+common,start=(pstar=%MSVARInit()), reject=%MSVARInitTransition()==0.0,$
method=bfgs) loglftp gstart gend
**********************************************************************
******************** Time varying probabilities **********************
**********************************************************************
dec equation p1eq p2eq
dec vector v1 v2
nonlin(parmset=tv) v1 v2
**********************************************************************
********** Overwriting the standard fixed transition matrix **********
**********************************************************************
function %MSVARPmat time
type rect %MSVARPmat
type int time
*
local integer i j
local rect pexpand
local real z
*
compute p(1,1)=%(z=exp(%dot(%eqnxvector(p1eq,time),v1)),z/(1+z))
compute p(1,2)=%(z=exp(%dot(%eqnxvector(p2eq,time),v2)),1/(1+z))
compute %MSVARInitTransition()
*
if nexpand==nstates {
dim pexpand(nstates,nstates-1)
ewise pexpand(i,j)=%if(i==nstates,-1.0,i==j)
compute %MSVARPmat=pexpand*p
ewise %MSVARPmat(i,j)=%if(i==nstates,1.0+%MSVARPmat(i,j),%MSVARPmat(i,j))
}
else {
dim %MSVARPmat(nexpand,nexpand)
ewise %MSVARPmat(i,j)=MSVARTransProbs(MSVARTransLookup(i,j))
}
end
**********************************************************************
******* Initialize the probabilities using only the intercepts *******
**********************************************************************
function TVPInit
type vector TVPInit
*
local rect a
local integer i j
*
compute p=||%logistic(v1(1),1.0),1-%logistic(v2(1),1.0)||
compute TVPInit=%MSVARInit()
end
**********************************************************************
********************* Calculating the Likelihood *********************
**********************************************************************
frml logltvtp = %MSVARPMat(t),log(%MSVarProb(t))
**********************************************************************
****************** Initialize the other Parameters *******************
**********************************************************************
*** Define the logistic index for the transitions
equation p1eq *
# constant cligr{1}
equation p2eq *
# constant cligr{1}
***Starting Values Except Sigma (initialized in @MSVARInitial)
compute v1=log(.7/.3)~~0.0
compute v2=log(.95/.05)~~0.0
compute mu(1)=-1.7,mu(2)=.3
*********************************************************************
**************** Maximization of the Log-Likelihood *****************
*********************************************************************
maximize(parmset=tv+common,start=(pstar=TVPInit()),$
method=bfgs) logltvtp gstart gend
Code: Select all
**********************************************************************
****************** Initialize the other Parameters *******************
**********************************************************************
*** Define the logistic index for the transitions
equation p1eq *
# constant cligr{1}
equation p2eq *
# constant cligr{1}
***Starting Values Except Sigma (initialized in @MSVARInitial)
compute v1=log(.7/.3)~~0.0
compute v2=log(.95/.05)~~0.0
compute mu(1)=-1.7,mu(2)=.3
*********************************************************************
**************** Maximization of the Log-Likelihood *****************
*********************************************************************
maximize(parmset=tv+common,start=(pstar=TVPInit()),$
method=bfgs) logltvtp gstart gend
Code: Select all
Convergence in 21 Iterations. Final criterion was 0.0000062 <= 0.0000100
Monthly Data From 1948:06 To 1992:08
Usable Observations 531
Function Value -595.8451
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. V1(1) 1.330191142 0.498559139 2.66807 0.00762882
2. V1(2) -1.191674820 0.575598988 -2.07032 0.03842227
3. V2(1) 4.285987836 0.743873498 5.76172 0.00000001
4. V2(2) 1.649581410 0.532863384 3.09569 0.00196354
5. MU(1)(1) -0.881213302 0.184496277 -4.77632 0.00000179
6. MU(2)(1) 0.472025129 0.073745579 6.40072 0.00000000
7. PHI(1)(1,1) 0.210996431 0.046587036 4.52908 0.00000592
8. PHI(2)(1,1) 0.072441700 0.047977295 1.50992 0.13106478
9. PHI(3)(1,1) 0.103730162 0.048833808 2.12415 0.03365789
10. PHI(4)(1,1) 0.102676182 0.049932939 2.05628 0.03975539
11. SIGMA(1,1) 0.472889311 0.034647662 13.64852 0.00000000
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 21 Iterations. Final criterion was 0.0000062 <= 0.0000100
Monthly Data From 1948:06 To 1992:08
Usable Observations 531
Function Value -595.8451
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. V1(1) 1.330191138 0.498557616 2.66808 0.00762863
2. V1(2) -1.191674820 0.575600618 -2.07032 0.03842282
3. V2(1) 4.285987824 0.743866100 5.76177 0.00000001
4. V2(2) 1.649581403 0.532856659 3.09573 0.00196328
5. MU(1)(1) -0.881213302 0.184495564 -4.77634 0.00000179
6. MU(2)(1) 0.472025129 0.073745368 6.40074 0.00000000
7. PHI(1)(1,1) 0.210996431 0.046587035 4.52908 0.00000592
8. PHI(2)(1,1) 0.072441700 0.047977564 1.50991 0.13106694
9. PHI(3)(1,1) 0.103730162 0.048833803 2.12415 0.03365788
10. PHI(4)(1,1) 0.102676182 0.049932854 2.05629 0.03975505
11. SIGMA(1,1) 0.472889311 0.034647353 13.64864 0.00000000
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 21 Iterations. Final criterion was 0.0000062 <= 0.0000100
Monthly Data From 1948:06 To 1992:08
Usable Observations 531
Function Value -595.8451
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. V1(1) 1.330191125 0.498560770 2.66806 0.00762901
2. V1(2) -1.191674824 0.575612285 -2.07027 0.03842675
3. V2(1) 4.285987810 0.743827047 5.76208 0.00000001
4. V2(2) 1.649581394 0.532831667 3.09588 0.00196232
5. MU(1)(1) -0.881213303 0.184494672 -4.77636 0.00000178
6. MU(2)(1) 0.472025128 0.073746027 6.40069 0.00000000
7. PHI(1)(1,1) 0.210996431 0.046587067 4.52908 0.00000592
8. PHI(2)(1,1) 0.072441700 0.047978115 1.50989 0.13107137
9. PHI(3)(1,1) 0.103730162 0.048833952 2.12414 0.03365842
10. PHI(4)(1,1) 0.102676182 0.049933545 2.05626 0.03975779
11. SIGMA(1,1) 0.472889311 0.034647396 13.64862 0.00000000
Thank you in advance and best regards
Jules