code for Multivariate analysis