fix bug in simulation of random effects

Fixed bug that caused error when n levels of a random effect factor is
greater than number of unique values.