Matlab codes for implementing the HDM model