Skip to content

Commit ac84f11

Browse files
committed
minor fix
1 parent f6e0b9a commit ac84f11

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

EvaluateFnOnAgentDist/FHorz/PType/LifeCycleProfiles_FHorz_Case1_PType.m

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -575,37 +575,36 @@
575575
% Note, eliminating zero weights and unique() cannot be done yet as they need to be conditional on j
576576
% (otherwise lose the j dimension if I just apply them now)
577577

578-
579578
% Preallocate various things for the stats (as many will have jj as a dimension)
580579
% Stats to calculate and store in AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).
581-
if simoptions.whichstats(1)==1
580+
if simoptions_temp.whichstats(1)==1
582581
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Mean=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
583582
end
584-
if simoptions.whichstats(2)==1
583+
if simoptions_temp.whichstats(2)==1
585584
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Median=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
586-
if simoptions.whichstats(1)==1
585+
if simoptions_temp.whichstats(1)==1
587586
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).RatioMeanToMedian=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
588587
end
589588
end
590-
if simoptions.whichstats(3)==1
589+
if simoptions_temp.whichstats(3)==1
591590
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Variance=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
592591
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).StdDeviation=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
593592
end
594-
if simoptions.whichstats(4)>=1
593+
if simoptions_temp.whichstats(4)>=1
595594
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Gini=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
596-
if simoptions.whichstats(4)<3
595+
if simoptions_temp.whichstats(4)<3
597596
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).LorenzCurve=nan(simoptions_temp.npoints,length(simoptions_temp.agegroupings),'gpuArray');
598597
end
599598
end
600-
if simoptions.whichstats(5)==1
599+
if simoptions_temp.whichstats(5)==1
601600
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Minimum=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
602601
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Maximum=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
603602
end
604-
if simoptions.whichstats(6)>=1
603+
if simoptions_temp.whichstats(6)>=1
605604
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).QuantileCutoffs=nan(simoptions_temp.nquantiles+1,length(simoptions_temp.agegroupings),'gpuArray'); % Includes the min and max values
606605
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).QuantileMeans=nan(simoptions_temp.nquantiles,length(simoptions_temp.agegroupings),'gpuArray');
607606
end
608-
if simoptions.whichstats(7)==1
607+
if simoptions_temp.whichstats(7)==1
609608
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top1share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
610609
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top5share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
611610
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top10share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
@@ -617,34 +616,34 @@
617616
end
618617
if useCondlRest==1
619618
for rr=1:length(CondlRestnFnNames)
620-
if simoptions.whichstats(1)==1
619+
if simoptions_temp.whichstats(1)==1
621620
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Mean=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
622621
end
623-
if simoptions.whichstats(2)==1
622+
if simoptions_temp.whichstats(2)==1
624623
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Median=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
625-
if simoptions.whichstats(1)==1
624+
if simoptions_temp.whichstats(1)==1
626625
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).RatioMeanToMedian=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
627626
end
628627
end
629-
if simoptions.whichstats(3)==1
628+
if simoptions_temp.whichstats(3)==1
630629
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Variance=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
631630
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).StdDeviation=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
632631
end
633-
if simoptions.whichstats(4)>=1
632+
if simoptions_temp.whichstats(4)>=1
634633
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Gini=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
635634
if simoptions.whichstats(4)<3
636635
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).LorenzCurve=nan(simoptions_temp.npoints,length(simoptions_temp.agegroupings),'gpuArray');
637636
end
638637
end
639-
if simoptions.whichstats(5)==1
638+
if simoptions_temp.whichstats(5)==1
640639
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Minimum=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
641640
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).Maximum=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
642641
end
643-
if simoptions.whichstats(6)>=1
642+
if simoptions_temp.whichstats(6)>=1
644643
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).QuantileCutoffs=nan(simoptions_temp.nquantiles+1,length(simoptions_temp.agegroupings),'gpuArray'); % Includes the min and max values
645644
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).QuantileMeans=nan(simoptions_temp.nquantiles,length(simoptions_temp.agegroupings),'gpuArray');
646645
end
647-
if simoptions.whichstats(7)==1
646+
if simoptions_temp.whichstats(7)==1
648647
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top1share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
649648
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top5share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
650649
AgeConditionalStats.(CondlRestnFnNames{rr}).(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top10share=nan(1,length(simoptions_temp.agegroupings),'gpuArray');
@@ -687,37 +686,37 @@
687686
SortedWeights_jj=SortedWeights_jj/sum(SortedWeights_jj(:)); % Normalize conditional on jj (is later renormalized ii weight before storing for groupstats)
688687

689688
%% Use the full ValuesOnGrid_ii and StationaryDist_ii to calculate various statistics for the current PType-FnsToEvaluate (current ii and ff)
690-
tempStats=StatsFromWeightedGrid(SortedValues_jj,SortedWeights_jj,simoptions.npoints,simoptions.nquantiles,simoptions.tolerance,1,simoptions.whichstats); % 1 is presorted
689+
tempStats=StatsFromWeightedGrid(SortedValues_jj,SortedWeights_jj,simoptions_temp.npoints,simoptions_temp.nquantiles,simoptions_temp.tolerance,1,simoptions_temp.whichstats); % 1 is presorted
691690

692691
% Now store these based on jj
693-
if simoptions.whichstats(1)==1
692+
if simoptions_temp.whichstats(1)==1
694693
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Mean(jj)=tempStats.Mean;
695694
end
696-
if simoptions.whichstats(2)==1
695+
if simoptions_temp.whichstats(2)==1
697696
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Median(jj)=tempStats.Median;
698-
if simoptions.whichstats(1)==1
697+
if simoptions_temp.whichstats(1)==1
699698
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).RatioMeanToMedian(jj)=tempStats.RatioMeanToMedian;
700699
end
701700
end
702-
if simoptions.whichstats(3)==1
701+
if simoptions_temp.whichstats(3)==1
703702
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Variance(jj)=tempStats.Variance;
704703
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).StdDeviation(jj)=tempStats.StdDeviation;
705704
end
706-
if simoptions.whichstats(4)>=1
705+
if simoptions_temp.whichstats(4)>=1
707706
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Gini(jj)=tempStats.Gini;
708-
if simoptions.whichstats(4)<3
707+
if simoptions_temp.whichstats(4)<3
709708
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).LorenzCurve(:,jj)=tempStats.LorenzCurve;
710709
end
711710
end
712-
if simoptions.whichstats(5)==1
711+
if simoptions_temp.whichstats(5)==1
713712
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Minimum(jj)=tempStats.Minimum;
714713
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).Maximum(jj)=tempStats.Maximum;
715714
end
716-
if simoptions.whichstats(6)>=1
715+
if simoptions_temp.whichstats(6)>=1
717716
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).QuantileCutoffs(:,jj)=tempStats.QuantileCutoffs;
718717
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).QuantileMeans(:,jj)=tempStats.QuantileMeans;
719718
end
720-
if simoptions.whichstats(7)==1
719+
if simoptions_temp.whichstats(7)==1
721720
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top1share(jj)=tempStats.MoreInequality.Top1share;
722721
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top5share(jj)=tempStats.MoreInequality.Top5share;
723722
AgeConditionalStats.(FnsToEvalNames{ff}).(Names_i{ii}).MoreInequality.Top10share(jj)=tempStats.MoreInequality.Top10share;
@@ -729,14 +728,14 @@
729728
end
730729

731730
% For later, put the mean and std dev in a convenient place. These are instead done on jjageshifted (so they can be grouped across ptypes later)
732-
if simoptions.whichstats(1)==1
731+
if simoptions_temp.whichstats(1)==1
733732
MeanVec(ff,ii,jjageshifted)=tempStats.Mean;
734733
end
735-
if simoptions.whichstats(3)==1
734+
if simoptions_temp.whichstats(3)==1
736735
StdDevVec(ff,ii,jjageshifted)=tempStats.StdDeviation;
737736
end
738737
% Do the same with the minimum and maximum
739-
if simoptions.whichstats(5)==1
738+
if simoptions_temp.whichstats(5)==1
740739
minvaluevec(ff,ii,jjageshifted)=tempStats.Minimum;
741740
maxvaluevec(ff,ii,jjageshifted)=tempStats.Maximum;
742741
end
@@ -847,6 +846,10 @@
847846
end
848847
% Preallocate various things for the stats (as many will have jj as a dimension)
849848
% Stats to calculate and store in AgeConditionalStats.(FnsToEvalNames{ff})
849+
% If we can put these together, it must be the case that whichstats is same for all permanent types
850+
if isstruct(simoptions.whichstats)
851+
simoptions.whichstats=simoptions.whichstats.(Names_i{1}); % just use the first one
852+
end
850853
for ff=1:numFnsToEvaluate
851854
if simoptions.whichstats(1)==1
852855
AgeConditionalStats.(FnsToEvalNames{ff}).Mean=nan(1,N_j_max2,'gpuArray'); % Note: N_j_max2=length(simoptions.agegroupings) in basic setup, will be different when N_j or agejshifter varies by PType

0 commit comments

Comments
 (0)