Semi-exogenous shocks, what if we have many values?

Dear all

Consider a model with stochastic human capital, where human capital is a semi-exogenous state whose transition probabilities depend on the employment state. Employment can be thought of as another semi-exogenous state, but that’s not relevant at the moment.

Let H={h_1,…,h_n} denote the human capital grid with n elements. I want to impose that if the agent is employed (l=0), he can either stay with the current level of human capital or move up the ladder by one level with probability delta_0. Likewise

For some reason I cannot modify the post above. Let me continue here:

If the agent is employed he can either stay where they are with prob 1-\\delta_1 or move up one level with probability \\delta_1. So the logic is that if you are unemployed, your human capital depreciates stochastically, but if you are employed your human capital might stochastically increase. The movement are only + or - one grid point.

I can easily create the two transition matrices in Matlab with the following simple code:

clear,clc,close all

n     = 4;      % number of states
delta = 0.1;    % probability of downward/upward move

%% Markov chain if unemployed (l=0)
prob_hc_l0 = (1 - delta)*eye(n) + delta*diag(ones(n-1,1), -1);
% fix bottom row so it still sums to 1
prob_hc_l0(1,:) = 0;
prob_hc_l0(1,1) = 1; % stays in state 1 if already at the bottom
disp(prob_hc_l0)

%% Markov chain if employed (l=1)
prob_hc_l1 = (1 - delta)*eye(n) + delta*diag(ones(n-1,1), 1);
% fix top row so it still sums to 1
prob_hc_l1(n,:) = 0;
prob_hc_l1(n,n) = 1; % stays in state n if already at the top
disp(prob_hc_l1)

which produces the matrix for unemployed:

  1                         0                         0                         0
                       0.1                       0.9                         0                         0
                         0                       0.1                       0.9                         0
                         0                         0                       0.1                       0.9

and the matrix for employed

  0.9                       0.1                         0                         0
                         0                       0.9                       0.1                         0
                         0                         0                       0.9                       0.1
                         0                         0                         0                         1

Is it possible to do this with the toolkit?

More in general, I find that the use of f_SemiExoStateFn with if conditions inside is a bit limiting, because it works only if you have a very small number of values for the semi-exogenous shocks. I think it would be nicer to allow the user to input directly the transition matrix for semiz, something like an array with 3 dimensions F(semiz,semiz’,d) or 4 dimension if it is also age-dependent F(semiz,semiz’,d,j)

Totally unrelated: it seems that the editor here in the discourse experienced a negative TFP shock :slight_smile:

or maybe it’s just my laptop?

I agree, the editor did seem to have a negative tech shock :smiley:

Discourse, which is the software that runs the forum, used to have ‘MathJax’ as a plugin and moved it to be inbuilt. It is also my impression that this has led to a backward step in the performance of the editor. Hopefully they resolve it in the next few patches (they release patches more or less continuously, the change was less than a month back).

Internally, I convert the SemiExoStateFn into pi_semiz_J which has dimensions (semiz, semiz’, d3, j) [d3 is the decision variable(s) that controls the semi-exogenous state]
I guess I can easily enough allow you to just input this matrix directly, I will go make the changes in the next day or two and report back. [The only reason I used the function rather than matrix setup was it seemed easier for the beginner user, so makes sense I should have the matrix alternative for advanced users.]

That said, you can typically do the SemiExoStateFn setup easily enough as a big bunch of if-else statements, which is just a rather verbose version of the matrix.

If you are not wedded to the discrete nature of your human capital, you would be better off setting this up as an experienceassetu. You would use ‘l’ as the decision variable, ‘u’ shock would determine if you move up (down) or not while employed (unemployed), and so the aprimeFn would just be @(l,h,u,delta) (l==1)(h+delta*u)+(l==0)(h-delta*u); (which is the value for hprime; so if you work there is a probability that you add delta to h, and if you do not work there is a probability that you subtract delta from h; you would set n_u=2, u_grid=[0;1] and pi_u=[1-deltaP; deltaP]; (note that I use delta for how much h changes, and deltaP for the probability that occurs, in your example deltaP was 0.1 and delta was not described but is implicit in what you used as the spacing between the grid points for the semi-exo state)

[Actually this experienceassetu setup would also work for a discrete human capital but only in the case where semiz_grid was evenly spaced, and that spacing was equal to delta. It would not work if the semi_zgrid spacing was not even.]

1 Like

Great, thanks for the suggestion about experienceassetu!

In your example, deltaP is the probability that the shock u is equal to 1? If so, shouldn’t you write

Pi_u = [1-deltaP, deltaP]

?

To make sure that human capital stays bounded, should I clip it in [hmin,hmax] in aprimeFn?

cleaned up my post

No need to clip it, internally if you try to go off the end of the grid it just forces you to the endpoint with probability 1.

1 Like

That would be quite useful, thanks!

If I have two semi-exogenous shocks that depend on a single decision variable and on age, the matrix would be

pi_semiz_J(semiz1,semiz2,semiz1’,semiz2’,d,j)

or the equivalent

pi_semiz_J = reshape(pi_semiz_J,[n_semiz1*n_semiz2,n_semiz1*n_semiz2,n_d,N_j]) ?

Correct (I will check internally what size matrix is and if it is the former I will convert to the later, so both will be accepted as inputs)

1 Like

I wanted to add that the matrix pi_semiz_J is useful also for welfare calculations.

I have a separable utility function and I compute the CEV following your Conesa et al example: LifeCycleOLGReadingList/ConesaKitaoKrueger2009/chooseCEV_C_function.m at main · robertdkirkby/LifeCycleOLGReadingList · GitHub

However, while CKK has only Markov shocks, I have semi-exogenous shocks so I need the transition matrix pi_semiz_J. That’s why I have computed it myself.

Note for readers: CKK have a separable utility function as a robustness check, their main specification features a Cobb Douglas utility

Thanks a lot! Please let me know when you introduce this option, so that I will update the toolkit and test it on my code.

You can now set either
vfoptions.SemiExoStateFn
or
vfoptions.pi_semiz_J

In either case you need to set both
vfoptions.n_semiz
vfoptions.semiz_grid
And you need to include copies of all three in simoptions.

If you use vfoptions.pi_semiz_J it should be a matrix of size [N_semiz,N_semiz,N_d3,N_j], where N_semiz=prod(n_semiz), and N_d3=prod(n_d3) with n_d3 the decision variables that influence the semi-exogenous states.

Pretty sure this should just work with everything (advantage of how I have made the toolkit internals modular).

1 Like

Hi Rob,

Thanks a lot for making this change! It works well but it returns an error in SimPanelValues_FHorz_Case1. I think the error has nothing to do with the new option for pi_semiz_J but is specific to the panel simulation command.

I assume it is just the same error you mention in Error in SimPanelValues_FHorz_Case1. I should get to it in the next day or three.

1 Like

Yes it is the same error

1 Like