I think I have read all posts regarding stochastic volatility, but I am still unsure, so here I am.
I want ot estimate an SV model with MA(1) errors to forecast inflation.
Starting from the model:
Rt=sigma_t*ut with Rt=dlog(CPI)- mu and mu=@mean(dlog(CPI))
log(Rt*Rt)=log(sigma-t^2)+log(ut^2)
y=ht + vt
I want vt to follow vt=et+theta*et(-1).
As a start, I have modified tha svol.prg on the sspace example files. See code below. (This is just to see if it works, it does not use my data).
My questions are:
1- Is this way to set up the MA errors in the sspace correct? Do you see any conceptual errors?
2- Now, in the original SV model by Taylor, ut---N(0,1). In the code, I didn't make any assumption or impose any constraint related to that, but estimated the variance freely. The program runs OK, although the estimates might not be very good. Do you think I should try to incorpórate in the specification the fact that ut---N(0,1) and that vt=log(ut^2) (whose distribution I ignore)?
3- I would like to model mu as time varying, for example as an unobserved component model. Or to include an AR(p) for y in the signal equation. Is this possible in the context of sspace estimation of SV models? I think it isn't, but please let me know if I am mistaken.
I appreciate greatly any comment on this.
Thanks!
Code: Select all
'basic stochastic volatility model (12/14/2000)
'QML estimation by state space
'revised 3/7/2007
wfcreate u 1 1000
'get data
%datafile = @runpath + "svpdx.dat"
read(skiprow=1) %datafile rt
'estimate GARCH(1,1) model
equation eq1.arch(1,1,m=500,c=1e-5,showopts) rt c
show eq1.output
'and get conditional variance series
smpl 945 1000
eq1.forecast rhat rhat_se gt
smpl 1 944
'transformation for QML estimation
series y = log(rt*rt)
'variance of log chi-square distribution
!pi = @acos(-1)
scalar s2 = 0.5*!pi*!pi
'STOCHASTIC VOLATILITY WITH MA(1) ERRORS?
'specify quasi-likelihood state-space
sspace sv
sv.append @signal y =sv1 +c(1)*sv2 +ht
sv.append @state sv1=[var=c(4)]
sv.append @state sv2=sv1(-1)
sv.append @state ht = c(2) + c(3)*ht(-1) + [var=exp(c(5))]
'set starting values
c(1) = 0.1
c(2) = 0.1
c(3) = 0.9
c(4)=0.01
c(5)=0.01
'estimate
show sv.ml(showopts,m=500,c=1e-7)
'and retrieve state series
sv.makestate(t=pred) *f
sv.makestate(t=predse) *f_se
sv.makestate(t=filt) *t
sv.makestate(t=filtse) *t_se
sv.makestate(t=smooth) *s
sv.makestate(t=smoothse) *s_se
'plot to compare log variance from GARCH and stochastic volatility
graph graph1.line log(gt) htf hts
graph1.options size(8,2)
graph1.addtext(0.1,-0.3) Log volatility
graph1.setelem(1) legend(GARCH(1,1))
graph1.setelem(2) legend(One-step ahead)
graph1.setelem(3) legend(Smoothed)
graph1.legend columns(1) position(0,0)
show graph1
