This pretty impressive web tool from the Urban Institute shows how difficult it is to make larger affordable housing projects pencil out. This is one reason why encouraging missing middle housing, and particularly secondary dwelling units, can help greatly with affordable housing. In addition, figuring out how to provide incentives to those who build larger affordable developments is also important. While it may not pencil out build a hundred unit apartment complex, the math works a lot better if one is attempting to build a single unit on a lot they already own. Greater Greater Washington provides some additional analysis.