Estimating variance of random effects to solve multiple problems simultaneously