Age-dependent health shocks

Note that when you run the codes, a bunch of the agent mass will end up in ‘dead’. Hence why you will likely want to use simoptions.conditionalrestrictions so as to evaluate all your model statistics conditional on being alive.

Also, you need to be careful when setting up the age weights. You don’t want to include survival probabilities in them (as these are accounted for in the ‘dead’ mass), just the population growth rates (of the young).

1 Like

Thanks for the answer, Robert. Now the probability of dying depends on whether your health status is good or bad (i.e. ds>dh). However, you would want the probability of dying to depend on age as well. In my toy example above I had the survival rate depend on age. In your example the survival rate depends on health. Is there a way to make the survival rate depend on both age and health?

Just make Params.dh and Params.ds be age-dependent parameters (and Params.h and Params.s would likely be age-dependent parameters too).

[And of course create pi_z_J instead of the above pi_z. Except I believe you want it to be a semi-exo state, so obviously do the equivalent version for a semi-exo state]

[And have different ones for each ptype (can just be different parameter values and the same SemiExoStateFn)]

1 Like

Another question about age-dependent health shocks, this time NO semi-exogenous shocks :slight_smile:
I would like to have two z shocks: zn is an income shock, NOT age-dependent, and zh is a health shock, age-dependent. You explained very clearly how to do this in your first answer above. Now I want to make zh also depend on a permanent type. Can I do the following:

(i) n_z=[n1,n2]; with n1 the number of grid points for zn (income), and n2 the number of grid points for zh (health). Let N_j be the number of model periods.
(ii) create [zn_grid, pi_zn] for the (not age-dependent) income shock (sizes are [n1,1] and [n1,n1];
(iii) create [zh_grid_J, pi_zh_J] for the (age-dependent) health shock where now zh_grid_J and pi_zh_J are not numeric arrays but structures
zh_grid_J.sick = array with size [n2,N_j]
zh_grid_J.healthy = array with size [n2,N_j]
pi_zh_J.sick = array with size [n2,n2,N_j]
pi_zh_J.healthy = array with size [n2,n2,N_j]

Question: How do I combine the grids and the transition matrices? For example, I want to combine zn_grid_J = zn_grid*ones(1,N_j) with zh_grid_J but now zh_grid_J is a structure

You can do (i), (ii) and (iii) exactly as you describe.

Toolkit either has to let all of z depend on permanent type or none of z depend on permanent type. So essentially we have to set up two copies of z, one for each permanent type (both will contain the same zn, but different zh parts). So you are going to want z_grid_J.sick and z_grid_J.healthy, as well as pi_z_J.sick and pi_z_J.healthy.

So now you just need a (iv).
Keep your n_z=[n1,n2];
Set

z_grid_J.sick=[zn_grid*ones(1,N_j); zh_grid_J.sick]; % array with size [n1+n2,N_j]
z_grid_J.healthy=[zn_grid*ones(1,N_j); zh_grid_J.healthy]; % array with size [n1+n2,N_j]
pi_z_J.sick=zeros(n1*n2,n1*n2,N_j); % array with size [n1*n2,n1*n2,N_j]
pi_z_J.healthy=zeros(n1*n2,n1*n2,N_j); % array with size [n1*n2,n1*n2,N_j]
for jj=1:N_j
   pi_z_J.sick(:,:,jj)=kron(pi_zh_J.sick(:,:,jj), pi_zn);  % note: kron in reverse order
   pi_z_J.healthy(:,:,jj)=kron(pi_zh_J.healthy(:,:,jj), pi_zn);  % note: kron in reverse order
end

(Formatting has gone weird, the ; is starting a comment which is not intended, read the z_grid_J lines carefully. I don’t want to change it as it is in matlab format.)

1 Like

Thank you very much for the detailed answer, Robert!

EDIT
I think this part

for jj=1:N_j
   pi_z_J.sick(:,:,jj)=kron(pi_zh_J.sick, pi_zn);  % note: kron in reverse order
   pi_z_J.healthy(:,:,jj)=kron(pi_zh_J.healthy, pi_zn);  % note: kron in reverse order
end

should actually be

for jj=1:N_j
   pi_z_J.sick(:,:,jj)=kron(pi_zh_J.sick(:,:,jj), pi_zn);  % note: kron in reverse order
   pi_z_J.healthy(:,:,jj)=kron(pi_zh_J.healthy(:,:,jj), pi_zn);  % note: kron in reverse order
end
1 Like

quite right, have corrected my post

1 Like