For viewers of this channel watching from home, I can now estimate my housing demand using the CustomModelStats feature:
function CustomStats=Electrify_HouseholdCustomModelStats(V,Policy,StationaryDist,Parameters,FnsToEvaluate, ...
n_d,n_a,n_z,N_j,d_grid,a_grid,z_gridvals_J,pi_z_J,heteroagentoptions,vfoptions,simoptions)
CustomStats=struct();
% Houses come in 4 sizes (1..4)
CFnsToEvaluate.H1buy = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && hprime==1;
CFnsToEvaluate.H2buy = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && hprime==2;
CFnsToEvaluate.H3buy = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && hprime==3;
CFnsToEvaluate.H4buy = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && hprime==4;
CFnsToEvaluate.H1sell = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && h==1;
CFnsToEvaluate.H2sell = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && h==2;
CFnsToEvaluate.H3sell = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && h==3;
CFnsToEvaluate.H4sell = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) h~=hprime && h==4;
CFnsToEvaluate.H_u = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) (h>0); % Unit house holdings
CFnsToEvaluate.PV_u = @(labor,buyhouse,sprime,aprime,hprime,s,a,h,solarpv,z,e) (solarpv>0); % Unit solarpv holdings
AgeConditionalStats=LifeCycleProfiles_FHorz_Case1(StationaryDist,Policy,CFnsToEvaluate,Parameters,[],n_d,n_a,n_z,N_j,d_grid,a_grid,z_gridvals_J,simoptions);
mean_buyers=[AgeConditionalStats.H1buy.Mean; AgeConditionalStats.H2buy.Mean; AgeConditionalStats.H3buy.Mean; AgeConditionalStats.H4buy.Mean];
mean_sellers=[AgeConditionalStats.H1sell.Mean; AgeConditionalStats.H2sell.Mean; AgeConditionalStats.H3sell.Mean; AgeConditionalStats.H4sell.Mean];
hbuyers=1000*mean_buyers.*Parameters.mewj;
hsellers=1000*mean_sellers.*Parameters.mewj;
hunits=(1:4)';
% Compute the demand independently of buyers and sellers, in case of rounding error
hdemand=sum(round(hbuyers-hsellers),2).*hunits;
hdemand_total=sum(hdemand);
CustomStats.hbuyers_total=sum(sum(round(hbuyers),2).*hunits);
CustomStats.hsellers_total=sum(sum(round(hsellers),2).*hunits);
CustomStats.hdemand_total=hdemand_total;
% CustomStats tells the factory how many net house units need to be built
% It does not specify how many of what size house to build
% Typically for this model, we need about 42 units +/- 6, which can then be scaled as needed to other economic statistics
return