R package treeHFM. Hidden Factor graph models generalise Hidden Markov Models to tree structured data. The distinctive feature of ’treeHFM’ is that it learns a transition matrix for first order (sequential) and for second order (splitting) events. It can be applied to all discrete and continuous data that is structured as a binary tree. In the case of continuous observations, ’treeHFM’ has Gaussian distributions as emissions.