Best way to model labor productivity shocks and exogenous shock jointly

Hi Robert,

I’m interested in modeling labor productivity shocks (makov and iid, model 11 in intro to lifecycle models) and exogenous shock like medical expenditure (model 20/21 in intro to lifecycle models).

I’ve tried to add the exogenous shock into model 11 by using vfoptions.ExogShockFn, but I haven’t been successful in modifying solving the model. Here, I’ve tried to solve it by batching up both productivity shocks and exogenous shock together.

Do you have a recommended way to solve this kind of model?

Please let me know.

Best,
Kaz

1 Like

Hi Kaz,

there are three ways you might add a medical (markov) shock alongside a labor productivity (markov) shock.

(i) You can have two markov shocks, let’s use the notation z=(z1,z2), so z1 is the productivity and z2 is the medical. Then just set z_grid=[z1_grid; z2_grid]; and pi_z=kron(pi_z2, pi_z1); (note reverse order for the later). If you take this approach then there are two ‘z’ variables, and so you need to include both as inputs in the ReturnFn and all FnsToEvaluate.
Note that this can then fairly easily be extended to allow for the two shocks to be correlated. Or to allow for the shock processes to be age dependent.

(ii) If you just want the productivity during working age and the medical during retirement, then you can just use a single markov shock, and simply interpret it in different ways at different ages. This is the approach of Imrohoroglu, Imrohoroglu & Joines (1995), and is what is being done in Life-Cycle Model 21. In this case there is just one exogenous state, but you have to be careful interpreting z as it means different things at different ages (this is easy enough, just requires care). The advantage of this over the first option is that it is going to compute much faster because there is only one shock at each age (rather than two).

(iii) You could have the productivity as a markov, but then model medical as a ‘semi-exogenous state’. A semi-exogenous state is like an exogenous markov, but the transition probabilities depend on a decisino variable. So you could have that the transition of your health state depends on a medical spending decision. Life-Cycle Model 30 shows how to add a semi-exogenous state (there the state is children, and transitions depend on the decision to try to have a child).

All of these can be paired with an i.i.d shock (which may be age dependent) on labor productivity units.


From your description I am guessing that you are mixing up (i) and (ii). You want to do one shock that is interpreted in different ways at different ages (and has different grids and transition probabilities at different ages), but then you are putting it as two inputs to some functions when it is just one input?
If this explanation doesn’t help you sort it then email me a copy of your code and I will take a look.

PS. There is a replication of Imrohoroglu, Imrohoroglu & Joines (1995) if you want to see option (ii) in action.

1 Like

Hi Robert,

Thank you for your quick reply.

The strand of models I’m interested in is along the lines of French and Jones (2011) (https://onlinelibrary.wiley.com/doi/abs/10.3982/ECTA7560). When stripped down to a simpler model, they model age dependent medical expenses (in their model, agents incur medical expenses in all periods) as a function of health state that evolves as age dependent markov process. This health state also influences wages and survival rate both of which are also modeled as a function of health state.

I have sent you an email with the code I’m experimenting.

Best,
Kaz

1 Like

Kaz sent me code via email, using what is described as approach (i) above. Following are comments on what was wrong that might be useful to others.

  1. You had set up n_z=[z1,h], where z1 is persistent labor shock, h is health shock. You have to use this same ordering everywhere. But then in the return function you had (…,h,z1,…) and same in the FnsToEvaluate. Hence why you thought things were going wrong, e.g., when you thought you were plotting a life-cycle profile of h you were actually plotting a life-cycle profile of the first exogenous shock which is z1.

  2. If you use ‘ExogShockFn’ then you have to do this for all markov shocks. It is not possible to use it for some markov shocks but not others. I have just eliminated the use of this and instead used age-dependent shock processes for both of your markov states. If you want to use ExogShockFn you can, just make it output the combined z_grid=[z1_grid; h_grid] and pi_z=kron(pi_h,pi_z); [note that is is reverse order in kron()]

Hi Robert,

Thank you for looking into my code, and pointing out mistakes.

The reason why I did not use the “e” option for transitory shock previously is that I get an error in running lifecycle model 11B. Indeed when I try to run the code you have sent me, I get the same error as attached. I’m not sure whether this error is because I’m running the program on mac. I will run it on pc and get back to you shortly.

FYI: I’m using MATLAB 2022b on intel processor macbook pro with 32gb ram, and I’ve used the latest version of the vfitoolkit on github.

Many thanks,
Kaz


1 Like

This error is because ‘e’ i.i.d. variables are only supported by GPU (not implemented on CPU). I have added a message to make this clear.

If you plan to run a bunch of models it is well worth getting a GPU, for example, Life-Cycle Model 3 is less than one second on GPU but 8-10 minutes on CPU, and Life-Cycle Model 9 is 10 seconds on GPU but 90min on CPU. [these are times for the value function problem, your actual runtimes will obviously vary with your hardware].

[general note: the run time differences are partly about gpu vs cpu, but mostly just because the way VFI Toolkit works is built around alogrithms that take advantage of gpu but are a bad idea with cpu. ]

1 Like

Hi Robert,

Thank you again. I didn’t realize the “e” option used gpu; I thought the error was because of using a mac.

I will purchase gpu if budget allows.

Many thanks,
Kaz

1 Like

Basic features, the toolkit looks if you have a GPU and uses it, but otherwise uses CPU. More advanced features only exist for GPU.

1 Like