added function to create Z matrix for multilevel models in Stan