  Handling nominal covariates with a large number of categories is challenging
for both statistical and machine learning techniques. This problem is further
exacerbated when the nominal variable has a hierarchical structure. We commonly
rely on methods such as the random effects approach (Campo and Antonio, 2023)
to incorporate these covariates in a predictive model. Nonetheless, in certain
situations, even the random effects approach may encounter estimation problems.
We propose the data-driven Partitioning Hierarchical Risk-factors Adaptive
Top-down (PHiRAT) algorithm to reduce the hierarchically structured risk factor
to its essence, by grouping similar categories at each level of the hierarchy.
We work top-down and engineer several features to characterize the profile of
the categories at a specific level in the hierarchy. In our workers'
compensation case study, we characterize the risk profile of an industry via
its observed damage rates and claim frequencies. In addition, we use embeddings
(Mikolov et al., 2013; Cer et al., 2018) to encode the textual description of
the economic activity of the insured company. These features are then used as
input in a clustering algorithm to group similar categories. Our method
substantially reduces the number of categories and results in a grouping that
is generalizable to out-of-sample data. Moreover, we obtain a better
differentiation between high-risk and low-risk companies.
