Learning procedure for chain (stratified) graphical models