science.js’s loess() output is identical to input
- by user3710111
Rendered project available here. The line is supposed to be a trend line (as rendered with LOESS), but it merely follows each data point instead.
I am no stats wonk, so maybe it makes sense that a LOESS function’s output would match the input as seen in the above example, but it strikes me as being wrong.
Here is the relevant bit of code:
var loess = science.stats.loess().bandwidth(.2);
var xVal = data.map(function(d) { return d.date; });
var yVal = data.map(function(d) { return d.A; });
var loessData = loess([xVal], [yVal])[0];
console.log(yVal);
console.log(loessData);