Semi-exogenous shock whose transition depends on a Markov shock

The title says it all. Consider a model with a semi-exogenous shock semiz and two exogenous Markov shocks z1 and z2. The transition probabilities for semiz depend on a decision variable d, on some age-dependent parameters and, importantly, on some parameter whose value depend on z2.

To make the example more concrete, think of semiz as the employment state whose transitions (job finding and job loss probabilities) depend on search effort (the d variable). The job loss probability is a parameter, call it \delta(h) which depend on the health shock (which is purely exogenous and is z2).

How do I implement this in the toolkit? I had created the function SemiExoStateFn but then realized that I cannot pass z2 as input variable!

function prob=f_SemiExoStateFn(l_val,lprime_val,s_val,jdr_h0,jdr_h1)
% Variable name       Description                  Toolkit notation
% -------------       -----------                  ----------------
% l_val               Employment today             semiz
% lprime_val          Employment tomorrow          semiz_prime
% s_val:              Search effort                d (not d1)
% -------------------------------------------------------------------------
% Markov chain for (l,lprime):
% t\t+1           l=0 (non-empl)  l=1 (employed)
% -----           --------------  --------------
% l=0 (non-empl)  1-jfr(s)        jfr(s)
% l=1 (employed)  jdr(s)          1-jdr(s)
% -------------------------------------------------------------------------

prob=-1; % Just a placeholder (one that will cause errors if not overwritten)

% Job finding rate depends on search effort
jfr = min(1.0,s_val);

% Job destruction rate depends on health status but for now we assume it
% does not!
jdr = jdr_h0;
%jdr = -1; % Just a placeholder (one that will cause errors if not overwritten)
% if h_val==0
%     % bad health
%     jdr = jdr_h0;
% elseif h_val==1
%     % good health
%     jdr = jdr_h1;
% end

% Define transition probabilities
if l_val==0
    % Today non-employed
    if lprime_val==0
        prob = 1-jfr;
    elseif lprime_val==1
        prob = jfr;
    end
elseif l_val==1
    % Today employed
    if lprime_val==0
        prob = jdr;
    elseif lprime_val==1
        prob = 1-jdr;
    end
    
end %end if

end %end function

In the function above, I need the value of z2 (called h_val in my code) to choose the right parameter value for the job loss probability.

Does the solution require declaring also z2 as a semi-exogenous shock even if it is not?
If I were to write my own code for example I would do this:

pi_semiz = zeros(n_semiz,n_semiz,n_d,N_j,n_z(2))
for z2_c = 1:n_z(2)
for jj = 1:N_j
for d_c=1:n_d
    pi_semiz(:,:,d_c,jj,z2_c) = 'write 2*2 matrix here'
end
end
end

Short answer: Yes, as you say the solution in your case is to declare z2 as a semi-exogenous shock even though it is just a markov.

Long answer:
VFI Toolkit is set up with a few different types of shocks (semi-exogenous markov, markov, i.i.d., between-period i.i.d.; semiz,z,e,u).

Each different type of shock is handled independently. So you cannot have a semiz that depends on a z (as in your example). Nor can you have that the innovations to a markov are correlated with an i.i.d.

Within each type of shock, you can have multiple shocks of that type, e.g., three markovs, or four i.i.d.s. VFI Toolkit allows for correlations and dependencies of a shock and another shock of the same kind. E.g., you can have a semiz whose transitions depend on the value of another semiz, or you can have two i.i.d shocks that are correlated.

One ‘trick’ you can pull is to disguise a shock of one type as being another type, and then you can make them depend on each other. Any i.i.d. e shock, can be implemented as a markov z shock. Any markov z shock, can be implemented as a semi-exogenous markov semiz shock. After you disguise it as another type, you can then have dependency with that other type.

In your example, you have a semi-exogenous markov that depends on a markov. If you set them up in the standard way, one is semiz while the other is z, and so VFI Toolkit cannot handle any dependency between them. But if you implement the markov by pretending it is a semi-exogenous markov then you now have two semiz and they are allow to depend on each other.

1 Like

Is the toolkit able to tell that I have only one d that affects the semi-exogenous shocks (and no other d variable)?

By default the toolkit uses one d variable (the last one) to determine the semi-exogenous shocks. This is the default regardless of how many semi-exogenous shocks there are.

You can use the options to change this so that it is more than one d variable being used to determine the semi-exogenous shocks. Specifically, vfoptions.l_dsemiz=1 is the default (and same in simoptions). If you set, e.g., vfoptions.l_dsemiz=2 then the ‘last two’ decision variables are those that are treated as relevant to the semi-exogenous shocks.

PS. This is essentially a by-product of the way that semi-exogenous shocks are handled with just using one ‘SemiExogShockFn’ regardless of the number of semi-exogenous shocks being used.

1 Like

Thanks for the very clear explanation!

I think the repo “Introduction to Lifecycle models” could benefit from a simple model with semi-exogenous shocks. Example 29 on fertility and children is a bit complicated because it has one d variable that does not affect semiz, more than one semiz, more than one d variable that affects the semiz…

Why not adding a simple model with just one semiz, one z and one d variable (and no extra d variables unrelated to semi-exo shocks)? I can share an example with semiz as employment status and d as search effort, if you like.

I agree, but not sure if I will put it into the Intro to Life-Cycle Models or into something else. There are already 50 models, so I kind of just want to do a clean and call it finished. Start on a separate doc that is ‘Intermediate Life-Cycle Models’ or something like that. That said, maybe this specific issue of semi-exo shocks is something I can add to the Appendix that is about different shock types.

1 Like