# Overlapping Generations Model (OLG)

**URL:** https://forum.dynare.org/t/overlapping-generations-model-olg/2158
**Category:** Dynare contributions and examples
**Created:** [22 September 2011 15:56 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158 "2011-09-22T15:56:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![charliesan](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@charliesan](https://forum.dynare.org/u/charliesan)
#### Post date: [22 September 2011 15:56 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158/1 "2011-09-22T15:56:30Z")

</div>

Hi guys,

I’ve just started using matlab and dynare.

anyone has a code for a simple deterministic OLG model? I can only find Ramsey ones.

Thank You very much.

Charlie.

---

<div class="post-metadata">

### Author: ![makota](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/a88e4f/32.png) [@makota](https://forum.dynare.org/u/makota)
#### Post date: [27 February 2012 13:43 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158/2 "2012-02-27T13:43:00Z")

</div>

Hey,

I noticed that here’s very little OLG related material. So here’s a basic 2 cohort Diamond-Samuelsson.

```auto
// Basic OLG with population growth and technological growth
var c c1 c2 k w r s y check1 check2;

parameters beta alpha delta n x;
beta = 0.4010; // 0.97^30
alpha = 1/3; delta = 0.9; n=0.1614; x=0.3478;

kss = ((1+1/beta)*(1+n)/(1-alpha))^(1/(alpha-1));
wss = (1-alpha)*kss^alpha; rss = alpha*kss^(alpha-1)-delta;
sss = (1+n)*kss; c1ss = sss/beta; c2ss = (1+rss)*sss;
yss = kss^alpha; css = c1ss+c2ss/(1+n);

model;
    // In effective labour form
    1/c1 = beta*(1+r(+1))/c2(+1);
    c1 + s = w;
    c2(+1) = (1+r(+1))*s;
    y = k(-1)^alpha; // Y/XL = (K/XL)^alpha
    w = (1-alpha)*k(-1)^alpha;
    r = alpha*k(-1)^(alpha-1) - delta;
    c = c1 + c2/(1+n+x); // C = X*L*c1 + X(-1)*L(-1)*C2;
    // ECNOMY WIDE FEASIBILITY CONSTRAINT
    y = (1+n+x)*k - (1-delta)*k(-1) + c; 
    check1 = y -( (1+n+x)*k - (1-delta)*k(-1) + c);
    check2 = (1+n+x)*k - s;
end;

initval; 
k = kss; c1 = c1ss; c2 = c2ss; r=rss; w=wss; s=sss; c=css; y = yss;
end;

steady;

```

---

<div class="post-metadata">

### Author: ![jepecolc](https://forum.dynare.org/user_avatar/forum.dynare.org/jepecolc/32/8932_2.png) [@jepecolc](https://forum.dynare.org/u/jepecolc)
#### Post date: [23 June 2012 18:54 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158/3 "2012-06-23T18:54:29Z")

</div>

Hi there,

Thanks a lot for this post. I have a problem, though. If I try to save the results in a “mat” file by using this command  
dynasave (OLGResults) w c1 s c2 r k c y;

I get this error message

Error using horzcat  
CAT arguments dimensions are not consistent.

I have found out that the problem is caused by variable “s”; i.e. if I use the command  
dynasave (OLGResults) w c1 c2 r k c y; // excluding “s”

it works fine.

However, in the former case (when I get the error) if I open the oo\_.endo\_simul file, the variable “s” is there, with the same (!) number of observations as the other endogenous variables.

Does any one have an idea of what is going on? What am I doing wrong?

Any help would be appreciated.

Best,  
jepecolc

---

<div class="post-metadata">

### Author: ![William](https://forum.dynare.org/letter_avatar_proxy/v4/letter/w/b19c9b/32.png) [@William](https://forum.dynare.org/u/William)
#### Post date: [9 October 2017 12:40 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158/4 "2017-10-09T12:40:44Z")

</div>

hello, what utility function did you use for the model?

---

<div class="post-metadata">

### Author: ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)
#### Post date: [9 October 2017 15:15 UTC](https://forum.dynare.org/t/overlapping-generations-model-olg/2158/5 "2017-10-09T15:15:45Z")

</div>

This one was \log(c)
