Balcilar, Gupta and Miller, EE 2015

Use this forum for posting example programs or short bits of sample code.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

If you want to use ||8.0,2.0|| rather than ||19.0,1.0||, go ahead. They're priors. 8,2 isn't as persistent and is weaker, but both of those will be dominated by 1800+ data points. If you have 100 data points, then those are going to be much more strongly informative.
atarca
Posts: 25
Joined: Thu Dec 08, 2011 8:48 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by atarca »

Dear Tom,
In one of the rows of "oil_stock_msvecm_irf.rpf", "set dloil = %if(dloil==0.0,%ran(.1),dloil)" is used to "Fuzz" up the zero values of dloil. What is the meaning of (.1) used in %ran(.1)?
Thank you very much in advance.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

Standard deviation of the normals. The specifics for functions are included in the help.
atarca
Posts: 25
Joined: Thu Dec 08, 2011 8:48 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by atarca »

Thank you very much for your quick reply, Tom. However, I wonder why it is %ran(.1) instead of being %ran(1.0) in this case.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

Because it's supposed to be small random numbers to prevent the exact fit problem.
alexecon
Posts: 72
Joined: Fri Oct 30, 2015 12:16 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by alexecon »

TomDoan wrote:

The expected "labeling" of regimes is that regime 1 will be the low volatility and regime 2 the high volatility. This pushes the guess values in that direction, and then runs the EM algorithm for 100 iterations, followed by 10 iterations of BHHH to allow calculation of standard errors for the estimates:

Code: Select all

@MSSysRegInitial gstart gend
*
* Try to enforce regime 1 as having lower volatility
*
compute sigmav(1)=.25*sigmav(1)
compute sigmav(2)=4.0*sigmav(2)
*
@MSSysRegEMGeneralSetup
do emits=1,100
   @MSSysRegEMStep gstart gend
   disp "Iteration" emits "Log likelihood" %logl
end do emits
set p1smooth = psmooth(t)(1)
*
* Polish estimates with 10 iterations of BHHH. Set up the parameter sets
* and initialize the regime probability matrices (required for ML, but
* not EM, which uses its own).
*
nonlin(parmset=regparms) betasys sigmav
nonlin(parmset=msparms)  p

compute p=%xsubmat(p,1,nstates-1,1,nstates)
frml logl = f=%MSSysRegFVec(t),fpt=%MSProb(t,f),log(fpt)
*
@MSFilterInit
maximize(start=$
  %(logdet=%MSSysRegInitVariances(),pstar=%MSSysRegInit()),$
  parmset=regparms+msparms,method=bhhh,iters=10) logl gstart gend
Why is the EM 'pre-estimation' necessary in the MS-VECM of Balcilar et al. (2015) and not in the MS-VAR of Ehrmann et al. (2003)? Thank you.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

I don't think "necessary" is the right word. The EEV replication includes both a direct BFGS estimation and another program which does EM followed by BHHH. These are two approaches to doing maximum likelihood with models like this.
abi
Posts: 74
Joined: Sat Apr 13, 2013 3:48 am

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by abi »

Hi Tom,

Since MS-VECM use the @johmle procedure if there are some breaks in the data set, then the result of MS-VECM still would be valid?

Thanks,
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

Yes. The ML estimates of the cointegrating vector are consistent under a very wide range of assumptions.
LvXin
Posts: 6
Joined: Tue Sep 05, 2017 10:19 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by LvXin »

Dear Tom,
I would like to use this code to estimate MSVECM mode with 1 and 3 lags (in VECM). Whether this code could achieve this, and how could I modify the code to estimate 1 and 3 lags model. Thanks very much for your kind help.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

Lags 1 and 3 on the differences? Not sure that that's a good idea, but

# dlsp{1 3} dloil{1 3} constant ect{1}

would do that in this example.
LvXin
Posts: 6
Joined: Tue Sep 05, 2017 10:19 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by LvXin »

Dear Tom,
Thanks very for your quick reply. Mayebe I could not explain clearly last time. I would like to estimate two MS-VECM model

Model 1: MS(2)-VECM(1): Yt=μ(st )+Π(i(st)) ΔY(t-1)+Γ(i(st)) Y(t-1)+εt, st=2 states, Yt represents a vector sf observed time series variable
Model 2: MS(2)-VECM(3): Yt=μ(st )+Π(i(st)) ΔY(t-3)+Γ(i(st)) Y(t-3)+εt, st=2 states, Yt represents a vector sf observed time series variable

So, How could I modify the code?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

# dlsp{1} dloil{1} constant ect{1}

and

# dlsp{3} dloil{3} constant ect{3}
LvXin
Posts: 6
Joined: Tue Sep 05, 2017 10:19 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by LvXin »

Dear Tom,
Thanks very much!
I successful estimate the code: # dlsp{1} dloil{1} constant ect{1}. However, when I estimate below code: # dlsp{2} dloil{2} constant ect{2} and # dlsp{3} dloil{3} constant ect{3}, the RATS report as:
## NL6. NONLIN Parameter SIGMAV(1)(1,1) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter SIGMAV(1)(2,1) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter SIGMAV(1)(2,2) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter SIGMAV(2)(1,1) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter SIGMAV(2)(2,1) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter SIGMAV(2)(2,2) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter P(1,1) Has Not Been Initialized. Trying 0
## NL6. NONLIN Parameter P(1,2) Has Not Been Initialized. Trying 0
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points

What's the problem? Do I need to modify some other code? In addition, which variable is the regime duration in the results. Thank again for your kind help!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Balcilar, Gupta and Miller, EE 2015

Unread post by TomDoan »

I'm really confused about what you're trying to do. Why are you skipping lags in a VECM? If you're simply trying to change the number of lags, you just need to fix the first and last lines in the code below. (4 and 3 will have 3 lags on the differences in the VECM, 3 and 2 would have 2). If you do a full set of differences (and it's not clear why you wouldn't, particularly before estimating the model), then the lag of the EC term doesn't matter.

The program is designed to run all the way through given a choice of model. If you try to change the model up and re-do part of the analysis, it won't work.

@johmle(lags=2,det=constant,cv=cv)
# loil lsp
*
* Normalize to a unit coefficient on oil
*
compute cv=cv/cv(1)
*
* This is the error correction series
*
set ect = cv(1)*loil+cv(2)*lsp
*
equation(coeffs=cv) ecteq *
# loil lsp
*
* LAGS=2 is chosen for the full VAR, so that involves 1 on the differences.
*
compute lag=1
Post Reply