Documentation on ValueFnIter_Case2

Hi Robert,

I would need to implement ‘Case2’ of the VFI code.
Compared to Case 1, there are two there are two additional parameters required: ‘Phi_aprime’ and ‘Case2_Type’.
However, I am uncertain about their definitions and couldn’t find additional documentation on them.

Any pointers would be greatly appreciated :slight_smile:

Best,
Barnabás

1 Like

The only model using Case2 is the replication of Castaneda, Diaz-Gimenez & Rios-Rull (2003)

That said, there are nowadays a number of other ways to do this some of the time (new features like ‘riskyasset’). If you describe the endogenous state in your model a little more I will tell you if it fits one of these other nicer approaches.

[Longer term vision of the toolkit is to eliminate Case1, Case2, etc. and instead have standard asset where aprime is chosen directly, and then implement other asset types, like riskyasset, to handle the alternatives. It has nowadays become clear to me that this is a cleaner and more flexible/powerful approach. The documention of the tookit needs an overhaul to reflect this.]

1 Like

First of all, thank you very much for your reply, this is already very helpful!

I am implementing a Khan and Thomas (2013) type of heterogeneous firms model, where firms own capital and may borrow or save. Thus, a firm can be described by capital, one-preiod debt and current productivity: (k,b,eps) and it chooses future capital, k’ and debt, b’ to maximize dividend payouts. So far, this conforms to Case1.

However, I would like to use a cash on hand variable, x, which is defined in equaiton (1).
The value function is then defined by equation (2) - where q is the inverse gross interest rate and P_chi is an exogeneous death shock.
Finally, next period’s cash on hand is defined by equation (3).

Hence, the firm may choose k’ and b’, but next periods’ state endogeneous state variable, x’ also depends on the realization of the future productivity, eps’. As far as I understand, this is Case2.

Best,
Barnabás

1 Like

The cash on hand trick is useful since it saves you one state variable. Not sure how to implement this in the toolkit though, since the next-period value of cash, x’ in eq(3) would not lie on the grid in most cases. This would require interpolation, which calls for using the “riskyshare” setup…

A simpler approach would be to just treat k and b as two endogenous state variables. Then you can choose directly k’ and b’ and this is a simple, straightforward Case 1 with two endog states, one exogenous Markov state eps and no decision variables, hence n_d=0. Please consider that if you plan to extend the model and introduce e.g. capital adjustment costs, then you wouldn’t be able to apply the cash on hand trick any more and you would have to keep track of both k and b anyways

Hey Alessandro,

You are right. I did manage to solve the VFI where firms choose k’ and b’ directly, just as you describe it. However, I plan to extend on the model, and I expect that this state-space reduction will become necessary later.

Could you elaborate on this part of your answer?
“ x’ in eq(3) would not lie on the grid in most cases. This would require interpolation, which calls for using the “riskyshare” setup… “

Thank you very much,
Barnabás

1 Like

Is epsilon markov? (as opposed to iid)

(I’m guessing so as epsilon’ is what determines x’, and epsilon still appears as a state of the value function)

1 Like

Yes. Epsilon is defined as an AR(1) process. Then, I use Tauchen’s method to discretize it. This is standard in the literature.

1 Like

Sorry but the toolkit does not really have this combo implemented (maybe some day :slight_smile: ). You would have to just do it as two separate assets, which is obviously nowhere near as fast :sob: (riskyasset assumes iid, so won’t work for markov).

PS. I recommend using Farmer-Toda rather than Tauchen to discretize the AR(1), it is better.

1 Like

Hi @Boca, that part of my answer was not very clear indeed :slight_smile:
To solve the model you outlined in (1) to (3) you need to have a grid on cash on hand x (and also the AR1 shock eps of course, discretized with Tauchen or even better Farmer-Toda). Then the choice variables are k’ and b’, and these two choices, together with eps’, will determine the next period value of x, defined as x’. One issue arises here: x’ will not be exactly one of the grid points of the x grid. For example, x’=3.5 and the x grid is [0, 0.4, 2.3, 3.1, 4.0, etc]. So you have to interpolate the value function V in eq (2) obtaining something like

Vinterp = weight*V(3.1,eps’) + (1-weight)*V(4.0,eps’)

where weight is the interpolation weight defined as

weight*3.1 + (1-weight)*4.0 = 3.5 = x’

I think the toolkit can handle this only as special cases like “riskyasset” but the shock that determines x’ together with some decision variable, has to be iid. @robertdkirkby feel free to correct me of course if I say smth wrong or imprecise :slight_smile:

Yeah, to do the cash-in-hand trick you need the interpolation onto the grid. Essentially if we have a grid on x, then because of how we calculate xprime it is unlikely to fall on the grid, and so it needs to be (linearly) interpolated back onto the grid.

The only publicly documented part of the toolkit that does interpolation is riskyasset. A risky asset has aprime(d,u) and the way to toolkit does it is to use grids on d and u, evaluate aprime(d,u) exactly (for each point on the d,u grids), and then interpolate this onto the a grid. To give a concrete example, pretend d,u and a are all binary 0-1 grids. We would consider say (d,u)=(0,0), and evaluate the exact aprime(0,0)=0.7 (this 0.7 is arbitrary example). We then need to interpolate this 0.7 onto the a grid (which is 0 and 1); linear interpolation is that we put 0.3 on the 0 grids point and 0.7 on the 1 grid point (because of how close 0.7 is to each grid point). We would then do the same for the other three points on the (d,u) grid.

There are actually some other parts of the toolkit doing this, but not documented yet. residualasset also does this and is used in Life-Cycle Model 38 (as need to keep the lag of consumption as a state variable), and so do experienceasset and experienceassetu which implement human capital but are not yet documented anywhere (probably early next year, they are brand new and going through some quality control at present).

1 Like

Thank you @aledinola and @robertdkirkby !
As you can probably tell I am quite new to this. But all this makes a lot of sense.
Also thank you for the hint on discretization.

Barnabás

1 Like