General linear model in javascript