@@ -254,6 +254,8 @@ def build_loss_matrix(dataset: type, time_period):
254254 # Rough estimate, not CPS derived
255255 "real_estate_taxes" : 400e9 , # Rough estimate between 350bn and 600bn total property tax collections
256256 "rent" : 735e9 , # ACS total uprated by CPI
257+ "is_newborn" : 3_491_679 , # ACS total of people aged 0
258+ "is_pregnant" : 2_618_759 , # 75% of the ACS total of people aged 0
257259 }
258260
259261 for variable_name , target in HARD_CODED_TOTALS .items ():
@@ -340,6 +342,19 @@ def build_loss_matrix(dataset: type, time_period):
340342 )
341343 targets_array .append (row ["population_under_5" ])
342344
345+ # Population by number of newborns and pregancies
346+
347+ age = sim .calculate ("age" ).values
348+ newborns = (age >= 0 ) & (age < 1 )
349+ label = "census/newborns"
350+ loss_matrix [label ] = sim .map_result (newborns , "person" , "household" )
351+ targets_array .append (HARD_CODED_TOTALS ["is_newborn" ])
352+
353+ pregnancies = (age >= - 0.75 ) & (age < 0 )
354+ label = "census/pregnancies"
355+ loss_matrix [label ] = sim .map_result (pregnancies , "person" , "household" )
356+ targets_array .append (HARD_CODED_TOTALS ["is_pregnant" ])
357+
343358 if any (loss_matrix .isna ().sum () > 0 ):
344359 raise ValueError ("Some targets are missing from the loss matrix" )
345360
0 commit comments