```\$title	Liquidity-Constrained Lifecycle Expenditure Model (NLP and MCP formulations)

\$ontext

Hi!

I am again. I guess that I already found the problem
in the formulation of the model (I mathematical error
program runs good.
The model is basisclly a Ramsey model. For speaking
more about it, it tries to represent the behavior of a
household with exogenous income and intertemporal
desicions in consumption and savings.

But now I have another little problem. Why the final
level values of the desicions variables change
(sometimes little, others a lot) when you modify the
initial values for them and solve the model (of
course, after the calibration of the paramters)?.

I send you the program that I did in GAMS, with
another document in WORD that have the FOC equations
obtained by solving the model using KKT.

Thanks.

The Original Model

set t /t1*t21/;
alias(t,s);
Variables
c(t)
d(t)
p(t)
r(t)
y(t);

equations
euler(t)
budget(t);

parameter
beta(T);

parameter
d0(t);

euler(t) ..      beta(t)/(p(t)*c(t))-(beta(t+1)*(1+r(t))/(p(t+1)*c(t+1)))\$(ord(t)<>card(t))=g=0;
budget(t)..      p(t)*c(t)+d(t)=e=(1+r(t-1))*d(t-1)+y(t);

y.fx(t)=200*(1.01)**(ord(t)-1);
p.fx(t)=(0.9)**(ord(t)-1);
r.fx(t)=0.03;

c.lo(t)=1.e-5;
d.lo(t)=0;
d.fx('t21')=0;

c.l(t)=150*(1.01)**(ord(t)-1);

loop(t,
d.l(t)=((1+r.l(t-1))*d.l(t-1))+y.l(t)-p.l(t)*c.l(t););
d0(t)=d.l(t);

c.l('t21')=(p.l('t21')*c.l('t21')+d.l('t21'))/p.l('t21');

beta(t)=(prod(s\$(ord(s)1)+1\$(ord(t)=1);

*This is something that I cant understand. Why the final variables change at differentes values of this initial value.
c.l(t)=5000;

model cos /
euler.d
budget.c
/;

option mcp = miles;

solve cos using mcp;

execute '=gdxviewer full.gdx'

\$offtext

An Alternative Approach

set		t		Time periods for a typical life-cycle /20*75/,
tr(t)		Retirement period /65*75/,
tl(t)		Labels for plots /20, 40, 60/,
tlast(t)	Last period;
alias(t,tt);

*	Define which period is the last one:

tlast(t) = yes\$(ord(t)=card(t));

parameter	r	Interest rate on savings /0.03/,
delta	Intertemporal discount rate /0.05/,
y(t)	Income level in time period t
pv(t)	Present-value price index
beta(t)	Utility discount factor;

*	Assume a 10% market interest, a 3% rate of return on savings and future
*	income growth of 1% per annum:

pv(t) = 1/(1+r)**(ord(t)-1);
beta(t) = 1/(1+delta)**(ord(t)-1);

*	Assume a lifecycle income profile as in Auerbach and Kotlikoff (1987):

y(t) = EXP(4.47 + 0.033*(ord(t)-1) - 0.00067 * (ord(t)-1)**2);
y(tr) = 0;

variables	c(t)		Consumption,
b(t)		Savings balance at the end of time period t,
u		Intertemporal utility;

equations
budget(t)	Budget constraint in time period t
utility		Defines intertemporal utility;

utility..	u =e= sum(t, beta(t) * log(c(t)));

budget(t)..      (1+r) * b(t-1) + y(t) =e= c(t) + b(t);

model ramsey /all/;

c.l(t) = beta(t) * sum(tt, pv(tt) * y(tt)) / pv(t);

*	Place a lower bound on C to avoid bad function calls:

c.lo(t) = 0.1;

*	First solve without a liquidity constraint:

b.lo(t)=-inf;
b.fx(tlast) = 0;

solve ramsey using nlp maximizing u;

parameter	results		Consumption and Savings over the Lifecycle;
results(t,"c*") = c.l(t);
results(t,"b*") = b.l(t);

*	Then solve the liquidity-constrained problem:

b.lo(t)=0;
solve ramsey using nlp maximizing u;
results(t,"c0") = c.l(t);
results(t,"b0") = b.l(t);

\$setglobal domain t
\$setglobal labels tl
\$libinclude plot results

variable	mu(t)		Shadow value on income balance in period t;

equation	foc_b(t)	First-order condition on savings balance
foc_c(t)	First-order condition on consumption;

foc_b(t)..	mu(t) =g= (1+r) * mu(t+1);

foc_c(t)..	mu(t) * c(t) =e= beta(t);

model mcp /budget.mu, foc_b.b, foc_c.c/;

mu.l(t) = - budget.m(t);

mcp.iterlim = 0;
solve mcp using mcp;

b.lo(t)=-inf;
b.fx(tlast) = 0;
mcp.iterlim = 10000;
solve mcp using mcp;

```