add chi2 test and update stata code