updated example without using statsmodels