cap log close
clear
cd "C:\Desktop"
use Multicollinearity.DTA
log using wasin_multicollinearlity_problem,replace
/*Multicollinearity Problem */
/* First, regress the academic performance of the school (api00) on percent receiving free meals (meals),  and   the average parent education variables (avg_ed)*/

/* Type the following command */

regress  api00 meals  avg_ed

/* meals =pct free meanls */
/* avg_ed = aveg parent ed */

/* Now we add ell  grad_sch col_grad some_col */

/* ell = english language learner */

/* grad sch =parent grad school */

/* col_grad =parent some college */

/* some_col =parent some college */

regress api00 meals ell  avg_ed  grad_sch col_grad some_col

/* high R^2  and statistically overall significant of the model from the F-test  BUT some coefficients are not individually significant. This is because the t-statistic is low due to multicollinearlity problem. */

/* Thus, we have to check the problem */

/* First, check the VIF (Variance Inflation Factor) */

/* Type the following command */

vif

/*In this example, the VIF and tolerance (1/VIF) values for avg_ed grad_sch and col_grad are worrisome.  All of these variables measure education of the parents and the very high VIF values indicate that these variables are possibly redundant.  For example, after you know grad_sch and col_grad, you probably can predict avg_ed very well.  In this example, multicollinearity arises because we have put in too many variables that measure the same thing, parent education. */

/* We can also check the correlation of the regressors */

/* Type the following command */
corr api00 meals ell  avg_ed  grad_sch col_grad some_col, means
  
/*  We have very high correlation between avg_ed and grad_school (0.7973), avg_ed and col_grad (0.8089) and avg_ed.*/

/* We therefore can fix the problem by discarding some explanatory variables (grad_sch col_grad and some_col)*/

regress api00 meals ell  avg_ed

/* Now check VIF again */

vif 

/* the problem is solved */
/* Good luck for final examination :)  */



