```\$TITLE Modeling Unanticipated Shocks: An Illustrative GAMS/MCP Model

\$ontext

Query:

I am writting because I have been working with the dynamic general
equilibrium in complementarity format and I have a question on how to
introduce a preexisting tax distortion to the model.  When I introduce
a tax rate to the benchmark model of the "shock" program that you have
on your webpage the model does not calibrate.

When you introduce a capital tax in the benchmark, the unit cost
function changes from:

PR_Y(t).. (RK(t)*(1+taxk(t))/rk0)**kvs * PL(t)**(1-kvs) =E= P(t);

to

PR_Y(t).. (RK(t)*(1+taxk(t))/(rk0*(1+taxk0)))**kvs * PL(t)**(1-kvs) =E= P(t);

where taxk0 represents the benchmark tax rate on capital.  (This uses
the calibrated share form of the CES which is documented here.)

The application of a tax on capital also affects the calibrated value
of the labor supply, as you need to deduct the tax revenue from the
unit profit, hence:

lref = 1 - kref * rk0 * (1+taxk0);

Finally, the pre-existing tax modifies the demand functions for labor
and labor (search for taxk0 to see these changes).

I've modified the code analogous to the previous version with
experiments in which we remove the tax on capital rather than apply a
tax.

Query:

Since it seems not possible to use dynamic ordered set in GAMS (at least with CNS or
MCP solvers), how do you model unanticipated shocks?

I'm working on an intertemporal CGE with a 40 years period, I'm calibrating it on 1994
data, and I want to fix the four first periods in one of the simulations to simulate an
unanticipated schock by households and firms.

Is it possible for example to modify the solve command to tell the model to start at a
certain period?

The changes must take place after the first solve, since I need to find the reference path
of the economy I'm working on.

The short answer to this question is: "Yes, this can be done; but you need to do some
programming."

Think of your economic equilibrium model as a function of the initial conditions, x0,
equilibrium prices and quantities, p and q, and a vector of policy instruments, tau.

The vector of initial conditions, x0, corresponds to the state variables in the model if
you were to think of the problem in an optimal control framework.

Your model is dynamic, so prices, quantities and policy instruments are indexed by time.
Abstractly, the model is then a solution to the system of equations:

F(p,q; tau, x0) = 0

where F is a vector function with as many equations as there are endogenous variables
(elements in p and q).  (There are some complications which I don't included here,
including the fact that you are actually modeling the transition path to an infinite
horizon, so you have introduced some additional variables -- state variables at the end of
the horizon -- which are used to approximate the post-terminal equilibrium growth path.)

Now, we have a baseline equilibrium in which x0 is given and tau(t)=tau0(t), i.e. all the
state variables match the base year values and policy instruments (tax rates) are given.
Let this reference equilibrium be denoted (p0(t), q0(t)).

You next want to compute an equilibrium growth path with a different set of policy
instruments, tau'(t), where tau'(t)=tau0(t) for t < t*, and it differs thereafter.

If you simply set tau(t)=tau'(t) in the model you will compute a different equilibrium
growth path, (p'(t), q'(t)), but this growth path will include the anticipated response to
future change in tau(t) for all periods t prior to t*.

If you want to compute the unanticipated response to the new policy instruments, you need
to think of solving a model with initial conditions corresponding to period t* in the
reference equilibrium.

Let x(t) represent the state variable values in the equilibrium growth path corresponding
to the initial conditions.  In a single sector model, x(t) would correspond to the value
of the capital stock in period t.  In a multisector model, x(t) would be a vector of
capital stocks, one for each sector in the model.

To solve the unanticipated shock, you do the following:

1. Solve the reference equilibrium:  F(p0,q0; tau0, x0) = 0

2. Generate initial conditions for a new model in which the initial conditions correspond
to the state variables in the reference equilibrium growth path: x0 = x(t*).

3. Solve the new equilibrium model: F(p,q; tau', x0)

4. Translate the solution from the new model to represent the unanticipated growth path.

The following model illustrates how to program this in GAMS.  In this single-sector Ramsey
model I first compute the baseline growth path, then I compute the equilibrium growth path
with an anticipated change in the tax on capital, and then I compute the equilibrium
growth path with an unanticipated change in the capital tax rate.

Details of the model formulation can be found in

Morten I. Lau, Andreas Pahlke and Thomas F. Rutherford.  "Approximating infinite-horizon
models in a complementarity format: a primer in dynamic general equilibrium analysis",
Journal of Economic Dynamics and Control, 26, 577-609, 2002.

\$offtext

SET     t		Time periods in the model /0*50/,
tp(t)		Periods in which tax shock applies /4*50/,
tfirst(t)	First period in the model,
tlast(t)	Last explicit period in the model

ALIAS (t,tt);

*	Assign the first and last period using ORD() and CARD() so
*	that changing T to be /2003*2050/ would not break the model:

tfirst(t) = YES\$(ORD(t) EQ 1);
tlast(t)  = YES\$(ORD(t) EQ CARD(t));

*	Define the baseline growth path which implicitly defines the
*	utility discount parameters:

PARAMETER       g       Growth rate             /0.02/
r       Interest rate           /0.05/

*	Capital stock in the base year is defined by the
*	capital-output ratio, letting base year output be unity:

kref    Capital-output ratio    /3.00/

k0	Capital stock in period 0 / 1 /
l0	Labor supply in period 0  / 1 /

delta   Depreciation rate       /0.07/

kvs     Base year capital value share,
lref    Base year labor input,
taxk(t)	Capital tax rate,
taxk0	Baseline tax rate
qref(t) Reference quantity path,
pref(t) Reference price path,
alpha(t) Utility discount parameters (budget shares);

*	Apply a taxe in the steady-state replication or baseline
*	growth path:

taxk0 = 0.1;
taxk(t) = taxk0;

*	The steady-state cost of capital equals interest plus
*	depreciation:

rk0 = r + delta;

*	Calibrate the base year steady-state labor supply by
*	subtracting the cost of capital from aggregate output:

lref = 1 - kref * rk0 * (1+taxk0);

*	Baseline steady-state growth is defined by the growth
*	rate g:

qref(t) = (1+g)**(ORD(t)-1);

*	Baseline steady-state present value prices decline
*	with the interest rate:

pref(t) = (1/(1+r))**(ORD(t)-1);

*	The capital value share is equal to gross capital
*	earnings divided by the steady-state output (unity):

kvs = kref * rk0 * (1+taxk0);

*	Intertemporal preferences are calibrated to be consistent
*	with a steady-state growth of consumption ate rate g
*	when the steady-state interest rate is r:

alpha(t) = ((1+g)/(1+r))**(ord(t)-1);

*	We can scale these to sum to unity:

alpha(t) = alpha(t) / SUM(tt, alpha(tt));

POSITIVE VARIABLES
Y(t)	Output
I(t)	Investment
K(t)	Capital stock
P(t)	Output price
U	Utility
PU	Unit expenditure function
PK(t)	Capital price
PL(t)	Wage rate
PKT	Terminal capital
RA	Representative agent
TK	Post-terminal capital stock;

EQUATIONS
PR_Y(t)	Zero profit condition for output,
PR_C(t)	Zero profit condition for consumption,
PR_K(t)	Zero profit condition for capital,
PR_I(t)	Zero profit condition for investment,
PR_U	Zero profit condition for utility,

M_P(t)	Market clearing for output,
M_PK(t)	Market clearing for capital,
M_RK(t)	Market clearing for rental capital,
M_PL(t)	Market clearing for labor,
M_PU	Market clearing for utility,
M_PKT	Market clearing for terminal investment,

I_RA	Income balance for representative agent,

TERMK	Terminal constraint for capital stock;

*	Zero profit condition for output based on a reference price
*	of RK equal to rk0, and a reference price for PL equal to
*	unity.  This is a Cobb-Doublas cost function:

PR_Y(t).. (RK(t)*(1+taxk(t))/(rk0*(1+taxk0)))**kvs * PL(t)**(1-kvs) =E= P(t);

*	Zero profit condition for utility, based on a reference
*	price for P(t) equal to pref(t), and a budget share for
*	period t equal to alpha:

PR_U..    PROD(t, (P(t)/pref(t))**alpha(t) ) =E= PU;

*	Zero profit for capital relates the cost of purchasing
*	a unit of capital at the start of period t (PK(t)) to
*	the rental earnings in period t (RK(t)) and the salvage
*	value of the capital stock which is carried over to
*	period t+1.  In the last period of the model, the
*	post-terminal salvage value, PKT, applies to the
*	depreciated capital stock:

PR_K(t).. PK(t) =E= RK(t) + (1-delta)*(PK(t+1) + PKT\$tlast(t));

*	Zero profit for investment relates the cost of purchasing
*	a unit of current output to the value of a unit of new
*	capital in the subsequent period.  In the last period of
*	the model investment generates one unit of post-terminal
*	capital with price PKT:

PR_I(t).. P(t) =E= PK(t+1) + PKT\$tlast(t);

*	Market clearing conditions for output relate aggregate supply
*	in period t (Y(t)) to consumption in period (computed using
*	the Cobb-Douglas value share, the value of aggrgate
*	expenditure and the price of period t output), plus
*	investment (I(t)):

M_P(t)..  Y(t) =E= alpha(t) * PU * U / P(t) + I(t);

*	Aggregate expenditure equals the present value of income:

M_PU..    U*PU =E= RA;

*	Capital stock at the start of period t equals depreciated
*	capital from the previous period (K(t-1)) plus investment
*	from the previous period (I(t-1)); except in the first
*	period of the model when the capital stock equals the initial
*	capital stock.  (In GAMS, a reference to t-1 evaluates to zero
*	when t refers to the first element of set t.)

M_PK(t).. K(t) =E= (1-delta)*K(t-1) + I(t-1) + k0\$tfirst(t);

*	The supply of capital in period t equals the demand for
*	capital in period t.  The user cost of capital is based on
*	a reference price of rk0 and an ad-valorem tax rate of
*	taxk(t).

M_RK(t).. K(t) =E= Y(t) * kref*(RK(t)*(1+taxk(t))/((1+taxk0)*rk0))**kvs * PL(t)**(1-kvs)
/ (RK(t)*(1+taxk(t))/((1+taxk0)*rk0));

*	The supply of labor in period t equals the demand for labor
*	in period t:

M_PL(t).. L0*qref(t) =E= Y(t) * lref*(RK(t)*(1+taxk(t))/((1+taxk0)*rk0))**kvs *
PL(t)**(-kvs);

*	The supply of post-terminal capital stock, based on the
*	depreciated terminal capital plus investment in the terminal
*	period equals the "demand" for post-terminal capital (TK):

M_PKT..	  SUM(tlast, K(tlast)*(1-delta) + I(tlast) - TK) =E= 0;

*	Income equals labor earnings plus net capital earnings plus
*	tax revenue.  Net capital earnings equal the sales value of
*	the base year capital stock less the cost of purchasing the
*	target level of post-terminal capital:

I_RA..    RA  =E= SUM(t, PL(t)*L0*qref(t)) +
SUM(tfirst, PK(tfirst)*k0)
+ SUM(t, K(t) * RK(t)*taxk(t)/((1+taxk0)*rk0))
- TK*PKT;

*	The level of post-terminal capital is targetted so that
*	investment grows smoothly in the final period:

TERMK..	  SUM(t\$tlast(t+1),  I(t+1)/I(t) - Y(t+1)/Y(t)) =E= 0;

*	Define the complementarity problem by relating equations
*	and variables:

MODEL MCP     /PR_Y.Y, PR_U.U, PR_K.K, PR_I.I,
M_P.P, M_PU.PU, M_PK.PK, M_RK.RK, M_PL.PL, M_PKT.PKT,
I_RA.RA, TERMK.TK/;

Y.L(t)  = qref(t);
I.L(t)  = (delta + g) * kref * qref(t);
K.L(t)  = kref * qref(t);

P.L(t)  = pref(t);
RK.L(t) = pref(t) * rk0;
PK.L(t) = (1+r) * pref(t);
PL.L(t) = pref(t);
PKT.L   = SUM(tlast, pref(tlast));
TK.L    = kref * (1+g)**CARD(t);

Y.LO(t) = 1.E-5;
I.LO(t) = 1.E-5;

PU.L = PROD(t, (P.L(t)/pref(t))**alpha(t) );

U.L  = ( SUM(t, PL.L(t)*lref*qref(t)) + SUM(tfirst,  PK.L(tfirst)*kref)
+ sum(t, RK.L(t)*taxk0*kref*Y.L(t))
-  TK.L * PKT.L) / PU.L;

*	Fix aggregate income to normalize prices.  Because equation I_RA is
*	associated with RA in the model statement, we are dropping
*	I_RA from the system of equations when we fix this value:

RA.FX = U.L * PU.L;

*	the steady-state values and then verify that the model
*	calibrates:

l0 = lref;
k0 = kref;
MCP.ITERLIM = 0;
SOLVE MCP USING MCP;
ABORT\$(mcp.objval GT 0.001) "Steady state does not calibrate";

*	Having checked consistency of the steady-state growth
*	path, we compute a baseline growth path assuming that the
*	initial capital stock is 20% below the equilibrium

k0 = 0.80 * kref;
MCP.ITERLIM = 20000;
SOLVE MCP USING MCP;

PARAMETER	consum		Consumption level
invest		Investment level
capital		Capital stock
output		Output level;

output(t,"base") = Y.L(t);
consum(t,"base") = alpha(t) * PU.L * U.L / P.L(t) ;
invest(t,"base") = I.L(t)/qref(t);
capital(t,"base") = K.L(t)/qref(t);

PARAMETER  K4	Value of state variable K in period 4 of the baseline;
K4 = K.L("4");

*	Now we remove the tax on capital beginning in period 4:

taxk(tp) = 0;
SOLVE MCP USING MCP;

*	Store values for the equilibrium growth path
*	subject to the the anticipated tax on capital
*	applied beginning in period 4:

output(t,"antic") = Y.L(t);
consum(t,"antic") = alpha(t) * PU.L * U.L / P.L(t) ;
invest(t,"antic") = I.L(t)/qref(t);
capital(t,"antic") = K.L(t)/qref(t);

*	Update the initial conditions of the model to coincide with
*	with period 4 of the baseline growth path:

k0 = k4;
L0 = lref*qref("4");

*	In this model the tax applies in the first period of the
*	model:

taxk(t) = 0;
SOLVE MCP USING MCP;

*	Use the baseline equilibrium path for periods 0 to 4:

output(t,"unantic") = output(t,"base");
consum(t,"unantic") = consum(t,"base");
invest(t,"unantic") = invest(t,"base");
capital(t,"unantic") = capital(t,"base");

*	Use values from the current calculation to establish
*	values for periods 5 onward:

output(t+4,"unantic") = Y.L(t);
consum(t+4,"unantic") = alpha(t) * PU.L * U.L / P.L(t) ;
invest(t+4,"unantic") = I.L(t)/qref(t+4);
capital(t+4,"unantic") = K.L(t)/qref(t+4);

*	Generate a graphical comparison of results.

*	Plot the first 20 years with tics on 0, 5, 10, 15 and 20:

set	tplot(t) /0*20/,  tl(t) /0,5,10,15,20/;
\$setglobal domain tplot
\$setglobal labels tl

*	Set up a batch mode operation with output written in
*	gif format, the key outside the box and slightly smaller
*	than full size:
\$setglobal gp_opt4 "set key outside width 3"

*	Generate the pictures:

\$setglobal batch yes
\$setglobal gp_opt3 "set size 0.9,0.9"
\$setglobal gp_opt2 "set term gif"

*	Generate the pictures:

\$setglobal gp_opt1 "set output 'output.gif'"
\$libinclude plot output

\$setglobal gp_opt1 "set output 'consum.gif'"
\$libinclude plot consum

\$setglobal gp_opt1 "set output 'invest.gif'"
\$libinclude plot invest

\$setglobal gp_opt1 "set output 'capital.gif'"
\$libinclude plot capital

display invest, capital, consum, output;
```