$title	Illustrative MPSGE model based on a social accounting matrix

$ontext

> I am formulating a small open economy model to tourism policy in 
> a small open economy.  One obvious issue could be an exogenous shock 
> to aggregate tourism demand.  How is this done?

I would use a representative tourism household that demands
aggregate tourism final consumption (produced by all domestic
sectors) being endowed with "foreign exhange". In order 
to be concrete I illustrate here with a modified version of
the SOE model from ../lib/soe.htm.

A representative tourist in the SOE model is endowed with foreign
exchange -- the "global vacation budget".  For concreteness, suppose
that this budget denominated in US$ which may be spent at Coolangatta
or Ocean City.  In the base period some fraction of that budget is
spent on tourist visits to the Coolangatta while the rest of the
budget is spent elsewhere in the world (Ocean City).  The subutility
function for vacation happiness is:

	U(T,Z) = ( alpha T^rho + (1-alpha) Z^rho)^(1/rho)

where T represents vacation trips to Coolongatta, the resort town in
our SOE, and Z represents tourism visits elsewhere (Ocean City).  The
foreign tourist solves:

	max U(T,Z)

	s.t.  Pt T + e Z = e B

where B is the tourist's budget in foreign currency, and e is the
"real exchange rate" (the domestic price of foreign exchange, A$/US$). 

Note that the price on Z remains fixed relative to the tourist budget,
embodying the SOE assumption that the cost of vacations in Ocean City
remain constant even with a decline in tourism expenditures.

A scenario which reduces B would reduce T and Z preportionally if Pt/e
were constant. However, if the small open economy suffers a
deterioration in the exchange rate as a result of a decline in tourism
exports, then Pt/e will decline and the foreign tourism demand will
fall less than proportionally with B.  The actually response depends
on the elasticity of substitution between T and Z, characterized here
by rho in U(T,Z) (sigma = 1/(1-rho); rho = 1 - 1/sigma)

$offtext

set	tb	Percent decline in global tourism expenditure /0*10/,
	sg	Alternative elasticities of substitution /0*3/;

set	i	SAM row and column indices /1*14/,
	s	Sectors	/	agr	Agriculture, 
				ind	Industry,
				ser	Services /,
	f	Primary factors / L Labor, N Land, K Capital/,
	h	Households	/ rural, urban/

*	Goods and sectors are identical:

alias (s,g,gg), (i,j);

set	mapa(i,s)	Mapping from SAM to activities	 /1.agr, 2.ind, 3.ser/,
	mapc(i,g)	Mapping from SAM to commodities /4.agr, 5.ind, 6.ser/,
	mapf(i,f)	Mapping from SAM to factors	 /7.L, 8.N, 9.K /,
	maph(i,h)	Mapping from SAM to households	/ 10.rural, 11.urban/, 
	mapg(i)		Identifies government in the SAM  /12/,
	mapi(i)		Identifies the investment row    /13/,
	mapx(i)		Identifies the rest of world	 /14/;

parameter	sam(i,j)	Base year social accounts;
$libinclude xlimport sam sam.xls sam

*	Scale the social accounting matrix so that the average entry
*	is roughly 1:

sam(i,j) = sam(i,j) / 1000;

display sam;

parameter	chksam(i)	Consistency check of social accounts;
chksam(i) = sum(j, sam(i,j)-sam(j,i));
display "Consistency check before balancing:", chksam;

variable	obj		Objective -- least squares deviation;

positive
variable	es(i,j)		Estimate of SAM entries;

equations	objdef		Defines the deviation
		balance(i)	SAM balance condition;

scalar	penalty  /1e6/;

objdef..	obj =e=   sum((i,j), sqr(es(i,j)-sam(i,j))) 
			+ sum((i,j)$(not sam(i,j)), penalty * es(i,j));

balance(i)..	sum(j, es(i,j)) =e= sum(j, es(j,i));

es.l(i,j) = sam(i,j);

model sambal /all/;
solve sambal using nlp minimizing obj;

parameter	nz(i,j)	New nonzeros in the SAM;
nz(i,j) = es.l(i,j)$(not sam(i,j));
display nz;

sam(i,j) = es.l(i,j);
chksam(i) = sum(j, sam(i,j)-sam(j,i));
display "Consistency check after balancing:", chksam;

*	Extract submatrices from the social accounts:

parameter	id0(g,s)	Intermediate demand
		fd0(f,s)	Factor demand
		tm0(g)		Import tariff collection
		m0(g)		Imports (cif),
		c0(g,h)		Private consumption
		g0(g)		Government demand
		i0(g)		Investment demand
		x0(g)		Exports
		tx0		Export taxes (total)
		ti0		Investment taxes (total)
		fe0(f,h)	Factor endowments
		it0(h)		Income taxes,
		s0(h)		Private saving,
		gs0		Government saving
		fs0		Foreign savings
		tf0(f)		Factor taxes
		tr0(h)		Government transfers to households, 
		tx(g)		Export tax rate (assumed uniform)
		px0(g)		Reference price for exports
		d0(s)		Domestic supply
		a0(s)		Aggregate supply
		pm0(s)		Reference price of imports
		tm(s)		Import tariff rate
		ti		Investment tax rate
		inv0		Total investment
		depr0(f)	Deprecation
		xk0(f)		Foreign factor return;

loop((mapc(i,g), mapa(j,s)),	id0(g,s) = sam(i,j) );
loop((mapf(i,f), mapa(j,s)),	fd0(f,s) = sam(i,j) );
loop((mapc(j,g), mapg(i)), 	tm0(g) = sam(i,j) );
loop((mapc(j,g), mapx(i)), 	m0(g) = sam(i,j) );
loop((mapc(i,g), maph(j,h)), 	c0(g,h) = sam(i,j) );
loop((mapc(i,g), mapg(j)),	g0(g) = sam(i,j));
loop((mapc(i,g), mapi(j)),	i0(g) = sam(i,j));
loop((mapc(i,g), mapx(j)),	x0(g) = sam(i,j));
loop((mapg(i), mapx(j)),	tx0 = sam(i,j));
loop((mapg(i), mapi(j)),	ti0 = sam(i,j));
loop((maph(i,h),mapf(j,f)),	fe0(f,h) = sam(i,j));
loop((mapg(i), maph(j,h)),	it0(h) = sam(i,j));
loop((mapi(i), maph(j,h)),	s0(h) = sam(i,j));
loop((mapi(i), mapg(j)),	gs0 = sam(i,j));
loop((mapi(i), mapx(j)),	fs0 = sam(i,j));
loop((maph(i,h), mapg(j)),	tr0(h) = sam(i,j));
loop((mapg(i), mapf(j,f)),	tf0(f) = sam(i,j));
loop((mapx(i), mapf(j,f)),	xk0(f) = sam(i,j));
loop((mapi(i), mapf(j,f)),	depr0(f) = sam(i,j));

*	Assume a uniform export tax:

tx(g) = tx0 / (tx0 + sum(gg, x0(gg)));

px0(g) = 1 - tx(g);

*	Express x0(g) as a gross of tax value:

x0(g) = x0(g) / (1 - tx(g));

d0(s) = sum(g, id0(g,s)) + sum(f, fd0(f,s)) - x0(s)*px0(s);

tm(g) = tm0(g) / m0(g);
pm0(g) = 1 + tm(g);
a0(g) = d0(g) + m0(g) * pm0(g);

inv0 = ti0 + sum(g, i0(g));
ti = ti0/inv0;

*	Introduce tourism here:

parameter	t0(s)	Tourism exports,
		ytot	Total tourist expenditure,
		sigmay	Elasticity of tourist demand,
		tbudget	Tourism budget multiplier /1/;

t0("ser") = x0("ser");
ytot = 3 * sum(s, t0(s));
x0("ser") = 0;
sigmay = 0.5;


$ontext

$model:soe

$sectors:
	y(s)	! Sectoral output (domestic production)
	a(s)	! Aggregate supply (Armington aggregate)
	c(h)	! Household consumption
	invest	! Aggregate investment

$commodities:
	pd(s)		! Domestic output
	pa(s)		! Composite demand price
	pt(s)$t0(s)	! Tourism export price
	pc(h)		! Household consumption price
	pf(f)		! Factor prices
	pinv		! Investment 
	pfx		! Price of foreign exchange

$consumers:
	ra(h)	! Private households
	govt	! Government
	tourist	! Tourist demand

$auxiliary:
	tau	! Consumption tax rate (for trade tax experiment)

*	Production for domestic market and for export:

$prod:y(s) s:0 t:4 va:1
	o:pfx	q:x0(s)	p:px0(s) a:govt t:tx(s)
	o:pt(s) q:t0(s) p:px0(s) a:govt t:tx(s)
	o:pd(s)	q:d0(s)
	i:pa(g)	q:id0(g,s)
	i:pf(f)	q:fd0(f,s)	va:

$report:
	v:x(s)	o:pfx	prod:y(s)
	v:t(s)$t0(s)  o:pt(s) prod:y(s)

*	Armington aggregation of domestic and imported goods:

$prod:a(s)  s:2
	o:pa(s)	q:a0(s)
	i:pd(s)	q:d0(s)
	i:pfx	q:m0(s)  p:pm0(s)  a:govt  t:tm(s)

$report:
	v:m(s)	i:pfx	prod:a(s)

*	Investment:

$prod:invest
	o:pinv	q:inv0	a:govt t:ti
	i:pa(g)	q:i0(g)

*	Household consumption:

$prod:c(h)  s:1
	o:pc(h)	q:(sum(g, c0(g,h)))
	i:pa(g)	q:c0(g,h)	a:govt  n:tau

*	Household demand (with exogenously fixed investment,
*	taxes and transfers):

$demand:ra(h)  
	d:pc(h)	
	e:pinv	q:(-s0(h))
	e:pc(h)	q:(tr0(h)-it0(h))
	e:pf(f)	q:fe0(f,h)

$demand:tourist  s:sigmay
	d:pt(s)	q:t0(s)
	d:pfx	q:(ytot-sum(s,t0(s)))
	e:pfx	q:(tbudget*ytot)

*	Government demand:

$demand:govt s:0

*	Government demand for goods appears here:

	d:pa(g)	q:g0(g)

*	Income tax revenue less transfers, fixed in real terms:

	e:pc(h)	q:(it0(h)-tr0(h))

*	Inestment demand -- this includes government savings, foreign
*	savings and depreciation:

	e:pinv	q:(-gs0-fs0-sum(f,depr0(f)))

*	Factor ownership includes lump-sum taxes on factor income,
*	depreciation and returns to foreign factor owners:

	e:pf(f)	q:(tf0(f)+depr0(f)+xk0(f))

*	Foreign savings appear as a credit, returns paid to foriegn
*	factor owners is a debit:

	e:pfx	q:(fs0-sum(f,xk0(f)))

$constraint:tau
	govt =e= sum(g, pa(g) * g0(g));

$offtext
$sysinclude mpsgeset soe

*	Check the benchmark:

soe.iterlim = 0;
$include soe.gen
solve soe using mcp;
soe.iterlim = 2000;

tau.lo = -inf;

*	Examine declines in tourism expenditure between 0
*	and 10%:

parameter	impact	Impact of change in tourist expenditure;

loop(tb,
	tbudget = 1 - 0.01 * (ord(tb)-1);
	impact(tb,"b") = 100 * (tbudget-1);

	loop(sg,

	  sigmay = ord(sg)-1;

$include soe.gen
	  solve soe using mcp;

	  impact(tb,sg) = 100 * (t.l("ser")/t0("ser")-1);

	);

);
$setglobal labels tb
$setglobal domain tb
$setglobal gp_opt0 "set xlabel 'Percent decline in B'"
$setglobal gp_opt1 "set ylabel 'Percent change in T'"
$libinclude plot impact