Page 1 of 2

Estimating state space model for GARCH(1,1)

Posted: Mon Sep 10, 2012 11:30 am
by mido21
ot final.wf1
(173.86 KiB) Downloaded 718 times


Hello everybody,

I'm trying to run estimate state space model for GARCH(1,1)...can you help me in writing the code?

Thank you,
Mido

Re: Estimating state space model for GARCH(1,1)

Posted: Tue Sep 11, 2012 3:58 pm
by mido21
I`m tried this code:

@signal rlogot= c(1)+sv1*rlogot(-1)+ c(2)*sv2
@state sv2 = c(3) + c(4)*sv2(-1) + [var = exp(c(5))]
@state sv1 = sv1(-1)

Am I right??

Thank you in advance..

Re: Estimating state space model for GARCH(1,1)

Posted: Thu Sep 13, 2012 3:42 pm
by mido21
plz answer me urgently I need to know Am I right in this specification or not???

Re: Estimating state space model for GARCH(1,1)

Posted: Fri Sep 14, 2012 12:33 am
by trubador
No, your specification is incorrect. GARCH models are nonlinear, so I am not sure if there is a way to put such a structure into a linear state space form. Unfortunately, EViews currently cannot handle nonlinear or non-Gaussian state space models. However, the counterpart of GARCH is called "stochastic volatility" in state space and there is an approximate solution based on a linear model. One way to build such a model in EViews is as follows:

Code: Select all

'Transform the price level series (yt)
series rt = (dlog(yt)-@mean(dlog(yt)))
series lrt2 = log(rt*rt)

'Build the state space model
sspace svmod
svmod.append @signal lrt2 = ht + [var=exp(c(1))]
svmod.append @state ht = c(2) + c(3)*ht(-1) + [var = exp(c(4))]
svmod.append param c(1) 1.0 c(2) .0 c(3) .9 c(4) -2.0  'you may need to experiment to find feasible starting parameter values!

'Estimate the model
svmod.ml(showopts,m=500,c=1e-06)

'Retrieve the smoothed estimation of state variable ht
svmod.makestate(t=smooth) hts

'Compute the smoothed estimated stochastic volatility
series sv = @exp(hts/2)

Re: Estimating state space model for GARCH(1,1)

Posted: Sat Sep 15, 2012 6:44 am
by mido21
Thanks Trubador.

Your reply is extremely appreciated.

However, I dont want to estimate a GARCH(1,1) using a state space model. I want to estimate the time varying beta using and AR model while relying on GARCH (1,1) in estimating the volatilities.

In other words, is it possible to use the GARCH (1,1) in the State Space model for estimating time varying betas as per the attached document.

Your swift response will be highly appreciated as I am in real need to understand and implement this.

Re: Estimating state space model for GARCH(1,1)

Posted: Sat Sep 15, 2012 12:03 pm
by trubador
The model is nonlinear in state variables, so as I mentioned before, it cannot be estimated via linear state space approach. Nonlinear state space models are quite complicated and therefore are very difficult to estimate. In addition to this technical detail, your model is so flexible that you may experience additional problems during estimation even if you manage to find a way to build it.

Re: Estimating state space model for GARCH(1,1)

Posted: Mon Apr 06, 2015 7:25 pm
by saizal87
hello trubador, thanks for sharing the code for Stochastic volatility using state space. i got few questions, 1) can you recommend the best way to experiment to find feasible starting parameter values for stochastic volatility. 2) (showopts,m=500,c=1e-06) why is that c = 1e-06? thank you very much and your response is highly appreciated.

Re: Estimating state space model for GARCH(1,1)

Posted: Mon May 04, 2015 2:11 am
by student07
@trubador Possibly an elementary question, but why exactly do you take the exponent of hts/2 at the end? Why doesn't hts itself already contain the end result?

Re: Estimating state space model for GARCH(1,1)

Posted: Mon May 04, 2015 6:31 am
by trubador
student07 wrote:@trubador Possibly an elementary question, but why exactly do you take the exponent of hts/2 at the end? Why doesn't hts itself already contain the end result?

In the beginning, we log transform the return series so we can express the conditional variance in linear form. Otherwise, it would become nonlinear in states and we would not be able to solve it via linear Kalman filter. When the estimation is done, we need to transform the estimated conditional variance back to its original state. Since we want the volatility, we also take the square root: @sqrt(@exp(hts)) = @exp(hts/2)

Re: Estimating state space model for GARCH(1,1)

Posted: Tue May 05, 2015 5:40 am
by student07
trubador wrote:In the beginning, we log transform the return series so we can express the conditional variance in linear form. Otherwise, it would become nonlinear in states and we would not be able to solve it via linear Kalman filter. When the estimation is done, we need to transform the estimated conditional variance back to its original state. Since we want the volatility, we also take the square root: @sqrt(@exp(hts)) = @exp(hts/2)


Thanks for your reply. I've read about the linearization so I understand that part. But didn't we take the log of rt^2 i.e. 'y' in the observation/@signal equation? Why would this immediately mean that our outcome for the VARIANCE is also in log? What am I missing?

Re: Estimating state space model for GARCH(1,1)

Posted: Tue May 05, 2015 6:28 am
by trubador
The variance part you refer to is actually the unobserved state variable and has the same scale as log(rt^2), which is mostly filled with negative values. Return series is defined as the stochastic volatility times the random error (noise). When you log transform, the relationship becomes additive:

Code: Select all

Rt = √Ht*et
Rt^2 = Ht*et^2
log(Rt^2) = log(Ht) + 2*log(et)

We model this relationship as follows:

Code: Select all

lrt2 = ht + vt

So the stochastic variance we estimate is actually @exp(ht)

Re: Estimating state space model for GARCH(1,1)

Posted: Thu May 07, 2015 3:59 am
by student07
Aha, great, thanks a lot :) !
trubador wrote:The variance part you refer to is actually the unobserved state variable and has the same scale as log(rt^2), which is mostly filled with negative values. Return series is defined as the stochastic volatility times the random error (noise). When you log transform, the relationship becomes additive:

Code: Select all

Rt = √Ht*et
Rt^2 = Ht*et^2
log(Rt^2) = log(Ht) + 2*log(et)

We model this relationship as follows:

Code: Select all

lrt2 = ht + vt

So the stochastic variance we estimate is actually @exp(ht)

Re: Estimating state space model for GARCH(1,1)

Posted: Mon Oct 03, 2016 5:25 am
by Amir_hghi
excuse me
and in this problem
1.jpg
1.jpg (24.31 KiB) Viewed 20356 times


How can we underestand measure of coefficients beta0, beta1?????

It is worth noting that to corroborate the weak form efficiency hypothesis, the estimated value of
βi,t(1) should be either equal to ‘zero’ or statistically insignificant.

Plz help me

Re: Estimating state space model for GARCH(1,1)

Posted: Thu Oct 24, 2019 3:55 am
by femimathew_1
I am trying to generate inflation uncertainty series from inflation series using a stochastic volatility model. I tried using the code you gave below and it generated the sv series along with the estimated model.
However, I dont know how to interprete the model. I saw C1, C2, C3, C4 each with coefficient, standard error, probability values and so on. I also saw H with its own coefficient, standard error, prob. values etc.
My question is this: What do the C's stand for? Is h the stochastic volatility variance?





trubador wrote:No, your specification is incorrect. GARCH models are nonlinear, so I am not sure if there is a way to put such a structure into a linear state space form. Unfortunately, EViews currently cannot handle nonlinear or non-Gaussian state space models. However, the counterpart of GARCH is called "stochastic volatility" in state space and there is an approximate solution based on a linear model. One way to build such a model in EViews is as follows:

Code: Select all

'Transform the price level series (yt)
series rt = (dlog(yt)-@mean(dlog(yt)))
series lrt2 = log(rt*rt)

'Build the state space model
sspace svmod
svmod.append @signal lrt2 = ht + [var=exp(c(1))]
svmod.append @state ht = c(2) + c(3)*ht(-1) + [var = exp(c(4))]
svmod.append param c(1) 1.0 c(2) .0 c(3) .9 c(4) -2.0  'you may need to experiment to find feasible starting parameter values!

'Estimate the model
svmod.ml(showopts,m=500,c=1e-06)

'Retrieve the smoothed estimation of state variable ht
svmod.makestate(t=smooth) hts

'Compute the smoothed estimated stochastic volatility
series sv = @exp(hts/2)

Re: Estimating state space model for GARCH(1,1)

Posted: Wed Oct 14, 2020 10:06 am
by arianbhm
Hi,

I am new to EVIEWS. Is it possible to model nonlinear state space in EVIEWS or not? Not sure if the option is now available or not since I was checking the previous comments. Are there any software like Stata, SPSS, or.... capable of dealing with nonlinear state space model (Extended Kalman Filter) or not?