Code for fitting subunit models