We study the credit risk of banks in Germany from lending to non-financial firms. We model changes in Expected Credit Loss, which is derived from the guidelines in the IFRS 9 accounting standard. We map the accounting model to a dataset with individual loans as the unit of observation (AnaCredit). We present new approaches to modeling two well-known credit risk parameters: Loss Given Default (LGD), and Probability of Default (PD), which both affect Expected Credit Loss. First, we obtain an approximation of the Loss Given Default for each individual loan. This step makes use of the detailed collateral data available in AnaCredit and reveals a heterogeneity in LGD that is typically ignored in top?down stress tests. Second, regarding PD, we encounter a missing data problem since only a subset of banks reports default probabilities in AnaCredit. We employ machine learning algorithms to impute missing default probabilities. With the help of these credit risk parameters, we then apply the stress test model to two ad?hoc scenarios in which the downturn in CRE markets worsens to varying degrees and report how this would affect the capital of German banks.