## Estimating state space model for GARCH(1,1)

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

mido21
Posts: 5
Joined: Sun Aug 26, 2012 3:41 am

### Estimating state space model for GARCH(1,1)

ot final.wf1

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

mido21
Posts: 5
Joined: Sun Aug 26, 2012 3:41 am

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

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??

mido21
Posts: 5
Joined: Sun Aug 26, 2012 3:41 am

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

plz answer me urgently I need to know Am I right in this specification or not???

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

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

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 modelsspace svmodsvmod.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 modelsvmod.ml(showopts,m=500,c=1e-06)'Retrieve the smoothed estimation of state variable htsvmod.makestate(t=smooth) hts'Compute the smoothed estimated stochastic volatilityseries sv = @exp(hts/2)`

mido21
Posts: 5
Joined: Sun Aug 26, 2012 3:41 am

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

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.
Attachments
Time Varying State Space Model (using GARCH).docx

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

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

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.

saizal87
Posts: 4
Joined: Tue Mar 24, 2015 10:47 pm

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

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.

student07
Posts: 18
Joined: Tue Jun 03, 2014 5:58 am

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

@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?

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

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

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)

student07
Posts: 18
Joined: Tue Jun 03, 2014 5:58 am

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

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?

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

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

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*etRt^2 = Ht*et^2log(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)

student07
Posts: 18
Joined: Tue Jun 03, 2014 5:58 am

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

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*etRt^2 = Ht*et^2log(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)

Amir_hghi
Posts: 1
Joined: Mon Oct 03, 2016 5:16 am

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

excuse me
and in this problem
1.jpg (24.31 KiB) Viewed 3572 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

femimathew_1
Posts: 2
Joined: Mon Oct 14, 2019 1:55 am

### Re: Estimating state space model for GARCH(1,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 modelsspace svmodsvmod.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 modelsvmod.ml(showopts,m=500,c=1e-06)'Retrieve the smoothed estimation of state variable htsvmod.makestate(t=smooth) hts'Compute the smoothed estimated stochastic volatilityseries sv = @exp(hts/2)`