Portfolio-Choice with Housing

I’ve added a Life-Cycle Model 35 to the Intro to Life-Cycle Models that implements portfolio-choice with housing.

Housing is modeled as a six-valued standard endgenous state, when the value is zero this represents not-owning a house. Everything else about the model setup is a bit arbitrary, if anyone knows a nicer set of budget constraints etc to impose, please let me know.

Just a quick warning this code has not undergone as much testing as is standard in the tookit (normally I try to either use code in a paper or replication before I make it public). I am pretty sure it is working fine but please contact me if you see odd behaviour.

Lastly a comment on accuracy, the current code has just 101 points on savings, this is not enough. In the example I use the same grid on savings and assets, but really you should use more grid points on savings (the range of both, that is the min and max, should be the same; in codes I just use the same grid on both, but this is not really a good idea). The reason is that savings is required to only take values on the grid, whereas aprime is evaluated exactly (conditional on savings and riskyasset which are both on grids) and then aprime is interpolated onto the grid on a (assets). Thus for a good mix of speed and accuracy you will want lots more points on savings than on assets. [That you should use more points on the decisions than on the endogenous state is true for all use of riskyasset, is entirely independent of the housing.]

2 Likes

Quick comment for my future self. When doing portfolio choice I should divide decision variables into three types: d1 are in ReturnFn but not aprimeFn (e.g., endogenous labor), d2 are in both ReturnFn and aprimeFn (e.g., savings), and d3 are in aprimeFn but not ReturnFn (e.g., riskyshare).

Currently I just put d=(d1,d2,d3) into return and aprime, but this is wasteful. I should put (d1,d2) into ReturnFn, then refine to elimante d1. Then put (d2,d3) into aprimeFn, then refine to eliminate d3. I can then put refined ReturnFn and aprimeFn together having only d2 left. This is likely to be both faster and use substantially less memory.

2 Likes

Thanks a lot for the extension, Robert! I will try to learn and use it for my own research. If I find that anything goes wrong or is not clear, I will let you know.

2 Likes

Quick description of the tests I ran. When I make the return function ignore the housing and just be the same as Life-Cycle Model 32 I get the exact same answer as in that model [for V, Policy, and life-cycle profiles]. I did this both with vNM preferences and with Epstein-Zin preferences.

If I add that housing has to equal a certain number, then it does [e.g. I just added that F=-Inf is it is not true that hprime=rem(agej,6), and this gave a sawtooth shape to the housing mean life-cycle profile].

What I haven’t tested is when housing interacts with everything else, I think it is working but it hasn’t had much testing.

1 Like

Thank you Robert. Great update!

1 Like

Quite interesting!! Portfolio choice models with housing are quite popular in the finance literature.

I noticed a small discrepancy between the matlab code of example 35 and the pdf documentation. When h=0, the agent is a renter and housing services s are proportional to minhouse:

s=0.5 * houseservices * minhouse

In the writeup however, if h=0 then also s is equal to zero,

s = houseservices * h

I think this might be a typo (the formulation in the code is correct but the pdf is not)

Thanks, typo in docs, fixed.

I guess rightly so given buying a house is for most people the largest financial decision of their lives (outside of germany :wink: )

1 Like

Dear Robert,

is it possible to see your code for this particular housing model. I want to work on something similar in my research?

Thank you very much in advance for your help!

1 Like

Code or pseudo-code?

The code is already public as it is all on github, and if you want to see inside, e.g., the value function iteration step, just run the code and when it is mid-run calculating the value function press Ctrl+C. Matlab will then tell you where it was when you cancelled and this will be the specific value function iteration code that it uses for this problem (essentially, inside ValueFnIter_Case1_FHorz there are a large number of different value function commands, and based on inputs it figures out which of these to send it to).

If you do look at a specific piece of code, feel free to ask me what it is doing.

1 Like

PS. This is the value fn code that Life-Cycle Model 35 is calling [“raw” is what I call all the internal subcommands that do the actual value fn iteration, it is just pure discretization algorithm, together with interpolation to deal with the ‘u’ shocks]

If the comments are unclear just let me know. Or if you want pseudo-code just let me know.

a1 is the housing, a2 is the riskyasset.

1 Like