The EViews team should implement a built-in scenario gap decomposition within the Model object. The feature would attribute differences between a counterfactual and a baseline scenario for selected endogenous targets to specific drivers, covering both exogenous variables and add-factors over a user-defined sample. It should integrate seamlessly with existing solution controls and add-factor conventions, leveraging the Model object’s ability to solve non-linear systems. For instance, within a macroeconomic model, the routine could rapidly quantify how much of a change in the interest rate is driven by international price impulses, international demand, or shifts in public consumption.
To illustrate, consider a model Y = f(Y, X, e), where Y is endogenous, X denotes selected exogenous drivers, and e is an add-factor. Let Y_C and Y_B denote the counterfactual and baseline paths, respectively, over a chosen sample, and define DeltaY = Y_C - Y_B. For each driver j in X or e, construct a partial-counterfactual solution Y^(j) by holding all variables at their baseline paths except driver j, which follows its counterfactual path. The contribution is then C_j = Y^(j)-Y_B, computed period by period.
For the joint effect, construct Y_all by setting all selected drivers to their counterfactual paths while keeping all others at baseline, and define C_all = Y_all-Y_B, and C_other = DeltaY - C_all. This yields an additive decomposition in either levels or percentage changes.
If the counterfactual is set to the lagged baseline, Y_C = Y_(t-1), the same machinery delivers a historical decomposition: the change in Y at time t relative to its lag is attributed to deviations in X and e, with non-linear interactions preserved by solving the Model under the Y^(j) and Y_all constructions.
Conceptually, this parallels a historical shock decomposition, but is executed entirely within the Model object by re-solving counterfactuals where selected components of X and e act as the “shocks” driving the scenario gap. The feature should display baseline and counterfactual paths side by side, report their gap in levels and percentage changes, and offer grouping and sorting of drivers so users can highlight the largest contributors or user-defined categories while maintaining a transparent link to the model’s solution settings.
Building this functionality directly into the Model object would make it far faster and easier to use than relying on a user-written add-in. An in-built routine would also ensure consistency with EViews’ solver and reporting framework, avoiding the inefficiencies and maintenance costs of external workarounds.
Model object: Scenario gap decomposition
Moderators: EViews Gareth, EViews Moderator
-
tvonbrasch
- Posts: 569
- Joined: Fri Apr 15, 2011 5:35 am
Re: Model object: Scenario gap decomposition
The following example demonstrates this decomposition method. The attached program initializes a quarterly workfile and simulates a Data Generating Process (DGP) in which regressors x and z follow stochastic trends and drive y via a linear relationship with Gaussian noise. The script generates these series over three iterations, producing distinct sets for actual data and two scenarios, before isolating the 'actual' set for estimation. Subsequently, the code fits an OLS regression to recover the underlying parameters, incorporates the resulting equation into a model object, and creates an empty spool object for output.
Finally, it invokes the decomposition routine (decompose_single_spec.prg), which attributes the change in y to the specific contributions of x, z, and the residual term. This routine derives the decomposition by running multiple simulations on an auxiliary model object, yielding the table below.
Although decompose_single_spec.prg allows for general application by accepting a model object and scenarios, a built-in implementation would be more efficient. It should also be noted that the current routine is limited to single-equation decomposition. A truly general routine would extend this logic to the full model, decomposing endogenous variables into the contributions of exogenous drivers.
----------------
Finally, it invokes the decomposition routine (decompose_single_spec.prg), which attributes the change in y to the specific contributions of x, z, and the residual term. This routine derives the decomposition by running multiple simulations on an auxiliary model object, yielding the table below.
Although decompose_single_spec.prg allows for general application by accepting a model object and scenarios, a built-in implementation would be more efficient. It should also be noted that the current routine is limited to single-equation decomposition. A truly general routine would extend this logic to the full model, decomposing endogenous variables into the contributions of exogenous drivers.
----------------
Code: Select all
close @all
rndseed 1234
wfcreate q 2000 2020
'construct variables (and scenarios)
for %s _s1 _s2 _act
genr x{%s}=5+0.5*nrnd+0.08*@trend
genr z{%s}=10+0.3*nrnd+0.06*@trend
genr y{%s}=7+0.6*x{%s}-0.4*z{%s}+0.6*nrnd
next
rename *_act * 'generate actuals, remove suffix
'estimate equation
equation my.ls y c z x
'make model-object
model m
m.merge my
'make spool object
spool s
'decompose changes between the two scenarios (and append result to spool object)
smpl 2015 2020
exec .\decompose_single_spec(model=m, spool=s, variable=y) _s1 _s2
show s
- Attachments
-
- subroutines.prg
- (1.94 KiB) Downloaded 45 times
-
- decompose_single_spec.prg
- (20.45 KiB) Downloaded 52 times
Last edited by tvonbrasch on Sat Dec 27, 2025 2:07 am, edited 1 time in total.
-
tvonbrasch
- Posts: 569
- Joined: Fri Apr 15, 2011 5:35 am
Re: Model object: Scenario gap decomposition
Note that by defining the comparison scenario as t-1, the decomposition can be used to analyse the contributions to the change in the variable over time, e.g.:
which yields the table:
Code: Select all
smpl @first+4 @last
for %v y z x
genr {%v}_lag={%v}_act(-4)
next
smpl 2015 2020
exec .\decompose_single_spec(model=m, spool=s, variable=y) _lag _act
show sReturn to “Suggestions and Requests”
Who is online
Users browsing this forum: No registered users and 2 guests
