## Iteration in Estimating System and Solving Model

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Iteration in Estimating System and Solving Model

Hi all,

I am working on EViews7 for the first time.

I would like to know how can I write a code that:
1) Estimate a system of 3 equations with the first 200 observation out of 500 (in which i specify the type of estimation method and the options)
2) Solve a model linked to the system (in which i specify the options: like forecasting sample and stochastic options)
3) Store the solutions belonging to the forecast t+1, t+12, t+60
4) Repeate the step 1-2-3 but increasing the sample of estimation and shifting the forecasting sample.

I need to do Out-Of-Sample stochastic forecast of multivariate GARCH models.

Thank you,
Sfarz

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

What have you got so far?

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Re: Iteration in Estimating System and Solving Model

Hi Gareth,

"What have you got so far?"
Almost nothing, I would like to know:
how specify the type of estimation method for the system, i need to use diagonal BEKK, but i saw only ls method.
how specify the solving options of the model, i need to use stochastic dynamic solution for the next 60 steps with a large number of solutions like 50000.

For the iteration i think that i simply use a for i next and use i in the sample for estimation, forecasting period and in the saving the solutions of the iteration.

Can you help me?

Regards,
Sfarz

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

If you take a look at the System entry in Chapter 1 of the Object Reference, you'll see all the estimation methods available for systems, including ARCH.

If you look at the model entry in Chapter 1 of the Object Reference, you'll see the Solveopt proc that contains all the options available for model solves.

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Re: Iteration in Estimating System and Solving Model

Hi,

I read the object ref, thank you.

I wrote a first draft of the code, and it run but i have a doubt:
When i use a model inside a program can i spcify a specific forecast sample? because out of program i can, but in the guide is written:
"Note: when solve is used in a program (batch mode) models are always solved over the workfile sample. If the model contains a solution sample, it will be ignored in favor of the workfile sample."

Do you have some suggestion for the code?

Code: Select all

`for !i=1 to 193'Estimation the system diagonal bekk  'For a Diagonal BEKK model: see564 obj reference for other specification'system_name.arch(options) @diagbekk c(arg) [arch(n[, arg])] [tarch(n[, arg])][garch(n[, arg])] [exog(series, arg)]'options: tdist if you want to use t-distribution for the residuals   smpl 1972m01 1994m11+!i   system sys01   sys01.append reit=c(1)*reit(-1)+c(2)*equity(-1)+c(3)*bond(-1)+c(4)   sys01.append equity=c(5)*reit(-1)+c(6)*equity(-1)+c(7)*bond(-1)+c(8)   sys01.append bond=c(9)*reit(-1)+c(10)*equity(-1)+c(11)*bond(-1)+c(12)   sys01.arch @diagbekk c(indef) arch(1) garch(1) 'once we get the estimate coefficient we make simulation with "model"'first update the coefficient estimate   smpl 1994m12+!i 1995m11+!i   model01.update   model01.stochastic(s=1972m01 1994m11+!i,r=50000,p=solutions)   model01.solve(s=s)   next`

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

That looks pretty good - you use the smpl command to change the sample, once for estimation, once for forecast.

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Re: Iteration in Estimating System and Solving Model

hi Gareth,

With my code eviews stores in 193 page the 50000 solutions to the model for 60 steps.
In order to do my analysis i need only the 50000 solutions for the steps 1, 12 and 60, for the 193 iteration of the loop.
How can i do ?

Thanks,
Sfarz

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

You could put something in the code like:

Code: Select all

`if !i=1 or !i=12 or !i=60 or !i=193 then   model01.stochastic(s=1972m01 1994m11+!i,r=50000,p=solutions)   model01.solve(s=s)else  model01.solve(s=d)endif`

i.e. only do a stochastic solve for the iterations in which i=1,12,60 or 193.

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Re: Iteration in Estimating System and Solving Model

I probably explain my problem badly.

I want that eviews make 193 iteration of the program in order to make the estimate and forecast as it was in each month between 1995 and 2011,
but i want to find a easier way of manage the solutions to the stochastic model.

I need to store for each of the 193 iteration the 50000 solutions for the forecast horizon 1, 12, 60, and not all the solutions.

Is this possible? How can I export this solution to an excel file?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

sfarz
Posts: 10
Joined: Fri Mar 16, 2012 7:16 am

### Re: Iteration in Estimating System and Solving Model

Sorry for my messy post.

I am trying to do trivariate density forecasts and valuation of models.
In order to do density forecasts i use "model" of eviews to generate many stochastic solutions for each horizon (i.e. 50000 repetitions) in order to have data that i can be converted in density, over 193 periods.
My interest is for the horizon +1, +12, +60.

I would like to modify my code in order to create 9 matrix (a matrix for each equation and horizon) of the type 193*50000.
In this way I have a matrix for each equation and horizon that collects all the repetitions for each iteration of the program.

Up to now I can simply put the option to generate a new workfile page to save the results of all repeteition of the stochastic solve,
but in this way eviews generate 193 new workfile with 3 series that have the 50000 repetition for all the 60 steps (3mil numbers for each series for each page)
then manage this 193 workfile is not simple. Is there possible to merge the 193 page in one and then try to deleate all the repetition that i do not need?

thanks for the help

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12574
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Iteration in Estimating System and Solving Model

You could use pageselect to switch to the newly created page. You could use stom to convert the series on that page into a matrix. Then use copy to copy that matrix to the original page (and then possibly matplace to place into a larger matrix. You can then use pagedelete to delete any pages that are no longer necessary.