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

Postby sfarz » Sat Mar 17, 2012 2:43 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Sat Mar 17, 2012 9:25 am

What have you got so far?
Follow us on Twitter @IHSEViews

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

Re: Iteration in Estimating System and Solving Model

Postby sfarz » Sun Mar 18, 2012 3:31 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Sun Mar 18, 2012 11:29 am

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.
Follow us on Twitter @IHSEViews

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

Re: Iteration in Estimating System and Solving Model

Postby sfarz » Tue Mar 20, 2012 4:06 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Tue Mar 20, 2012 7:47 am

That looks pretty good - you use the smpl command to change the sample, once for estimation, once for forecast.
Follow us on Twitter @IHSEViews

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

Re: Iteration in Estimating System and Solving Model

Postby sfarz » Wed Mar 21, 2012 3:24 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Wed Mar 21, 2012 7:38 am

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.
Follow us on Twitter @IHSEViews

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

Re: Iteration in Estimating System and Solving Model

Postby sfarz » Wed Mar 21, 2012 10:03 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Wed Mar 21, 2012 10:15 am

Sorry, don't follow what you're asking.
Follow us on Twitter @IHSEViews

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

Re: Iteration in Estimating System and Solving Model

Postby sfarz » Wed Mar 21, 2012 10:45 am

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: 13318
Joined: Tue Sep 16, 2008 5:38 pm

Re: Iteration in Estimating System and Solving Model

Postby EViews Gareth » Wed Mar 21, 2012 10:49 am

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.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 18 guests