Editing adjust series via program

For questions regarding programming in the EViews programming language.

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

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Editing adjust series via program

Postby BT454 » Thu Jan 21, 2021 11:43 am

Hi all,
Is it possible to write to the forecast adjustment series programmatically?
I.e. define a series that i want to adjust a forecasted series by, and then write the adjustment series to equal that predefined series.
i.e. where forecasted series is y_1, adjustment series is y_a_1, and series containing values to adjust by is x.
series x = 1, 2, 3, 4, 5
series y_a_1 = series x
solve model
in theory would this work to automate the adjusting of a forecasted series ?
Thanks!
Bob

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

Re: Editing adjust series via program

Postby EViews Gareth » Thu Jan 21, 2021 11:44 am

This is hard to follow. Could you provide more details, hopefully mentioning specific EViews objects/procedures?
Follow us on Twitter @IHSEViews

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: Editing adjust series via program

Postby BT454 » Thu Jan 21, 2021 12:36 pm

Sorry about that.
I have a model in eviews titled LTSTMOD, that uses econometric equations to forecast several series data. The model is solved using this code:

Code: Select all

LTSTMOD.solveopt(s=d,d=d,m=5000,c=1e-8,a=f,o=g,i=a,n=t,e=t,g=n,z=1e-7,f=t,v=f,j=a)
solve LTSTMOD

The model contains equations and identities to forecast a variety of variables, whose series are denoted with an _0 (baseline) and _1 (adjusted/scenario)
These scenario/adjustment series are created using this code:

Code: Select all

  LTSTMOD.scenario(n) "Adjust"
  LTSTMOD.scenario(a=_1) "Adjust"
  smpl %fstart %endrange
  solve LTSTMOD
  %n = LTSTMOD.@stochastic
  LTSTMOD.addassign(v) {%n}
  LTSTMOD.addinit(s=a,v=z) {%n}
  %o = LTSTMOD.@stochastic
  %p = @wcross(%o,"_a")
  %q = @wcross(%p,"_1")

  for %j {%q}
    !i = @isobject(%j)
    if(!i = 1) then
      delete {%j}
    endif
  next
 
  LTSTMOD.override {%p}
  LTSTMOD.addinit(v=z,s=o) {%o}
 


The baseline series (*_0) are adjusted using the model object's "edit override" function. These adjustments appear to be stored in a variable with the suffix _A_1, and the resulting adjusted variable is denoted as _1.
Instead of entering the adjustments by hand, i would like to write a job that calculates the adjustments, and imposes them in the _A_1 variables, and then applies them to the _0 variables when solving the model, resulting in the _1 variable
When entering the data by hand into the adjust series, using 'edit override' the data is transformed upon reincluding the variable into the model, and I cannot seem to reproduce it programmatically.
I hope this makes more sense. I'm sorry if it's still confusing.
Thanks again,
Bob

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Editing adjust series via program

Postby EViews Matt » Mon Jan 25, 2021 12:28 pm

Hello,

You can create add factor series programmatically like any other series. Just make sure you're not overwriting such series before you use them as part of your model solution. Continuing your example of variable y in a scenario with alias _1, once you set a variable to use an add factor (y_a) and then override that add factor (y_a_1) as your later code does, you can copy whatever data you wish to y_a_1, e.g., y_a_1 = x. Just don't reinitialize y_a_1 via the model's addinit proc, as that will overwrite the contents of y_a_1.

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: Editing adjust series via program

Postby BT454 » Sat Jan 30, 2021 11:50 am

Thank you very much!
Something a little is odd is happening. If I adjust a series by hand using the edit/override function, upon reincluding the series, before resolving the model the values of the adjustment change from the values I input into the edit/override field. However, when I resolve, the series by and large looks correct. If I use a program to adjust the _A_1 series, when I resolve, the model will not solve. It appears the values I input into the edit/override are transformed when reincluded, allowing the model to solve. Is that change formulaic, algorithmic, etc? If I can track down the function responsible for that transformation, I can include it in the prg and correctly adjust and solve the models.
Thanks!
Bob

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Editing adjust series via program

Postby EViews Matt » Tue Feb 02, 2021 11:47 am

The model's reinclude procedure will automatically create/update an add factor for the reincluded variable such that the solved values of the model will not change after the reinclude. Naturally, this will overwrite any preexisting add factor (or its override) for that variable. Alternatively, you can reinclude a variable by using the exclude procedure with the (r) option, which will not alter any associated add factor.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 27 guests