code: function ols(endog, exog) {
      var nobs = endog.length;
      var df_model = exog[0].length - 1;
      var df_resid = nobs-df_model - 1;
      var coef = jStat.lstsq(exog, endog);
      var predict =
          jStat.multiply(exog, coef.map(function(x) { return [x] }))
              .map(function(p) { return p[0] });
      var resid = jStat.subtract(endog, predict);
      var ybar = jStat.mean(endog);
      // constant cause problem
      // var SST = jStat.sum(endog.map(function(y) {
      //   return Math.pow(y-ybar,2);
      // }));
      var SSE = jStat.sum(predict.map(function(f) {
        return Math.pow(f - ybar, 2);
      }));
      var SSR = jStat.sum(endog.map(function(y, i) {
        return Math.pow(y - predict[i], 2);
      }));
      var SST = SSE + SSR;
      var R2 = (SSE / SST);
      return {
          exog:exog,
          endog:endog,
          nobs:nobs,
          df_model:df_model,
          df_resid:df_resid,
          coef:coef,
          predict:predict,
          resid:resid,
          ybar:ybar,
          SST:SST,
          SSE:SSE,
          SSR:SSR,
          R2:R2
      };
    }
docs: do OLS model regress exog have include const columns ,it will not generate it .In fact, exog is "design matrix" look at https://en.wikipedia.org/wiki/Design_matrix