// 3-period OLG with capital and loans from middle-aged to young cohort.
// All variables on per effective worker-form.
// Variables are output, capital, wage, real interest rate, rental price on capital (q),
// saving in the form of capital investments (s), loans from middle-aged to young cohort,
// consumption for 3 generations, and pensions.
var y k w r q s B cY cM cO PEN check1 check2 yearly;
// Exogenous variables are a loaning restriction X for the young cohort, the relative price of capital (p),
// tax rate and total factor productivity A.
varexo X p ctau A;
// Parameters are period length, depreciation rate, discount rate and labor's share of output.
parameters T cdelta cbeta calpha;
T = 25;
// Depreciation rate
cdelta = 1 - (1 - 0.1)^T;
// Discount rate
cbeta = 1/((1 + 0.03)^T);
// labor share
calpha = 0.6;
model;
// Cobb-Douglas production (where L = 1).
y = A*k^(1-calpha);
// Rental price of capital equals marginal product of capital
q + cdelta = (1-calpha)*(A*k^(-calpha));
// Wages equal marginal product of labor
w = calpha*y;
// FOC for the middle cohort's loans to the young cohort
1/cM = cbeta*((1+r)/(cO(+1)));
// FOC for capital investments s.
(p-q)*cO(+1) = cbeta*p*(1-cdelta)*cM;
// Consumption for young cohort
cY = B;
// Consumption for middle-aged cohort. Rental income (q) from capital is received in the same period as one buys it.
// Pays back X(-1) = B(-1)*(1+r(-1)) which was the loan made as young plus interest. Lends out amount B to young cohort.
cM = w*(1-ctau) + (q-p)*s - X(-1) - B;
// Consumption for old cohort.
cO = p*s(-1)*(1-cdelta) + (X(-1)) + PEN;
// Capital law of motion
k(+1) = (1-cdelta)*k + s;
// Loans market clear
B = X/(1+r);
// PAYG-pensions
PEN = ctau*w;
// checking that output equals labor income plus capital income.
check1 = y - w - k*q;
// alternative check
check2 = y - w - k*q - s;
// yearly interest rate
yearly = r^(1/T) - 1;
end;
initval;
y = 5.00649;
k = 1.00325;
w = 3.00389;
r = 1.46021;
q = 1.0679;
s = 0.931225;
B = 0.243881;
cY = 0.243881;
cM = 1.28903;
cO = 1.51463;
PEN = 0.84109;
check1 = 0.931226;
yearly = 0.0152585;
X = 0.6;
p = 1.1;
ctau = 0.28;
A = 5;
end;
steady;
simul(periods=12, maxit=30);
check;
model_diagnostics;